C# Class TrashMan, RecyclerKit

Inheritance: MonoBehaviour
ファイルを表示 Open project: prime31/RecyclerKit Class Usage Examples

Public Properties

Property Type Description
cullExcessObjectsInterval float
instance TrashMan,
persistBetweenScenes bool

Public Methods

Method Description
despawn ( GameObject go ) : void

sticks the GameObject back into its recycle bin. If the GameObject has no bin it is destroyed.

despawnAfterDelay ( GameObject go, float delayInSeconds ) : void

sticks the GameObject back into it's recycle bin after a delay. If the GameObject has no bin it is destroyed.

manageRecycleBin ( TrashManRecycleBin, recycleBin ) : void

tells TrashMan to start managing the recycle bin at runtime

recycleBinForGameObject ( GameObject go ) : TrashManRecycleBin,

gets the recycle bin for the given GameObject. Returns null if none exists.

recycleBinForGameObjectName ( string gameObjectName ) : TrashManRecycleBin,

gets the recycle bin for the given GameObject name. Returns null if none exists.

removeRecycleBin ( TrashManRecycleBin, recycleBin, bool shouldDestroyAllManagedObjects = true ) : void

stops managing the recycle bin optionally destroying all managed objects

spawn ( GameObject go, Vector3 position = default(Vector3), Quaternion rotation = default(Quaternion) ) : GameObject

pulls an object out of the recycle bin

spawn ( string gameObjectName, Vector3 position = default(Vector3), Quaternion rotation = default(Quaternion) ) : GameObject

pulls an object out of the recycle bin using the bin's name

Private Methods

Method Description
Awake ( ) : void
OnApplicationQuit ( ) : void
activeSceneChanged ( Scene, oldScene, Scene, newScene ) : void
cullExcessObjects ( ) : IEnumerator

coroutine that runs every couple seconds and removes any objects created over the recycle bins limit

initializePrefabPools ( ) : void

populats the lookup dictionaries

internalDespawnAfterDelay ( GameObject go, float delayInSeconds ) : IEnumerator

internal coroutine for despawning after a delay

spawn ( int gameObjectInstanceId, Vector3 position, Quaternion rotation ) : GameObject

internal method that actually does the work of grabbing the item from the bin and returning it

Method Details

despawn() public static method

sticks the GameObject back into its recycle bin. If the GameObject has no bin it is destroyed.
public static despawn ( GameObject go ) : void
go GameObject Go.
return void

despawnAfterDelay() public static method

sticks the GameObject back into it's recycle bin after a delay. If the GameObject has no bin it is destroyed.
public static despawnAfterDelay ( GameObject go, float delayInSeconds ) : void
go GameObject Go.
delayInSeconds float
return void

manageRecycleBin() public static method

tells TrashMan to start managing the recycle bin at runtime
public static manageRecycleBin ( TrashManRecycleBin, recycleBin ) : void
recycleBin TrashManRecycleBin, Recycle bin.
return void

recycleBinForGameObject() public static method

gets the recycle bin for the given GameObject. Returns null if none exists.
public static recycleBinForGameObject ( GameObject go ) : TrashManRecycleBin,
go GameObject Go.
return TrashManRecycleBin,

recycleBinForGameObjectName() public static method

gets the recycle bin for the given GameObject name. Returns null if none exists.
public static recycleBinForGameObjectName ( string gameObjectName ) : TrashManRecycleBin,
gameObjectName string
return TrashManRecycleBin,

removeRecycleBin() public static method

stops managing the recycle bin optionally destroying all managed objects
public static removeRecycleBin ( TrashManRecycleBin, recycleBin, bool shouldDestroyAllManagedObjects = true ) : void
recycleBin TrashManRecycleBin, Recycle bin.
shouldDestroyAllManagedObjects bool If set to true should destroy all managed objects.
return void

spawn() public static method

pulls an object out of the recycle bin
public static spawn ( GameObject go, Vector3 position = default(Vector3), Quaternion rotation = default(Quaternion) ) : GameObject
go GameObject Go.
position Vector3
rotation Quaternion
return GameObject

spawn() public static method

pulls an object out of the recycle bin using the bin's name
public static spawn ( string gameObjectName, Vector3 position = default(Vector3), Quaternion rotation = default(Quaternion) ) : GameObject
gameObjectName string
position Vector3
rotation Quaternion
return GameObject

Property Details

cullExcessObjectsInterval public_oe property

this is how often in seconds TrashMan should cull excess objects. Setting this to 0 or a negative number will fully turn off automatic culling. You can then use the TrashManRecycleBin.cullExcessObjects method manually if you would still like to do any culling.
public float cullExcessObjectsInterval
return float

instance public_oe static_oe property

access to the singleton
public static TrashMan, instance
return TrashMan,

persistBetweenScenes public_oe property

if true, DontDestroyOnLoad will be called on the TrashMan
public bool persistBetweenScenes
return bool