void loadAnimatorData()
 {
     GameObject go = GameObject.Find ("AnimatorData");
     if(go) {
         aData = (AnimatorData) go.GetComponent ("AnimatorData");
         numFrames = aData.getCurrentTake().numFrames;
         frameRate = aData.getCurrentTake().frameRate;
     }
 }
Example #2
0
    void loadAnimatorData()
    {
        GameObject go = GameObject.Find("AnimatorData");

        if (go)
        {
            aData     = (AnimatorData)go.GetComponent("AnimatorData");
            numFrames = aData.getCurrentTake().numFrames;
            frameRate = aData.getCurrentTake().frameRate;
        }
    }
Example #3
0
 void loadAnimatorData()
 {
     if(AMTimeline.window) {
         __aData = AMTimeline.window.aData;
         numFrames = __aData.getCurrentTake().numFrames;
         frameRate = __aData.getCurrentTake().frameRate;
         loopCount = __aData.getCurrentTake().numLoop;
         loopMode = __aData.getCurrentTake().loopMode;
         loopBackFrame = __aData.getCurrentTake().loopBackToFrame;
     }
 }
Example #4
0
    public void reloadAnimatorData()
    {
        aData = null;
        loadAnimatorData();
        AMTake take = aData.getCurrentTake();
        // update references for track and key
        bool shouldClose = true;

        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();
        }
    }
Example #5
0
    void loadAnimatorData()
    {
        aData = AMTimeline.GetAnimatorData();
        if (aData != null)
        {
            numFrames = aData.getCurrentTake().numFrames;
            frameRate = aData.getCurrentTake().frameRate;
        }

        //GameObject go = GameObject.Find ("AnimatorData");
        //if(go) {
        //    aData = (AnimatorData) go.GetComponent<AnimatorData>();
        //    numFrames = aData.getCurrentTake().numFrames;
        //    frameRate = aData.getCurrentTake().frameRate;
        //}
    }
Example #6
0
    void OnEnable()
    {
        window       = this;
        this.title   = "Options";
        this.minSize = new Vector2(545f, 365f);
        this.maxSize = new Vector2(1000f, this.minSize.y);

        loadAnimatorData();
        oData = AMOptionsFile.loadFile();
        // setup skin popup
        skinIndex = 0;
        for (int i = 1; i < skin_ids.Length; i++)
        {
            if (skin_ids[i] == oData.skin)
            {
                skinIndex = i;
                break;
            }
        }

        if (aData)
        {
            exportTakeIndex = aData.getTakeIndex(aData.getCurrentTake());
        }
    }
Example #7
0
    void OnDisable()
    {
        window = null;
        if ((aData) && saveChanges)
        {
            AMUtil.regUndoSelectedTake(aData, "Modify Settings");
            bool saveNumFrames = true;
            if ((numFrames < aData.getCurrentTake().numFrames) && (aData.getCurrentTake().hasKeyAfter(numFrames)))
            {
                if (!EditorUtility.DisplayDialog("Data Will Be Lost", "You will lose some keys beyond frame " + numFrames + " if you continue.", "Continue Anway", "Cancel"))
                {
                    saveNumFrames = false;
                }
            }
            if (saveNumFrames)
            {
                // save numFrames
                aData.getCurrentTake().numFrames = numFrames;
                aData.getCurrentTake().deleteKeysAfter(numFrames);

                // save data
                foreach (AMTrack track in aData.getCurrentTake().trackValues)
                {
                    EditorUtility.SetDirty(track);
                }
            }
            // save frameRate
            aData.getCurrentTake().frameRate = frameRate;
            EditorWindow.GetWindow(typeof(AMTimeline)).Repaint();
            // save data
            EditorUtility.SetDirty(aData);
        }
    }
