Beispiel #1
0
 public void RemoveObject(SSObjectID name, GameObject obj)
 {
     if (objectList.ContainsKey(name)) {
         List<GameObject> gameObjList = objectList[name].objList;
         gameObjList.Remove(obj);
     }
 }
 public void RemoveObject(SSObjectID name, GameObject obj)
 {
     if (objectList.ContainsKey(name))
     {
         List <GameObject> gameObjList = objectList[name].objList;
         gameObjList.Remove(obj);
     }
 }
Beispiel #3
0
    public void AddObject(SSObjectID name, GameObject obj)
    {
        List<GameObject> gameObjList = null;
        if (objectList.ContainsKey(name)) {
            gameObjList = objectList[name].objList;
            gameObjList.Add(obj);
        }
        else {
            gameObjList = new List<GameObject>();
            gameObjList.Add(obj);

            SSPooledObject pooledObj = new SSPooledObject();
            pooledObj.obj = obj;

            GameObject objParent = new GameObject(obj.name + " Parent");
            pooledObj.parent = objParent.transform;
            objectList.Add(name, pooledObj);
        }
    }
Beispiel #4
0
    public GameObject GetObject(SSObjectID name)
    {
        if (objectList.ContainsKey(name)) {
            List<GameObject> objList = objectList[name].objList;
            for (int i = 0; i < objList.Count; i++) {
                if (!objList[i].activeInHierarchy) {
                    return objList[i];
                }
            }

            // Creates additional objects if needed
            GameObject obj = (GameObject)Instantiate(objectList[name].obj);
            obj.name = objectList[name].obj.name;
            obj.transform.parent = objectList[name].parent;
            objList.Add(obj);
            objectList[name].objList = objList;
            return obj;
        }

        return null;
    }
    public void AddObject(SSObjectID name, GameObject obj)
    {
        List <GameObject> gameObjList = null;

        if (objectList.ContainsKey(name))
        {
            gameObjList = objectList[name].objList;
            gameObjList.Add(obj);
        }
        else
        {
            gameObjList = new List <GameObject>();
            gameObjList.Add(obj);

            SSPooledObject pooledObj = new SSPooledObject();
            pooledObj.obj = obj;

            GameObject objParent = new GameObject(obj.name + " Parent");
            pooledObj.parent = objParent.transform;
            objectList.Add(name, pooledObj);
        }
    }
    public GameObject GetObject(SSObjectID name)
    {
        if (objectList.ContainsKey(name))
        {
            List <GameObject> objList = objectList[name].objList;
            for (int i = 0; i < objList.Count; i++)
            {
                if (!objList[i].activeInHierarchy)
                {
                    return(objList[i]);
                }
            }

            // Creates additional objects if needed
            GameObject obj = (GameObject)Instantiate(objectList[name].obj);
            obj.name             = objectList[name].obj.name;
            obj.transform.parent = objectList[name].parent;
            objList.Add(obj);
            objectList[name].objList = objList;
            return(obj);
        }

        return(null);
    }