コード例 #1
0
        public GameObject Allocate(string poolName)
        {
            GameObjectPool cell = null;

            if (!m_PoolMap.TryGetValue(poolName, out cell))
            {
                Log.e("Allocate Not Find Pool:" + poolName);
                return(null);
            }

            return(cell.Allocate());
        }
コード例 #2
0
ファイル: FloatMessagePanel.cs プロジェクト: moto2002/Hunter
        private void ShowMsg(FloatMsg msgVo, bool check = true)
        {
            if (!m_IsInit)
            {
                InitFloatMessage();
            }

            if (check)
            {
                if (!CheckIsShowAble())
                {
                    m_MsgList.Push(msgVo);
                    return;
                }
            }

            GameObject obj = m_GameObjectPool.Allocate();

            if (obj)
            {
                obj.SetActive(true);
                ++m_AnimItemCount;
                FloatMessageItem item = obj.GetComponentInChildren <FloatMessageItem>();

                item.SetFloatMsg(msgVo);

                obj.transform.SetParent(m_Root, true);

                obj.transform.localPosition = m_StartPos;

                var image = obj.GetComponent <Image>();
                var text  = obj.GetComponentInChildren <Text>();
                text.color  = m_InitColor;
                image.color = m_InitColor;
                text.DOColor(new Color(m_InitColor.r, m_InitColor.g, m_InitColor.b, 0f), m_AnimTime)
                //.SetDelay(m_AnimTime)
                .OnComplete(() =>
                {
                    m_GameObjectPool.Recycle(obj);
                    --m_AnimItemCount;
                });
                image.DOColor(new Color(m_InitColor.r, m_InitColor.g, m_InitColor.b, 0f), m_AnimTime)
                ;
                // .SetDelay(m_AnimTime);
                obj.transform.DOLocalMove(m_EndPos, m_AnimTime).SetEase(Ease.Linear);
                m_LastSendTime = Time.realtimeSinceStartup;
            }
        }