![]() ![]() You will see the Prefab you referenced in the Spawner instantiated using the settings you set in the SpawnManagerScriptableObject.ĪbleObject-derived class, you can use the CreateAssetMenu attribute to make it easy to create custom assets using your class. Set the Entity To Spawn field to be any Prefab in your Assets folder, and then click Play in the Editor. See in Glossary, set the Spawn Manager Values field to be 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, alowing 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. 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, you need to create a script in your Assets Any media or data that can be used in your game or Project.
0 Comments
Leave a Reply. |
Details
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |