Exemplo n.º 1
0
        private GameObject GetGameObject(string path, Vector3 pos, Quaternion rot, bool useRotation, out bool isInit)
        {
            Queue <CPooledGameObjectScript> queue = null;

            if (!this._pooledGameObjectMap.TryGetValue(path, out queue))
            {
                queue = new Queue <CPooledGameObjectScript>();
                this._pooledGameObjectMap.Add(path, queue);
            }

            CPooledGameObjectScript cPooledGameObjectScript = null;

            while (queue.Count > 0)
            {
                cPooledGameObjectScript = queue.Dequeue();
                if (cPooledGameObjectScript != null && cPooledGameObjectScript.gameObject != null)
                {
                    cPooledGameObjectScript.gameObject.transform.SetParent(null, true);
                    cPooledGameObjectScript.gameObject.transform.position   = pos;
                    cPooledGameObjectScript.gameObject.transform.rotation   = rot;
                    cPooledGameObjectScript.gameObject.transform.localScale = cPooledGameObjectScript.DefaultScale;
                    break;
                }
                cPooledGameObjectScript = null;
            }
            if (cPooledGameObjectScript == null)
            {
                cPooledGameObjectScript = this.CreateGameObject(path, pos, rot, useRotation);
#if UNITY_EDITOR
                //SuperDebug.Log(SuperDebug.ASSETBUNDLE, "这个资源没缓存呀:" + text);
#endif
            }
            if (cPooledGameObjectScript == null)
            {
                isInit = false;
                return(null);
            }
            isInit = cPooledGameObjectScript.IsInit;
            cPooledGameObjectScript.OnGet();
            return(cPooledGameObjectScript.gameObject);
        }