示例#1
0
        void OnDisable()
        {
            window = null;
            if (aData != null && saveChanges)
            {
                AMTakeData take          = aData.currentTake;
                bool       saveNumFrames = true;

                string label = take.name + ": Modify Settings";
                AMTimeline.RegisterTakesUndo(aData, label, true);
                take = aData.currentTake;

                if (saveNumFrames)
                {
                    Undo.RegisterCompleteObjectUndo(AnimatorDataEdit.GetKeysAndTracks(take), label);

                    // save end frame padding
                    take.endFramePadding = endFramePadding;
                }
                // save frameRate
                take.frameRate = frameRate;

                //save other data
                take.numLoop         = loopCount;
                take.loopMode        = loopMode;
                take.loopBackToFrame = loopBackFrameCheck ? Mathf.Clamp(loopBackFrame, 1, totalFrames) : 0;

                EditorWindow.GetWindow(typeof(AMTimeline)).Repaint();
            }
        }
        void OnEnable()
        {
            aData = new AnimatorDataEdit(target as AnimatorData);
            GenerateTakeLabels();

            mMissingsFoldout = true;
        }
示例#3
0
        void loadAnimatorData()
        {
            if (AMTimeline.window)
            {
                __aData = AMTimeline.window.aData;

                if (aData == null)
                {
                    return;
                }
                if (aData.currentTake == null)
                {
                    return;
                }

                AMTakeData take = aData.currentTake;
                endFramePadding    = take.endFramePadding;
                frameRate          = take.frameRate;
                loopCount          = take.numLoop;
                loopMode           = take.loopMode;
                loopBackFrame      = take.loopBackToFrame;
                loopBackFrameCheck = loopBackFrame > 0;
                totalFrames        = take.totalFrames;
            }
        }
示例#4
0
        static void DrawGizmos(AnimatorData aData, GizmoType gizmoType)
        {
            //check if it's the one opened
            if (AMTimeline.window != null && AMTimeline.window.aData != null && AMTimeline.window.aData.IsDataMatch(aData))
            {
                AnimatorDataEdit eData = AMTimeline.AnimEdit(aData);

                List <AMTakeData> _t = eData.takes;

                if (_t == null || _t.Count == 0)
                {
                    return;
                }
                if (eData.currentTakeInd < 0)
                {
                    eData.currentTakeInd = 0;
                }
                else if (eData.currentTakeInd >= _t.Count)
                {
                    eData.currentTakeInd = _t.Count - 1;
                }

                _t[eData.currentTakeInd].drawGizmos(eData.target, AnimatorTimeline.e_gizmoSize, Application.isPlaying);
            }
        }
示例#5
0
 void loadAnimatorData()
 {
     if (AMTimeline.window != null)
     {
         aData = AMTimeline.window.aData;
     }
 }
示例#6
0
        public void reloadAnimatorData()
        {
            aData = null;
            loadAnimatorData();
            bool shouldClose = true;

            if (aData != null)
            {
                AMTakeData take = aData.currentTake;
                // update references for track and key
                foreach (AMTrack _track in take.trackValues)
                {
                    if (track == _track)
                    {
                        track = _track;
                        foreach (AMKey _key in track.keys)
                        {
                            if (key == _key)
                            {
                                key         = _key;
                                shouldClose = false;
                            }
                        }
                    }
                }
            }
            if (shouldClose)
            {
                this.Close();
            }
        }
示例#7
0
 void OnDisable()
 {
     window  = null;
     justSet = false;
     key     = null;
     track   = null;
     aData   = null;
 }
示例#8
0
 void loadAnimatorData()
 {
     if (AMTimeline.window != null)
     {
         __aData = AMTimeline.window.aData;
         if (__aData != null)
         {
             exportTakeIndex = __aData.currentTakeInd;
         }
     }
 }
示例#9
0
 public void MergeWith(AnimatorDataEdit _aData)
 {
     if (meta == null && _aData.meta == null)
     {
         foreach (AMTakeData take in _aData.takes)
         {
             takes.Add(take);
             MakeTakeNameUnique(take);
         }
     }
 }
示例#10
0
 void loadAnimatorData()
 {
     if (AMTimeline.window)
     {
         mData = AMTimeline.window.aData;
     }
     else
     {
         mData = null;
     }
 }
示例#11
0
 void loadAnimatorData()
 {
     if (AMTimeline.window)
     {
         aData        = AMTimeline.window.aData;
         dependencies = aData.GetDependencies(take);
     }
     else
     {
         this.Close();
     }
 }
示例#12
0
 void loadAnimatorData()
 {
     if (AMTimeline.window)
     {
         __aData = AMTimeline.window.aData;
         if (track)
         {
             _go = track.GetTarget(__aData.target) as GameObject;
             // refresh
             updateComponentArray();
         }
     }
 }
示例#13
0
        bool saveSelectedItemsToScene()
        {
            string saveScenePath = UnityEditor.EditorUtility.SaveFilePanel("Export Take", "Assets/", (take != null ? take.name : "All_Takes"), "unity");

            if (saveScenePath == "")
            {
                return(false);
            }
            // delete unselected GameObjects
            foreach (GameObject go in gameObjs)
            {
                if (!go)
                {
                    continue;
                }
                AnimatorData dat = go.GetComponent <AnimatorData>();
                if (dat)      //...
                {
                    if (take != null)
                    {
                        AnimatorDataEdit datEdit = new AnimatorDataEdit(dat);
                        datEdit.DeleteAllTakesExcept(take);
                    }
                    continue;
                }
                int index = gameObjs.IndexOf(go);
                if (gameObjsSelected[index] != null && (bool)!gameObjsSelected[index])
                {
                    DestroyImmediate(go);
                }
            }
            // save with changes
            EditorSceneManager.SaveScene(EditorSceneManager.GetActiveScene(), saveScenePath, true);
            // restore scene
            EditorSceneManager.OpenScene(saveScenePath);
            // refresh project directory
            AssetDatabase.Refresh();
            return(true);
        }