Example #8
0
    void loadAnimatorData()
    {
        GameObject go = GameObject.Find("AnimatorData");

        if (go)
        {
            aData = (AnimatorData)go.GetComponent("AnimatorData");
            if (aData)
            {
                if (aData.playOnStart != null)
                {
                    playOnStartIndex = aData.getTakeIndex(aData.playOnStart) + 1;
                }
                exportTakeIndex = aData.getTakeIndex(aData.getCurrentTake());
            }
        }
    }
Example #9
0
        public static void regUndoSelectedTake(AnimatorData data, string name)
        {
#if UNITY_EDITOR
            if (!EditorApplication.isPlaying)
            {
                if (data.currentTake < 0)
                {
                    return;
                }
                var take = data.getCurrentTake();
                if (take != null)
                {
                    AMUtil.recordObject(take, name);
                }
            }
#endif
        }
Example #10
0
    void loadAnimatorData()
    {
        aData = AMTimeline.GetAnimatorData();
        if (aData)
        {
            if (aData.playOnStart != null)
            {
                playOnStartIndex = aData.getTakeIndex(aData.playOnStart) + 1;
            }
            exportTakeIndex = aData.getTakeIndex(aData.getCurrentTake());
        }

        //GameObject go = GameObject.Find ("AnimatorData");
        //if(go) {
        //    aData = (AnimatorData) go.GetComponent<AnimatorData>();
        //    if(aData) {
        //        if(aData.playOnStart != null) playOnStartIndex = aData.getTakeIndex(aData.playOnStart) + 1;
        //        exportTakeIndex = aData.getTakeIndex(aData.getCurrentTake());
        //    }
        //}
    }
