Пример #1
0
        private static void onFinish(ActionSequence seq)
        {
            seq.IsFinshed   = true;
            seq.OnFinished -= onFinish;

            if (!reuse)
            {
                _allSeq.Remove(seq);
                Destroy(seq);
            }
        }
Пример #2
0
        public static ActionSequence Create()
        {
            if (_instance == null)
            {
                GameObject obj = new GameObject
                {
                    name = "ActionSequenceManager"
                };
                //obj.hideFlags = HideFlags.HideInHierarchy;
                _instance = obj.AddComponent <ActionSequenceManager>();
            }

            ActionSequence newSeq = null;

            if (reuse)
            {
                for (int i = 0; i < _allSeq.Count; i++)
                {
                    if (_allSeq[i].IsFinshed)
                    {
                        newSeq = _allSeq[i];
                        break;
                    }
                }
            }

            if (newSeq == null)
            {
                newSeq = _instance.gameObject.AddComponent <ActionSequence>();
                _allSeq.Add(newSeq);
            }

            newSeq.OnFinished += onFinish;
            newSeq.IsFinshed   = false;

            return(newSeq);
        }