示例#14
0
 public void reloadAnimatorData()
 {
     aData = null;
     loadAnimatorData();
 }
示例#15
0
        void saveChanges()
        {
            if (!AMTimeline.window)
            {
                return;
            }
            AnimatorDataEdit aData = AMTimeline.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
            AMTimeline.resetIndexMethodInfo();
            AMTimeline.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();
        }
示例#16
0
        void OnGUI()
        {
        #if UNITY_5
            titleContent = new GUIContent("Ease: " + (oData.time_numbering ? AMTimeline.frameToTime(key.frame, (float)aData.currentTake.frameRate) + " s" : key.frame.ToString()));
        #else
            title = "Ease: " + (oData.time_numbering ? AMTimeline.frameToTime(key.frame, (float)aData.currentTake.frameRate) + " s" : key.frame.ToString());
        #endif
            AMTimeline.loadSkin(ref skin, ref cachedSkinName, position);
            bool updateEasingCurve = false;

            GUIStyle styleBox = new GUIStyle(GUI.skin.button);
            styleBox.normal = GUI.skin.button.active;
            styleBox.hover  = styleBox.normal;
            styleBox.border = GUI.skin.button.border;
            GUILayout.BeginArea(new Rect(5f, 5f, position.width - 10f, position.height - 10f));
            GUILayout.BeginHorizontal();
            if (GUILayout.Button("", styleBox, GUILayout.Width(500f), GUILayout.Height(100f)))
            {
                selectedSpeedIndex = (selectedSpeedIndex + 1) % speedValues.Length;
                percent            = waitPercent * -1f;
            }

            GUILayout.EndHorizontal();

            GUILayout.Space(5f);
            GUILayout.BeginHorizontal();
            int  prevCategory         = category;
            bool updatedSelectedIndex = false;
            if (setCategory(GUILayout.SelectionGrid(category, categories, (position.width >= 715f ? 12 : 6), GUILayout.Width(position.width - 16f))))
            {
                selectedIndex = getSelectedEaseIndex(prevCategory, selectedIndex);
                selectedIndex = getCategoryIndexForEase(selectedIndex);
                if (selectedIndex < 1)
                {
                    selectedIndex        = 1;
                    percent              = waitPercent * -1f;
                    updatedSelectedIndex = true;
                }
            }
            GUILayout.EndHorizontal();
            GUILayout.Space(5f);

            GUILayout.BeginVertical(GUILayout.Height(233f));
            if (updatedSelectedIndex || setSelectedIndex(GUILayout.SelectionGrid(selectedIndex, easeTypesFiltered[category].ToArray(), 3)))
            {
                percent           = waitPercent * -1f;
                updateEasingCurve = true;
                if (getSelectedEaseName(category, selectedIndex) == "Custom")
                {
                    isCustomEase = true;
                    if (key.customEase.Count > 0)
                    {
                        curve = key.getCustomEaseCurve();
                    }
                    else
                    {
                        setEasingCurve();
                    }
                }
                else
                {
                    isCustomEase = false;
                }
            }
            GUILayout.EndVertical();
            GUILayout.Space(5f);
            GUILayout.BeginHorizontal();
            if (GUILayout.Button("Apply"))
            {
                int  nease             = AMTimeline.GetEaseIndex(getSelectedEaseIndex(category, selectedIndex));
                bool shouldUpdateCache = false;
                if (isCustomEase)
                {
                    key.setCustomEase(curve);
                    shouldUpdateCache = true;
                }
                if (key.easeType != nease)
                {
                    shouldUpdateCache = true;
                }
                if (shouldUpdateCache)
                {
                    AnimatorDataEdit.RecordUndoTrackAndKeys(track, false, "Change Ease");
                    key.setEaseType(nease);
                    // update cache when modifying varaibles
                    track.updateCache(aData.target);
                    // preview new position
                    aData.currentTake.previewFrame(aData.target, aData.currentTake.selectedFrame);
                }
                this.Close();
            }
            if (GUILayout.Button("Cancel"))
            {
                this.Close();
            }
            GUILayout.EndHorizontal();
            GUILayout.EndArea();

            // orb texture
            GUI.DrawTexture(new Rect(x_pos, 15f, 80f, 80f), tex_orb);
            // speed label
            GUIStyle styleLabelRight = new GUIStyle(GUI.skin.label);
            styleLabelRight.alignment        = TextAnchor.MiddleRight;
            styleLabelRight.normal.textColor = Color.white;
            EditorGUI.DropShadowLabel(new Rect(475f, 5f, 25f, 25f), speedNames[selectedSpeedIndex], styleLabelRight);
            // draw border
            GUI.color = GUI.skin.window.normal.textColor;
            GUI.DrawTexture(new Rect(0f, 0f, 7f, 110f), EditorGUIUtility.whiteTexture);
            GUI.DrawTexture(new Rect(position.width - 209f, 0f, 208f, 110f), EditorGUIUtility.whiteTexture);
            GUI.color = Color.white;

            // curve field
            if (updateEasingCurve)
            {
                setEasingCurve();
            }
            else if (!isCustomEase && didChangeCurve())
            {
                isCustomEase  = true;
                selectedIndex = getCategoryIndexForEaseName("Custom");
                if (selectedIndex < 0)
                {
                    category      = 0;
                    selectedIndex = getCategoryIndexForEaseName("Custom");
                }
            }
            curve = EditorGUI.CurveField(new Rect(500f, 5f, 208f, 100f), curve);
        }