Example #11
0
    void OnGUI()
    {
        AMTimeline.loadSkin(oData, ref skin, ref cachedSkinName, position);
        GUIStyle textStyle = new GUIStyle(GUI.skin.label);

        textStyle.wordWrap  = false;
        textStyle.alignment = TextAnchor.UpperLeft;
        textStyle.padding   = new RectOffset(0, 0, 10, 0);
        GUIStyle styleLabelCentered = new GUIStyle(GUI.skin.label);

        styleLabelCentered.alignment = TextAnchor.MiddleCenter;
        if (!aData)
        {
            AMTimeline.MessageBox("Animator requires an AnimatorData component in your scene. Launch Animator to add the component.", AMTimeline.MessageBoxType.Warning);
            return;
        }
        if (!oData)
        {
            oData = AMOptionsFile.loadFile();
        }
        #region drag logic
        Event e = Event.current;
        currentMousePosition = e.mousePosition;
        Rect rectWindow = new Rect(0f, 0f, position.width, position.height);
        mouseOverElement = (int)ElementType.None;
        //bool wasDragging = false;
        if (e.type == EventType.mouseDrag && EditorWindow.mouseOverWindow == this)
        {
            isDragging = true;
        }
        else if (e.type == EventType.mouseUp || /*EditorWindow.mouseOverWindow!=this*/ Event.current.rawType == EventType.MouseUp /*|| e.mousePosition.y < 0f*/)
        {
            if (isDragging)
            {
                //wasDragging = true;
                isDragging = false;
            }
        }
        // set cursor
        if (dragType == (int)DragType.ResizeInspector)
        {
            EditorGUIUtility.AddCursorRect(rectWindow, MouseCursor.ResizeHorizontal);
        }
        #endregion
        #region resize inspector
        if (dragType == (int)DragType.ResizeInspector)
        {
            width_inspector_open = start_width_inspector_open + (startScrubMousePosition.x - e.mousePosition.x);
        }
        width_inspector_open = Mathf.Clamp(width_inspector_open, width_inspector_open_min, position.width - width_code_min);
        #endregion
        GUILayout.BeginHorizontal();
        #region code vertical
        GUILayout.BeginVertical(GUILayout.Height(position.height));
        GUILayout.Space(3f);
        if (aData.setCodeLanguage(GUILayout.SelectionGrid(aData.codeLanguage, selStrings, 2 /*,styleSelGrid*/)))
        {
            // save data
            EditorUtility.SetDirty(aData);
            refreshCode();
        }
        GUILayout.Space(3f);
        // set scrollview background
        GUIStyle styleScrollView = new GUIStyle(GUI.skin.scrollView);
        styleScrollView.normal.background = GUI.skin.GetStyle("GroupElementBG").onNormal.background;
        scrollView = EditorGUILayout.BeginScrollView(scrollView, false, false, GUI.skin.horizontalScrollbar, GUI.skin.verticalScrollbar, styleScrollView);
        Vector2 textSize = textStyle.CalcSize(new GUIContent(codeCache));
        GUILayout.BeginHorizontal();
        GUILayout.Space(10f);
        EditorGUILayout.SelectableLabel(codeCache, textStyle, GUILayout.ExpandHeight(true), GUILayout.ExpandWidth(true), GUILayout.MinWidth(textSize.x + 30f), GUILayout.MinHeight(textSize.y + 30f));
        GUILayout.EndHorizontal();
        EditorGUILayout.EndScrollView();
        GUILayout.Space(3f);
        GUILayout.BeginHorizontal();
        // refresh button
        if (shouldRefresh)
        {
            GUI.color = Color.green;
        }
        if (GUILayout.Button("" /*,styleButton*/))
        {
            refreshCode();
        }
        GUI.color = Color.white;
        GUI.Label(GUILayoutUtility.GetLastRect(), "Refresh", styleLabelCentered);
        // copy to clipboard button
        if (GUILayout.Button("Copy to Clipboard"))
        {
            ClipboardHelper.clipBoard  = codeCache;
            GUIUtility.keyboardControl = 0;
            GUIUtility.hotControl      = 0;
        }
        GUILayout.EndHorizontal();
        GUILayout.Space(3f);
        GUILayout.EndVertical();
        #endregion
        #region track list vertical
        GUILayout.BeginHorizontal(GUILayout.Width((isInspectorOpen ? width_inspector_open : width_inspector_closed)));
        //if(GUILayout.Button("O/C",GUILayout.Width(width_inspector_closed),GUILayout.Height(position.height))) {
        //isInspectorOpen = !isInspectorOpen;
        //}
        // properties button
        GUILayout.BeginVertical(GUILayout.Width(width_inspector_closed));
        GUILayout.Space(width_inspector_closed);
        Rect rectPropertiesButton = new Rect(position.width - (isInspectorOpen ? width_inspector_open : width_inspector_closed) - 1f, 0f, width_inspector_closed, position.height - 28f);
        if (GUI.Button(rectPropertiesButton, "", "label"))
        {
            isInspectorOpen = !isInspectorOpen;
        }
        GUI.color = AMTimeline.getSkinTextureStyleState("properties_bg").textColor;
        GUI.DrawTexture(rectPropertiesButton, AMTimeline.getSkinTextureStyleState("properties_bg").background);
        GUI.color = Color.white;
        GUI.DrawTexture(new Rect(rectPropertiesButton.x + 8f + (isInspectorOpen ? 1f : 0f), 12f, 22f, 19f), (isInspectorOpen ? texRightArrow : texLeftArrow));
        if (!isInspectorOpen)
        {
            int numSelected = 0;
            foreach (var pair in dictTracks)
            {
                if (pair.Value == true)
                {
                    numSelected++;
                }
            }
            if (numSelected < dictTracks.Count)
            {
                GUI.color = Color.red;
            }
            GUI.Label(new Rect(rectPropertiesButton.x, rectPropertiesButton.y + rectPropertiesButton.height, rectPropertiesButton.width, 28f), numSelected + "/" + dictTracks.Count, styleLabelCentered);
            GUI.color = Color.white;
        }
        GUILayout.EndVertical();
        if (isInspectorOpen)
        {
            GUILayout.BeginVertical(GUILayout.Width(width_inspector_open - width_inspector_closed));
            GUILayout.Space(inspector_space);
            GUILayout.Label("Track Selection");
            GUILayout.Space(inspector_space);
            GUILayout.BeginHorizontal();
            //GUILayout.Space(inspector_space);
            scrollPos = EditorGUILayout.BeginScrollView(scrollPos /*,styleScrollView*/);
            for (int i = 0; i < aData.getCurrentTake().rootGroup.elements.Count; i++)
            {
                int id = aData.getCurrentTake().rootGroup.elements[i];
                //float height_group_elements = 0f;
                showGroupElement(id, 0);
            }
            GUILayout.EndScrollView();
            GUILayout.Space(inspector_space);
            GUILayout.EndHorizontal();
            // buttons
            GUILayout.Space(inspector_space);
            GUILayout.BeginHorizontal();
            Rect rectResizeInspector = new Rect(rectPropertiesButton.x, position.height - 15f - 8f, 15f, 15f);
            GUI.Button(rectResizeInspector, "", GUI.skin.GetStyle("ResizeTrackThumb"));
            EditorGUIUtility.AddCursorRect(rectResizeInspector, MouseCursor.ResizeHorizontal);
            if (rectResizeInspector.Contains(e.mousePosition) && mouseOverElement == (int)ElementType.None)
            {
                mouseOverElement = (int)ElementType.ResizeInspector;
            }

            if (GUILayout.Button("All", GUILayout.Width(42f)))
            {
                foreach (var key in dictTracks.Keys.ToList())
                {
                    dictTracks[key] = true;
                }
                refreshCode();
            }
            if (GUILayout.Button("None", GUILayout.Width(42f)))
            {
                foreach (var key in dictTracks.Keys.ToList())
                {
                    dictTracks[key] = false;
                }
                refreshCode();
            }
            GUILayout.FlexibleSpace();
            if (GUILayout.Button("JSON...", GUILayout.Width(58f)))
            {
                // export json
                exportJSON();
            }
            GUILayout.EndHorizontal();
            GUILayout.Space(inspector_space);
            GUILayout.EndVertical();
        }
        GUILayout.EndHorizontal();
        #endregion
        GUILayout.EndHorizontal();
    }
