Esempio n. 1
0
        void saveChanges()
        {
            if (!TimelineWindow.window)
            {
                return;
            }
            AnimateEditControl aData = TimelineWindow.window.aData;

            if (aData == null)
            {
                return;
            }

            List <GameObject> keepReferences    = new List <GameObject>();
            List <GameObject> replaceReferences = new List <GameObject>();

            for (int i = 0; i < newReference.Count; i++)
            {
                if (actions[i] == 0)
                {
                    continue;
                }
                if (newReference[i] == oldReference[i])
                {
                    continue;
                }
                if (!newReference[i] || !oldReference[i])
                {
                    continue;                                       // skip null values
                }
                else if (actions[i] == 1)
                {
                    keepReferences.Add(newReference[i]);
                    replaceReferences.Add(oldReference[i]);
                }
                else if (actions[i] == 2)
                {
                    keepReferences.Add(oldReference[i]);
                    replaceReferences.Add(newReference[i]);
                }
            }

            if (keepReferences.Count <= 0)
            {
                this.Close();
                return; // return if no changes made
            }
            //TODO: undo "Resolve Duplicates"
            // update references
            List <GameObject> lsFlagToKeep = aData.UpdateDependencies(keepReferences, replaceReferences);

            // reset event track method info
            TimelineWindow.resetIndexMethodInfo();
            TimelineWindow.shouldCheckDependencies = false;
            //aData.shouldCheckDependencies = false;
            // delete replaced references
            int count = 0;

            for (int i = 0; i < replaceReferences.Count; i++)
            {
                if (lsFlagToKeep.Contains(replaceReferences[i]))
                {
                    continue;
                }
                DestroyImmediate(replaceReferences[i]);
                replaceReferences.RemoveAt(i);
                count++;
                i--;
            }
            replaceReferences = new List <GameObject>();

            Debug.Log("Animator: Resolved Duplicate" + (count > 1 ? "s" : "") + ". Deleted " + count + " GameObject" + (count > 1 ? "s" : "") + ".");
            this.Close();
        }