Beispiel #1
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;
    }