Exemplo n.º 1
0
        public void RemoveCallback(string path, GameObjectPoolHandler callback)
        {
            List <GameObjectPoolHandler> lst = null;

            if (m_dicCallback.TryGetValue(path, out lst))
            {
                lst.Remove(callback);
            }
        }
Exemplo n.º 2
0
        public void GetObject(string path, GameObjectPoolHandler callback)
        {
            if (callback == null)
            {
                CLog.LogError("GameObjectPool callback can not be null!");
                return;
            }
            foreach (var item in m_dicGO)
            {
                if (item.Key.path == path)
                {
                    GameObject go = null;
                    if (item.Value.Count > 0)
                    {
                        go = item.Value.Dequeue();
                    }
                    else
                    {
                        go = GetGameObject(item.Key);
                    }
                    go.SetActive(true);
                    callback.Invoke(go);
                    return;
                }
            }
            List <GameObjectPoolHandler> lst = null;

            if (!m_dicCallback.TryGetValue(path, out lst))
            {
                lst = new List <GameObjectPoolHandler>();
                m_dicCallback.Add(path, lst);
            }
            if (!lst.Contains(callback))
            {
                lst.Add(callback);
            }
            ResourceSys.Instance.GetResource(path, OnResLoad);
        }