Example #12
0
    void OnGUI()
    {
        this.title = "Ease: " + (oData.time_numbering ? AMTimeline.frameToTime(key.frame, (float)aData.getCurrentTake().frameRate) + " s" : key.frame.ToString());
        AMTimeline.loadSkin(oData, 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 < 0)
            {
                selectedIndex        = 0;
                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"))
        {
            bool shouldUpdateCache = false;
            if (isCustomEase)
            {
                key.setCustomEase(curve);
                shouldUpdateCache = true;
            }
            if (key.setEaseType(getSelectedEaseIndex(category, selectedIndex)))
            {
                shouldUpdateCache = true;
            }
            if (shouldUpdateCache)
            {
                // update cache when modifying varaibles
                track.updateCache();
                AMCodeView.refresh();
                // preview new position
                aData.getCurrentTake().previewFrame(aData.getCurrentTake().selectedFrame);
                // save data
                EditorUtility.SetDirty(aData);
            }
            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, Color.blue, new Rect(0f, -0.5f, 1f, 2.0f));
    }
 public void reloadAnimatorData()
 {
     aData = null;
     loadAnimatorData();
     AMTake take = aData.getCurrentTake();
     // update references for track and key
     bool shouldClose = true;
     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();
 }
Example #14
0
 void loadAnimatorData()
 {
     GameObject go = GameObject.Find ("AnimatorData");
     if(go) {
         aData = (AnimatorData) go.GetComponent ("AnimatorData");
         if(aData) {
             if(aData.playOnStart != null) playOnStartIndex = aData.getTakeIndex(aData.playOnStart) + 1;
             exportTakeIndex = aData.getTakeIndex(aData.getCurrentTake());
         }
     }
 }
Example #15
0
    public static bool showEasePicker(AMTrack track, AMKey key, AnimatorData aData, float x = -1f, float y = -1f, float width = -1f)
    {
        bool didUpdate = false;
        if(x >= 0f && y >= 0f && width >= 0f) {
            width--;
            float height = 22f;
            Rect rectLabel = new Rect(x, y - 1f, 40f, height);
            GUI.Label(rectLabel, "Ease");
            Rect rectPopup = new Rect(rectLabel.x + rectLabel.width + 2f, y + 3f, width - rectLabel.width - width_button_delete - 3f, height);

            int nease = EditorGUI.Popup(rectPopup, key.easeType, easeTypeNames);
            if(key.easeType != nease) {
                recordUndoTrackAndKeys(track, false, "Change Ease");
                key.setEaseType(nease);
                // update cache when modifying varaibles
                track.updateCache();
                AMCodeView.refresh();
                // preview new position
                aData.getCurrentTake().previewFrame(aData.getCurrentTake().selectedFrame);
                // save data
                EditorUtility.SetDirty(track);
                setDirtyKeys(track);
                // refresh component
                didUpdate = true;
                // refresh values
                AMEasePicker.refreshValues();
            }

            Rect rectButton = new Rect(width - width_button_delete + 1f, y, width_button_delete, width_button_delete);
            if(GUI.Button(rectButton, getSkinTextureStyleState("popup").background, GUI.skin.GetStyle("ButtonImage"))) {
                AMEasePicker.setValues(/*aData,*/key, track);
                EditorWindow.GetWindow(typeof(AMEasePicker));
            }

            //display specific variable for certain tweens
            //TODO: only show this for specific tweens
            if(!key.hasCustomEase()) {
                y += rectButton.height + 4;
                Rect rectAmp = new Rect(x, y, 200f, height);
                key.amplitude = EditorGUI.FloatField(rectAmp, "Amplitude", key.amplitude);

                y += rectAmp.height + 4;
                Rect rectPer = new Rect(x, y, 200f, height);
                key.period = EditorGUI.FloatField(rectPer, "Period", key.period);
            }
        }
        else {
            GUILayout.BeginHorizontal();
            GUILayout.BeginVertical();
            GUILayout.Space(1f);
            GUILayout.Label("Ease");
            GUILayout.EndVertical();
            GUILayout.BeginVertical();
            GUILayout.Space(3f);
            int nease = EditorGUILayout.Popup(key.easeType, easeTypeNames);
            if(key.easeType != nease) {
                recordUndoTrackAndKeys(track, false, "Change Ease");
                key.setEaseType(nease);
                // update cache when modifying varaibles
                track.updateCache();
                AMCodeView.refresh();
                // preview new position
                aData.getCurrentTake().previewFrame(aData.getCurrentTake().selectedFrame);
                // save data
                EditorUtility.SetDirty(track);
                setDirtyKeys(track);
                // refresh component
                didUpdate = true;
                // refresh values
                AMEasePicker.refreshValues();
            }
            GUILayout.EndVertical();
            if(GUILayout.Button(getSkinTextureStyleState("popup").background, GUI.skin.GetStyle("ButtonImage"), GUILayout.Width(width_button_delete), GUILayout.Height(width_button_delete))) {
                AMEasePicker.setValues(/*aData,*/key, track);
                EditorWindow.GetWindow(typeof(AMEasePicker));
            }
            GUILayout.Space(1f);
            GUILayout.EndHorizontal();

            //display specific variable for certain tweens
            //TODO: only show this for specific tweens
            if(!key.hasCustomEase()) {
                key.amplitude = EditorGUILayout.FloatField("Amplitude", key.amplitude);

                key.period = EditorGUILayout.FloatField("Period", key.period);
            }
        }
        return didUpdate;
    }
Example #16
0
 void loadAnimatorData()
 {
     if(AMTimeline.window != null) {
         __aData = AMTimeline.window.aData;
         if(__aData) {
             if(__aData.playOnStart != null) playOnStartIndex = __aData.getTakeIndex(__aData.playOnStart) + 1;
             exportTakeIndex = __aData.getTakeIndex(__aData.getCurrentTake());
         }
     }
 }