If it goes out of range, it wraps back to the start.ĬurrentSpawnPointIndex = (currentSpawnPointIndex + 1) % 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 |