Пример #1
0
        /// <summary>
        /// 刷新角色形象为当前Code,若刚才的形象不对,则施放旧的,创建新的,都是从Pool里操作,开销不大。重复设置相同Code无开销。
        /// 刷新前一定要设置好Code
        /// 可以设置大小哦,1是原大小
        /// </summary>
        public void Refresh(float scale)
        {
            if (_curShowCode != CharacterCode)
            {
                if (AnimationInfo)
                {
                    CharacterBAPool.Enqueue(_curShowCode, AnimationInfo.gameObject);
                }

                AnimationInfo = null;
                _curShowCode  = CharacterCode;
            }

            if (AnimationInfo == null)
            {
                var go = CharacterBAPool.Dequeue(CharacterCode);
                if (go != null)
                {
                    go.transform.parent = transform;
                    go.transform.ResetTransform();
                    go.transform.localScale = new Vector3(scale, scale, 1);
                    AnimationInfo           = go.GetComponent <CharacterAnimationInfo>();
                }
            }
        }
Пример #2
0
        void Awake()
        {
            Instance = this;

            for (int i = 0; i < CodeCharacterBAPoolList.Length; i++)
            {
                CodeCharacterBAPoolList[i] = new Queue <GameObject>();
            }
        }