Skip to content

GameObjectManager

高凯 edited this page Dec 31, 2017 · 1 revision

Introduction

Is essentially a pool of objects that can help you reduce the frequent creation of destruction costs, provide the PoolObject class to provide OnCreate、OnFetch 、 OnRecycle interface.

API

GameObjectManager
static GameObject CreateGameObject (string gameObjectName, GameObject parent = null)
Load an object and instantiate it (do not use the object pool)

static GameObject CreateGameObjectByPool (string name, GameObject parent = null, bool isSetActive = true)
Remove an object from the object pool, if not, then create it directly, isSetActive is used to determine whether to reset the object's Active, used to save the Unity components overhead

static void DestroyGameObjectByPool (GameObject obj, bool isSetActive = true)
 Put an object into the object pool, isSetActive: whether to reset Active

static void DestroyGameObjectByPool (GameObject go, float time)
Delay in putting an object into the object pool

static void CleanPool ()
Clear the object pool

static void CleanPoolByName (string name)
Clear all object pool cache for one object

static void CreateGameObjectByPoolAsync (string name, CallBack <GameObject> callback, GameObject parent = null, bool isSetActive = true)
Load an object asynchronously and create it

GameObjectManager -> PoolObject
static void PutPoolObject (string gameObjectName)
Preload an object and put it in the object pool, not created

static PoolObject GetPoolObject (string name, GameObject parent = null)
Remove an object from the object pool, if not, then create it directly

static void DestroyPoolObject (PoolObject obj)
Put an object into the object pool

static void CleanPool_New ()
Empty PoolObject object pool

public static void CleanPoolByName_New (string name)
Clears all object pool cache for one PoolObject object

static void CreatePoolObjectAsync (string name, CallBack <PoolObject> callback, GameObject parent = null)
Asynchronously load a PoolObject object and create it

Tip

  • Use the object pool to be careful to ensure that you put the object into the object pool, all the necessary data has been reset, otherwise unexpected BUG may occur
  • Remember to clear the animation of the object before entering the pool, this may also be a hard to find BUG :)
Clone this wiki locally