示例#1
0
 protected UnityEngine.Object _GetObject(string path, bool isPrefab, ResourceObjectPoolHandler callback)
 {
     if (!m_lstPath.Contains(path))
     {
         m_lstPath.Add(path);
     }
     return(ResourceObjectPool.Instance.GetObject(path, isPrefab, callback));
 }
        public void RemoveCallback(string path, ResourceObjectPoolHandler callback)
        {
            List <GameObjectPoolCallbackStruct> lst = null;

            if (m_dicCallback.TryGetValue(path, out lst))
            {
                for (int i = lst.Count - 1; i > -1; i--)
                {
                    if (lst[i].callback == callback)
                    {
                        lst.RemoveAt(i);
                        break;
                    }
                }
            }
        }
示例#3
0
 protected void _RemoveCallback(string path, ResourceObjectPoolHandler callback)
 {
     ResourceObjectPool.Instance.RemoveCallback(path, callback);
 }
示例#4
0
 public UnityEngine.Object GetObject(string path, ResourceObjectPoolHandler callback)
 {
     return(ResourceObjectPool.Instance.GetObject(path, true, callback));
 }
示例#5
0
 public void RemoveCallback(string path, ResourceObjectPoolHandler callback)
 {
     base._RemoveCallback(PathTool.GetBasePrefabPath(path), callback);
 }
示例#6
0
 public UnityEngine.Object GetObject(string path, bool isPrefab, ResourceObjectPoolHandler callback)
 {
     return(base._GetObject(PathTool.GetBasePrefabPath(path), isPrefab, callback));
 }
        public UnityEngine.Object GetObject(string path, bool isPrefab, ResourceObjectPoolHandler callback)
        {
            ResourceObjectQueue resQueue;

            if (m_dicGO.TryGetValue(path, out resQueue))
            {
                if (resQueue.isDone)
                {
                    UnityEngine.Object go = null;
                    if (isPrefab)
                    {
                        go = resQueue.prefab;
                    }
                    else
                    {
                        if (resQueue.queue.Count > 0)
                        {
                            go = resQueue.queue.Dequeue();
                        }
                        else
                        {
                            go = GetGameObject(resQueue.prefab, path);
                        }
                        ((GameObject)go).SetActive(true);
                    }

                    if (null != callback)
                    {
                        var tempCallback = callback;
                        callback = null;
                        tempCallback.Invoke(path, go);
                    }
                    return(go);
                }
            }
            if (callback != null)
            {
                List <GameObjectPoolCallbackStruct> lst = null;
                if (!m_dicCallback.TryGetValue(path, out lst))
                {
                    lst = new List <GameObjectPoolCallbackStruct>();
                    m_dicCallback.Add(path, lst);
                }
                bool contain = false;
                for (int i = 0; i < lst.Count; i++)
                {
                    if (lst[i].callback == callback)
                    {
                        contain = true;
                        break;
                    }
                }
                if (!contain)
                {
                    GameObjectPoolCallbackStruct callbackStruct = new GameObjectPoolCallbackStruct();
                    callbackStruct.callback = callback;
                    callbackStruct.isPrefab = isPrefab;
                    lst.Add(callbackStruct);
                }
            }
            if (resQueue == null)
            {
                resQueue = ObjectPool <ResourceObjectQueue> .Instance.GetObject();

                resQueue.isDone = false;
                resQueue.queue  = new Queue <UnityEngine.Object>();
                resQueue.prefab = null;
                m_dicGO.Add(path, resQueue);
                Resource res = ResourceSys.Instance.GetResource(path, OnResLoad);
                resQueue.res = res;
                res.Retain();
            }
            return(null);
        }