If you’re working with ScriptableObject references in the Inspector, you can double click the reference field to open the Inspector for your ScriptableObject. The Prefab you referenced in the Spawner instantiates using the values you set in the SpawnManagerScriptableObject instance. Set the Entity To Spawn field to any Prefab in your Assets folder, then click Play in the Editor. More info See in Glossary, set the Spawn Manager Values field to the new SpawnManagerScriptableObject that you set up. Then, in the Inspector A Unity window that displays information about the currently selected GameObject, Asset or Project Settings, allowing you to inspect and edit the values. In each Scene, you place your environments, obstacles, and decorations, essentially designing and building your game in pieces. Think of each unique Scene file as a unique level. If it goes out of range, it wraps back to the start.ĬurrentSpawnPointIndex = (currentSpawnPointIndex + 1) % Īttach the above script to a GameObject in your Scene A Scene contains the environments and menus of your game. Sets the name of the instantiated entity to be the string defined in the ScriptableObject and then appends it with a unique number.ĬurrentEntity.name = spawnManagerValues.prefabName + instanceNumber GameObject currentEntity = Instantiate(entityToSpawn, spawnManagerValues.spawnPoints, Quaternion.identity) Creates an instance of the prefab at the current spawn point. This will be appended to the name of the created entities and increment when each is created.įor (int i = 0 i < spawnManagerValues.numberOfPrefabsToCreate i++) Public SpawnManagerScriptableObject spawnManagerValues An instance of the ScriptableObject defined above. To use these values, you need to create a new script that references your ScriptableObject, in this case, a SpawnManagerScriptableObject. Give your new ScriptableObject instance a meaningful name and alter the values. With the above script in your Assets folder, you can create an instance of your ScriptableObject by navigating to Assets > Create > ScriptableObjects > SpawnManagerScriptableObject. Public class SpawnManagerScriptableObject : ScriptableObject You can use the CreateAssetMenu attribute to make it easy to create custom assets using your class. More info See in Glossary folder and make it inherit from the ScriptableObject class. You can also create some asset types in Unity, such as an Animator Controller, an Audio Mixer or a Render Texture. An asset may come from a file created outside of Unity, such as a 3D model, an audio file or an image. To use a ScriptableObject, create a script in your application’s Assets Any media or data that can be used in your game or Project.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |