예제 #1
0
        private T GetOrCreateToolTip <T>() where T : ToolTipBase, new()
        {
            Type   toolTipType = typeof(T);
            string poolName    = toolTipType.FullName;

            var pool = UIPoolManager.GetInstance().GetPool(poolName);

            if (pool == null)
            {
                pool          = UIPoolManager.GetInstance().CreatePool(poolName, toolTipType);
                pool.onCreate = (tipCom) =>
                {
                    tipCom.OnAddedToStage((EventContext _) =>
                    {
                        var dict = GetToolTipDict();
                        var key  = GetToolTipKey <T>();
                        if (!dict.ContainsKey(key))
                        {
                            dict.Add(key, tipCom as ToolTipBase);
                        }
                    });

                    tipCom.OnRemovedFromStage((EventContext _) =>
                    {
                        var dict = GetToolTipDict();
                        var key  = GetToolTipKey <T>();
                        dict.Remove(key);

                        pool.Release(tipCom);
                    });
                };
                pool.onRelease = (fObj) => { };
            }
            return(pool.GetOrCreate() as T);
        }
예제 #2
0
 public void RemoveFromParent()
 {
     UIPoolManager.GetInstance().RemovePool(name);
 }