Difference between revisions of "RandomPrefabSpawner"
(Initial page, includes API information and categories) |
(Added image link) |
||
Line 1: | Line 1: | ||
+ | [[File:RandomPrefabSpawner.png|thumb|right|Custom editor interface for this script]] | ||
This script allows the game designer to easily spawn prefabs randomly around the object it's attached to. It provides a custom editor interface with buttons to allow the designer to clear and regenerate the random prefabs easily. Additionally, the RNG can be sent a seed value to re-create the same random field each time. | This script allows the game designer to easily spawn prefabs randomly around the object it's attached to. It provides a custom editor interface with buttons to allow the designer to clear and regenerate the random prefabs easily. Additionally, the RNG can be sent a seed value to re-create the same random field each time. | ||
+ | |||
== Public Variables == | == Public Variables == | ||
Line 19: | Line 21: | ||
This will be set to [http://docs.unity3d.com/Documentation/ScriptReference/Random-seed.html seed] the random number generator before prefabs are spawned, unless randomizeSeed is set to true. | This will be set to [http://docs.unity3d.com/Documentation/ScriptReference/Random-seed.html seed] the random number generator before prefabs are spawned, unless randomizeSeed is set to true. | ||
=== randomizeSeed : bool === | === randomizeSeed : bool === | ||
− | If this is true, the '''seed''' will be set to the current time when UpdateField () is called. | + | If this is true, the '''seed''' will be set to the current time when [[RandomPrefabSpawner#void_UpdateField_.28.29|UpdateField ()]] is called. |
=== numToGenerate : int === | === numToGenerate : int === | ||
This is how many prefabs will be spawned. | This is how many prefabs will be spawned. |
Latest revision as of 17:04, 20 April 2013
This script allows the game designer to easily spawn prefabs randomly around the object it's attached to. It provides a custom editor interface with buttons to allow the designer to clear and regenerate the random prefabs easily. Additionally, the RNG can be sent a seed value to re-create the same random field each time.
Contents |
[edit] Public Variables
[edit] mode : GenerationMode
This determines along what axis the objects are placed. It may have the following values:
[edit] X
This places objects linearly along the X axis.
[edit] Y
This places objects linearly along the Y axis.
[edit] Z
This places objects linearly along the Z axis.
[edit] X_Y
This places objects in a circle on the X, Y plane.
[edit] X_Z
This places objects in a circle on the X, Z plane.
[edit] X_Y_Z
This places objects inside a sphere.
[edit] seed : int
This will be set to seed the random number generator before prefabs are spawned, unless randomizeSeed is set to true.
[edit] randomizeSeed : bool
If this is true, the seed will be set to the current time when UpdateField () is called.
[edit] numToGenerate : int
This is how many prefabs will be spawned.
[edit] radius : float
This is how large of an area the prefabs will cover. This is shown in the Scene view of the Unity Editor as a green wireframe sphere when this object is selected.
[edit] prefabs : List<GameObject>
This is the list of all of the prefabs that will be spawned.
[edit] Public Functions
[edit] void ClearField ()
This clears the field by destroying all child objects of the object.
[edit] void UpdateField ()
This spawns the prefabs randomly around the current object, as defined by the public variables. The prefabs that are spawned are set as child objects of the object this script is attached to, so the entire thing can be moved around the scene easily.