Beispiel #1
0
        void OnEnable()
        {
            if (!texLoaded)
            {
                tex_orb   = AMEditorResource.LoadEditorTexture("am_orb");
                texLoaded = true;
            }

            window              = this;
            this.maxSize        = new Vector2(715f, 398f);
            this.minSize        = this.maxSize;
            this.wantsMouseMove = true;
            loadAnimatorData();
            oData = AMOptionsFile.loadFile();
            setupFilteredCategories();

            selectedIndex = getCategoryIndexForEase(AMTimeline.GetEaseTypeNameIndex(key.easeType));

            if (getSelectedEaseName(category, selectedIndex) == "Custom")
            {
                isCustomEase = true;
            }
            if (isCustomEase && key.customEase.Count > 0)
            {
                curve = key.getCustomEaseCurve();
            }
            else
            {
                setEasingCurve();
            }
        }
Beispiel #2
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();
            }
        }
Beispiel #3
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);
            }
        }
Beispiel #4
0
 public static void setValues(AMKey _key, AMTrack _track)
 {
     justSet = true;
     key     = _key;
     track   = _track;
     //aData = _aData;
     selectedIndex = AMTimeline.GetEaseTypeNameIndex(key.easeType);
 }
Beispiel #5
0
 void loadAnimatorData()
 {
     aData = AMTimeline.GetAnimatorData();
     //GameObject go = GameObject.Find ("AnimatorData");
     //if(go) {
     //    aData = (AnimatorData) go.GetComponent<AnimatorData>();
     //}
 }
Beispiel #6
0
    void OnGUI()
    {
        Event e = Event.current;

        AMTimeline.loadSkin(oData, ref skin, ref cachedSkinName, position);
        if (!aData)
        {
            AMTimeline.MessageBox("Animator requires an AnimatorData component in your scene. Launch Animator to add the component.", AMTimeline.MessageBoxType.Warning);
            return;
        }
        GUIStyle styleArea = new GUIStyle(GUI.skin.scrollView);

        styleArea.padding = new RectOffset(4, 4, 4, 4);
        GUILayout.BeginArea(new Rect(0f, 0f, position.width, position.height), styleArea);
        GUILayout.Label("Number of Frames");
        GUILayout.Space(2f);
        numFrames = EditorGUILayout.IntField(numFrames, GUI.skin.textField, GUILayout.Width(position.width - 10f - 12f));
        if (numFrames <= 0)
        {
            numFrames = 1;
        }
        GUILayout.Space(2f);
        GUILayout.Label("Frame Rate (Fps)");
        GUILayout.Space(2f);
        frameRate = EditorGUILayout.IntField(frameRate, GUI.skin.textField, GUILayout.Width(position.width - 10f - 12f));
        if (frameRate <= 0)
        {
            frameRate = 1;
        }
        GUILayout.Space(7f);
        GUILayout.BeginHorizontal();
        if (GUILayout.Button("Apply"))
        {
            saveChanges = true;
            this.Close();
        }
        if (GUILayout.Button("Cancel"))
        {
            saveChanges = false;
            this.Close();
        }
        GUILayout.EndHorizontal();
        GUILayout.EndArea();

        if (e.type == EventType.KeyDown && (e.keyCode == KeyCode.Return || e.keyCode == KeyCode.Escape))
        {
            saveChanges = (e.keyCode == KeyCode.Return);
            this.Close();
        }
    }
Beispiel #7
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;
        //}
    }
Beispiel #8
0
    void processSelectProperty(Component propertyComponent, FieldInfo fieldInfo, PropertyInfo propertyInfo, MethodInfo methodMegaMorphSetPercent = null)
    {
        if (!aData || !track)
        {
            this.Close();
        }

        bool changePropertyValue = true;

        if ((track.keys.Count > 0) && (!EditorUtility.DisplayDialog("Data Will Be Lost", "You will lose all of the keyframes on track '" + track.name + "' if you continue.", "Continue Anway", "Cancel")))
        {
            changePropertyValue = false;
        }
        if (changePropertyValue)
        {
            AMTimeline.registerUndo("Set Property");
            // delete keys
            if (track.keys.Count > 0)
            {
                track.deleteAllKeys();
                AMCodeView.refresh();
            }
            // set fieldinfo or propertyinfo
            if (fieldInfo != null)
            {
                track.setFieldInfo(fieldInfo);
            }
            else if (propertyInfo != null)
            {
                track.setPropertyInfo(propertyInfo);
            }
            // MegaMorph
            else if (methodMegaMorphSetPercent != null)
            {
                track.setMethodInfo(methodMegaMorphSetPercent, new string[] { "System.Int32", "System.Single" }, AMPropertyTrack.ValueType.MorphChannels);
            }
            // set component
            track.setComponent(propertyComponent);
            track.updateCache();
        }
        this.Close();
    }
Beispiel #9
0
        public void setEasingCurve()
        {
            string name = getSelectedEaseName(category, selectedIndex);

            if (name == "Custom")
            {
                if (curve.length <= 0)
                {
                    curve = getCurve(Ease.Linear);
                    this.Repaint();
                }
                return;
            }

            Ease ease = (Ease)AMTimeline.GetEaseIndex(getSelectedEaseIndex(category, selectedIndex));

            curve         = getCurve(ease);
            selectedCurve = getCurve(ease);
            this.Repaint();
        }
    void loadAnimatorData()
    {
        aData = AMTimeline.GetAnimatorData();
        if (aData != null)
        {
            dependencies = aData.getDependencies(take);
        }
        else
        {
            this.Close();
        }

        //GameObject go = GameObject.Find ("AnimatorData");
        //if(go) {
        //    aData = (AnimatorData) go.GetComponent<AnimatorData>();
        //    dependencies = aData.getDependencies(take);
        //} else {
        //    this.Close();
        //}
    }
    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());
        //    }
        //}
    }
Beispiel #12
0
    void loadAnimatorData()
    {
        aData = AMTimeline.GetAnimatorData();
        if (aData != null)
        {
            if (track)
            {
                _go = track.obj;
                // refresh
                updateComponentArray();
            }
        }

        //GameObject go = GameObject.Find ("AnimatorData");
        //if(go) {
        //    aData = (AnimatorData) go.GetComponent<AnimatorData>();
        //    if(track) {
        //        _go = track.obj;
        //        // refresh
        //        updateComponentArray();
        //    }
        //}
    }
Beispiel #13
0
        void Update()
        {
            percent += 0.003f * speedValues[selectedSpeedIndex];
            if (percent > 1f + waitPercent)
            {
                percent = waitPercent * -1f;
            }
            float x_pos_start = 50f;
            float x_pos_end   = position.width - 50f - 80f - 200f;

            if (percent <= 1f)
            {
                if (isCustomEase)
                {
                    x_pos = AMUtil.EaseCustom(x_pos_start, x_pos_end - x_pos_start, percent < 0f ? 0f : percent, curve);
                }
                else
                {
                    var ease = AMUtil.GetEasingFunction((Ease)AMTimeline.GetEaseIndex(getSelectedEaseIndex(category, selectedIndex)));
                    x_pos = x_pos_start + (x_pos_end - x_pos_start) * ease(percent < 0f ? 0f : percent, 1.0f, 0.0f, 0.0f);
                }
            }
            this.Repaint();
        }
Beispiel #14
0
        void showGameObject(int i, int level)
        {
            GUILayout.BeginHorizontal(GUILayout.Height(height_gameobject));
            if (gameObjsSelected[i] == null)
            {
                GUI.enabled = false;
                GUILayout.Toggle(true, "", GUILayout.Width(width_toggle));
            }
            else
            {
                gameObjsSelected[i] = GUILayout.Toggle((bool)gameObjsSelected[i], "", GUILayout.Width(width_toggle));
            }
            // indent
            GUILayout.Space(width_indent * level);

            if (gameObjsFoldout[i] != null)
            {
                GUI.enabled = true;
                // foldout
                GUILayout.BeginVertical();
                GUILayout.Space(height_label_offset - 1f);
                if (GUILayout.Button("", "label", GUILayout.Width(15f)))
                {
                    gameObjsFoldout[i] = !gameObjsFoldout[i];
                }
                GUI.DrawTexture(GUILayoutUtility.GetLastRect(), ((bool)gameObjsFoldout[i] ? GUI.skin.GetStyle("GroupElementFoldout").normal.background : GUI.skin.GetStyle("GroupElementFoldout").active.background));
                GUILayout.EndVertical();
                // toggle children
                //if(gameObjsSelected[i] != null) {
                if (gameObjsSelected[i] == null)
                {
                    GUI.enabled = false;
                }
                GUILayout.BeginVertical();
                GUILayout.Space(height_label_offset + 1f);
                if (GUILayout.Button("", GUILayout.Width(13f), GUILayout.Height(15f)))
                {
                    if (gameObjsSelected[i] != null)
                    {
                        gameObjsSelected[i] = !gameObjsSelected[i];
                        setAllChildrenSelection((bool)gameObjsSelected[i], i, gameObjsDepth[i]);
                    }
                }
                Rect rectSelectAllTexture = GUILayoutUtility.GetLastRect();
                GUILayout.EndVertical();

                rectSelectAllTexture.x     += 3f;
                rectSelectAllTexture.y     += 4f;
                rectSelectAllTexture.width  = 7f;
                rectSelectAllTexture.height = 8f;
                if (!GUI.enabled)
                {
                    GUI.color = new Color(GUI.color.r, GUI.color.g, GUI.color.b, 0.25f);
                }
                GUI.DrawTexture(rectSelectAllTexture, AMTimeline.getSkinTextureStyleState("select_all").background);
                GUI.color = Color.white;
                //}
            }
            else
            {
                GUILayout.Space(15f);
            }

            GUILayout.BeginVertical();
            GUILayout.Space(height_label_offset);
            if (gameObjsFoldout[i] != null)
            {
                GUILayout.Label(gameObjs[i].name);
            }
            else
            {
                GUILayout.Label(new GUIContent(gameObjs[i].name, EditorGUIUtility.ObjectContent(null, typeof(GameObject)).image), GUILayout.Height(19f));
            }
            GUILayout.EndVertical();
            GUILayout.FlexibleSpace();
            if (!GUI.enabled)
            {
                GUI.enabled = true;
            }
            GUILayout.EndHorizontal();
        }
Beispiel #15
0
        void OnGUI()
        {
            AMTimeline.loadSkin(ref skin, ref cachedSkinName, position);
            GUIStyle padding = new GUIStyle();

            padding.padding = new RectOffset(3, 3, 3, 3);
            GUILayout.BeginVertical(padding);
            // show list of items
            showItems();

            GUILayout.Space(3f);
            GUILayout.BeginHorizontal();
            if (GUILayout.Button("All", GUILayout.Width(50f)))
            {
                for (int i = 0; i < gameObjsSelected.Count; i++)
                {
                    if (gameObjsSelected[i] == false)
                    {
                        gameObjsSelected[i] = true;
                    }
                }
            }
            if (GUILayout.Button("None", GUILayout.Width(50f)))
            {
                for (int i = 0; i < gameObjsSelected.Count; i++)
                {
                    if (gameObjsSelected[i] == true)
                    {
                        gameObjsSelected[i] = false;
                    }
                }
            }
            GUILayout.FlexibleSpace();
            if (GUILayout.Button("Export...", GUILayout.Width(80f)))
            {
                bool shouldExit    = false;
                bool performExport = true;
                if (string.IsNullOrEmpty(EditorSceneManager.GetActiveScene().name))
                {
                    if (UnityEditor.EditorUtility.DisplayDialog("Save Current Scene", "The current scene must be saved before an export is performed.", "Save Current Scene", "Cancel"))
                    {
                        EditorSceneManager.SaveScene(EditorSceneManager.GetActiveScene());
                        UnityEditor.EditorUtility.DisplayDialog("Performing Export...", "The current scene has been saved. Now performing export.", "Continue");
                    }
                    else
                    {
                        performExport = false;
                    }
                }
                if (performExport)
                {
                    if (saveSelectedItemsToScene())
                    {
                        shouldExit = true;
                    }
                }
                if (shouldExit)
                {
                    this.Close();
                    GUIUtility.ExitGUI();
                }
            }

            GUILayout.EndHorizontal();
            GUILayout.EndVertical();
        }
Beispiel #16
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));
    }
Beispiel #17
0
        void OnGUI()
        {
            AMTimeline.loadSkin(ref skin, ref cachedSkinName, position);
            if (aData == null)
            {
                AMTimeline.MessageBox("Animator requires an AnimatorData component in your scene. Launch Animator to add the component.", AMTimeline.MessageBoxType.Warning);
                return;
            }

            //AMTake curTake = aData.getCurrentTake();

            GUIStyle styleArea = new GUIStyle(GUI.skin.scrollView);

            styleArea.padding = new RectOffset(4, 4, 4, 4);
            GUILayout.BeginArea(new Rect(0f, 0f, position.width, position.height), styleArea);
            //GUILayout.Label("Take: " + curTake.name + " of "+aData.gameObject.name + " "+curTake.GetHashCode());
            GUILayout.Label("Loop");
            GUILayout.Space(2f);
            GUILayout.BeginHorizontal(GUI.skin.box);
            EditorGUIUtility.labelWidth = 50f; EditorGUIUtility.fieldWidth = 100f;
            loopCount = EditorGUILayout.IntField("Count", loopCount);
            if (loopCount < 0)
            {
                loopCount = -1;
            }
            loopMode = (LoopType)EditorGUILayout.EnumPopup("Mode", loopMode);
            GUILayout.EndHorizontal();

            AMEditorUtil.ResetDisplayControls();

            GUILayout.Space(2f);
            //pausePreviousTake = EditorGUILayout.Toggle("Pause Prev. Take", pausePreviousTake);

            GUILayout.Space(4f);
            bool loopBackFrameEnabled = loopCount < 0;

            GUI.enabled = loopBackFrameEnabled;
            GUILayout.BeginHorizontal();
            loopBackFrameCheck = EditorGUILayout.Toggle(loopBackFrameCheck, GUILayout.Width(12f));
            GUI.enabled        = loopBackFrameEnabled && loopBackFrameCheck;
            loopBackFrame      = EditorGUILayout.IntSlider("Loop Back To Frame", loopBackFrame, 1, totalFrames);
            GUILayout.EndHorizontal();
            GUI.enabled = true;
            GUILayout.Space(6f);
            GUILayout.Label("End Frame Padding");
            GUILayout.Space(2f);
            GUI.enabled     = !loopBackFrameEnabled || !loopBackFrameCheck || loopBackFrame < 0;
            endFramePadding = EditorGUILayout.IntField(endFramePadding, GUI.skin.textField, GUILayout.Width(position.width - 10f - 12f));
            if (endFramePadding < 0)
            {
                endFramePadding = 0;
            }
            GUI.enabled = true;
            GUILayout.Space(2f);
            GUILayout.Label("Frame Rate (Fps)");
            GUILayout.Space(2f);
            frameRate = EditorGUILayout.IntField(frameRate, GUI.skin.textField, GUILayout.Width(position.width - 10f - 12f));
            if (frameRate <= 0)
            {
                frameRate = 1;
            }
            GUILayout.Space(7f);
            GUILayout.BeginHorizontal();
            if (GUILayout.Button("Apply"))
            {
                saveChanges = true;
                this.Close();
            }
            if (GUILayout.Button("Cancel"))
            {
                saveChanges = false;
                this.Close();
            }
            GUILayout.EndHorizontal();
            GUILayout.EndArea();
        }
Beispiel #18
0
    void OnDisable()
    {
        EditorApplication.playmodeStateChanged -= OnPlayMode;

        window = null;
        if(aData && aData.getCurrentTake() != null) {
            // stop audio if it's playing
            aData.getCurrentTake().stopAudio();

            // preview first frame
            aData.getCurrentTake().previewFrame(1f);

            aData = null;

            // reset property select track
            //aData.propertySelectTrack = null;
        }
    }
Beispiel #19
0
    void showGroup(int id, int group_lvl)
    {
        // show group
        //float group_x = width_subtrack_space*group_lvl;

        //Rect rectGroup = new Rect(group_x,track_y,width_track-group_x,height_group);
        if (!dictGroups.ContainsKey(id))
        {
            dictGroups.Add(id, true);
        }
        AMGroup grp = aData.getCurrentTake().getGroup(id);

        GUILayout.BeginHorizontal();
        GUILayout.Space(width_indent * (group_lvl));                    // indent
        // foldout
        GUILayout.BeginVertical(GUILayout.Width(15f));
        GUILayout.Space(height_label_offset - 1f);
        if (GUILayout.Button("", "label", GUILayout.Width(15f)))
        {
            dictGroups[id] = !dictGroups[id];
        }
        GUI.DrawTexture(GUILayoutUtility.GetLastRect(), (dictGroups[id] ? GUI.skin.GetStyle("GroupElementFoldout").normal.background : GUI.skin.GetStyle("GroupElementFoldout").active.background));
        GUILayout.EndVertical();
        // select children button
        if (hasTracks(grp))
        {
            GUILayout.BeginVertical(GUILayout.Width(13f));
            GUILayout.Space(height_label_offset + 1f);
            if (GUILayout.Button("", GUILayout.Width(13f), GUILayout.Height(15f)))
            {
                bool?newValue = null;
                toggleChildren(grp, ref newValue);
                refreshCode();

                /*if(gameObjsSelected[i] != null) {
                 *      gameObjsSelected[i] = !gameObjsSelected[i];
                 *      setAllChildrenSelection((bool)gameObjsSelected[i], i, gameObjsDepth[i]);
                 * }*/
            }
            Rect rectSelectAllTexture = GUILayoutUtility.GetLastRect();
            GUILayout.EndVertical();

            rectSelectAllTexture.x     += 3f;
            rectSelectAllTexture.y     += 4f;
            rectSelectAllTexture.width  = 7f;
            rectSelectAllTexture.height = 8f;
            if (!GUI.enabled)
            {
                GUI.color = new Color(GUI.color.r, GUI.color.g, GUI.color.b, 0.25f);
            }
            GUI.DrawTexture(rectSelectAllTexture, AMTimeline.getSkinTextureStyleState("select_all").background);
            GUI.color = Color.white;
        }
        GUILayout.BeginVertical();
        GUILayout.Space(height_label_offset);
        GUILayout.Label(grp.group_name);
        GUILayout.EndHorizontal();
        GUILayout.EndHorizontal();
        group_lvl++;            // increment group_lvl for sub-elements
        if (dictGroups[id])
        {
            for (int j = 0; j < grp.elements.Count; j++)
            {
                int _id = grp.elements[j];
                showGroupElement(_id, group_lvl);
            }
        }
    }
        public override void OnInspectorGUI()
        {
            AnimatorData anim = target as AnimatorData;

            GUILayout.BeginVertical();

            //meta
            AnimatorMeta curMeta = aData.meta;
            AnimatorMeta newMeta = EditorGUILayout.ObjectField(new GUIContent("Meta", "Use data from the reference AnimatorMeta. Note: All modifications to the animation will be saved to the Meta."), curMeta, typeof(AnimatorMeta), false) as AnimatorMeta;

            if (curMeta != newMeta)
            {
                bool doIt = true;
                if (curMeta == null)
                {
                    doIt = EditorUtility.DisplayDialog("Set Meta", "Setting the Meta will replace the current animation data, proceed?", "Yes", "No");
                }

                if (doIt)
                {
                    aData.RegisterUndo("Set Meta", true);
                    aData.MetaSet(newMeta, false);
                }
            }

            MetaCommand metaComm = MetaCommand.None;

            GUILayout.BeginHorizontal();
            GUILayout.FlexibleSpace();

            GUI.backgroundColor = Color.green;

            GUI.enabled = PrefabUtility.GetPrefabType(aData.gameObject) != PrefabType.Prefab && aData.metaCanSavePrefabInstance;
            if (GUILayout.Button("Save", GUILayout.Width(100f)))
            {
                metaComm = MetaCommand.Save;
            }

            GUI.enabled = true;
            if (GUILayout.Button("Save As...", GUILayout.Width(100f)))
            {
                metaComm = MetaCommand.SaveAs;
            }

            GUILayout.FlexibleSpace();
            GUILayout.EndHorizontal();

            GUILayout.BeginHorizontal();
            GUILayout.FlexibleSpace();

            GUI.backgroundColor = Color.red;

            GUI.enabled = PrefabUtility.GetPrefabType(aData.gameObject) != PrefabType.Prefab && aData.metaCanSavePrefabInstance;
            if (GUILayout.Button("Revert", GUILayout.Width(100f)))
            {
                metaComm = MetaCommand.Revert;
            }

            GUI.backgroundColor = Color.white;

            GUI.enabled = PrefabUtility.GetPrefabType(aData.gameObject) != PrefabType.Prefab && aData.meta;
            if (GUILayout.Button(new GUIContent("Break", "This will copy all data from AnimatorMeta to this AnimatorData, and then removes the reference to AnimatorMeta."), GUILayout.Width(100f)))
            {
                metaComm = MetaCommand.Instantiate;
            }
            GUI.enabled = true;

            GUILayout.FlexibleSpace();
            GUILayout.EndHorizontal();

            AMEditorUtil.DrawSeparator();
            //

            List <AMTakeData> takes        = aData.takes;
            string            playTakeName = aData.defaultTakeName;
            int playTakeInd = 0;

            if (!string.IsNullOrEmpty(playTakeName))
            {
                for (int i = 0; i < takes.Count; i++)
                {
                    if (takes[i].name == aData.defaultTakeName)
                    {
                        playTakeInd = i + 1;
                        break;
                    }
                }
            }

            GenerateTakeLabels();
            int newPlayTakeInd = EditorGUILayout.IntPopup("Play On Start", playTakeInd, mTakeLabels, null);

            if (newPlayTakeInd != playTakeInd)
            {
                aData.RegisterUndo("Set Play On Start", false);
                aData.defaultTakeName = newPlayTakeInd <= 0 ? "" : takes[newPlayTakeInd - 1].name;
            }

            bool isglobal = GUILayout.Toggle(aData.isGlobal, "Global");

            if (aData.isGlobal != isglobal)
            {
                aData.RegisterUndo("Set Global", false);
                aData.isGlobal = isglobal;
                if (isglobal)
                {
                    //uncheck isGlobal to any other animator data on scene
                    AnimatorData[] anims = FindObjectsOfType <AnimatorData>();
                    for (int i = 0; i < anims.Length; i++)
                    {
                        if (!aData.IsDataMatch(anims[i]) && anims[i].isGlobal)
                        {
                            anims[i].isGlobal = false;
                        }
                    }
                }
            }

            anim.sequenceLoadAll       = GUILayout.Toggle(anim.sequenceLoadAll, "Build All Sequence On Start");
            anim.sequenceKillWhenDone  = GUILayout.Toggle(anim.sequenceKillWhenDone, "Kill Sequence When Done");
            anim.playOnEnable          = GUILayout.Toggle(anim.playOnEnable, "Play On Enable");
            anim.onDisableAction       = (AnimatorData.DisableAction)EditorGUILayout.EnumPopup("On Disable", anim.onDisableAction);
            anim.updateType            = (DG.Tweening.UpdateType)EditorGUILayout.EnumPopup("Update", anim.updateType);
            anim.updateTimeIndependent = EditorGUILayout.Toggle("Time Independent", anim.updateTimeIndependent);

            if (PrefabUtility.GetPrefabType(aData.gameObject) != PrefabType.Prefab)
            {
                AMTimeline timeline = AMTimeline.window;

                if (timeline != null && aData == timeline.aData)
                {
                    if (GUILayout.Button("Deselect"))
                    {
                        timeline.aData = null;
                        timeline.Repaint();

                        if (Selection.activeGameObject == aData.gameObject)
                        {
                            Selection.activeGameObject = null;
                        }
                    }
                }
                else
                {
                    if (GUILayout.Button("Edit Timeline"))
                    {
                        if (timeline != null)
                        {
                            timeline.aData = aData;
                            timeline.Repaint();
                        }
                        else
                        {
                            EditorWindow.GetWindow(typeof(AMTimeline));
                        }
                    }
                }
            }

            //display missings
            string[] missings = aData.target.GetMissingTargets();
            if (missings != null && missings.Length > 0)
            {
                AMEditorUtil.DrawSeparator();
                mMissingsFoldout = EditorGUILayout.Foldout(mMissingsFoldout, string.Format("Missing Targets [{0}]", missings.Length));
                if (mMissingsFoldout)
                {
                    for (int i = 0; i < missings.Length; i++)
                    {
                        GUILayout.Label(missings[i]);
                    }
                }

                //fix missing targets
                if (GUILayout.Button("Generate Missing Targets"))
                {
                    aData.target.GenerateMissingTargets(missings);
                }
            }

            GUILayout.EndVertical();

            switch (metaComm)
            {
            case MetaCommand.Save:
                aData.MetaSaveInstantiate();
                GUI.changed = true;
                break;

            case MetaCommand.SaveAs:
                string path = EditorUtility.SaveFilePanelInProject("Save AnimatorMeta", aData.name + ".prefab", "prefab", "Please enter a file name to save the animator data to");
                if (!string.IsNullOrEmpty(path))
                {
                    GameObject metago = new GameObject("_meta");
                    metago.AddComponent <AnimatorMeta>();
                    UnityEngine.Object pref       = PrefabUtility.CreateEmptyPrefab(path);
                    GameObject         metagopref = PrefabUtility.ReplacePrefab(metago, pref);
                    UnityEngine.Object.DestroyImmediate(metago);
                    aData.MetaSet(metagopref.GetComponent <AnimatorMeta>(), true);
                }
                break;

            case MetaCommand.Revert:
                if (EditorUtility.DisplayDialog("Revert Animator Meta", "Are you sure?", "Yes", "No"))
                {
                    aData.RegisterUndo("Revert Animator Meta", true);
                    GameObject prefabGO = PrefabUtility.GetPrefabParent(aData.meta.gameObject) as GameObject;
                    aData.MetaSet(prefabGO ? prefabGO.GetComponent <AnimatorMeta>() : null, false);
                    GUI.changed = true;
                }
                break;

            case MetaCommand.Instantiate:
                //warning if there are missing targets
                bool doIt = true;
                if (missings != null && missings.Length > 0)
                {
                    doIt = EditorUtility.DisplayDialog("Break Animator Meta", "There are missing targets, some keys will be removed. Do you want to proceed?", "Yes", "No");
                }
                if (doIt)
                {
                    aData.RegisterUndo("Break Animator Meta", false);
                    aData.MetaSet(null, true);
                    aData.currentTakeInd = 0;
                    GUI.changed          = true;
                }
                break;
            }

            if (GUI.changed)
            {
                if (AMTimeline.window)
                {
                    AMTimeline.window.Repaint();
                }
            }
        }
Beispiel #21
0
        public override void OnInspectorGUI()
        {
            serializedObject.Update();

            AnimatorData mb = target as AnimatorData;

            Dbg.Assert(mb != null, "AnimatorDataEditor.OnInspectorGUI: cannot get target: {0}", target.name);

            EditorGUILayout.HelpBox("If you want to modify the takes list, do it via the Timeline editor", MessageType.Info);

            if (EUtil.Button("Open Timeline Editor", Color.green))
            {
                AMTimeline.ResetWithAnimatorData((AnimatorData)target);
            }

            string playOnStartName = (m_spPlayOnStart.objectReferenceValue != null) ? ((AMTake)m_spPlayOnStart.objectReferenceValue).name : "None";

            EditorGUILayout.LabelField("Play On Start:  " + playOnStartName);

            EUtil.DrawSplitter();

            for (int i = 0; i < m_spTakes.arraySize; ++i)
            {
                var oneTake = m_spTakes.GetArrayElementAtIndex(i);

                GUILayout.BeginHorizontal();
                {
                    if (oneTake != null && oneTake.objectReferenceValue != null)
                    {
                        AMTake takeObj = oneTake.objectReferenceValue as AMTake;
                        EditorGUILayout.LabelField(string.Format("{0}: \"{1} fr, {2} fps\"", takeObj.name, takeObj.numFrames, takeObj.frameRate));
                        if (GUILayout.Button(new GUIContent(ms_inspectTex, "inspect this take's content"), GUILayout.Height(20f), GUILayout.Width(30f)))
                        {
                            Selection.activeObject = takeObj;
                        }
                        //EUtil.PushGUIColor(EditorUtility.IsPersistent(takeObj) ? Color.yellow : Color.green);
                        //if (GUILayout.Button(new GUIContent("S", "save asset to disk"), GUILayout.Width(30f)))
                        //{
                        //    string path = null;
                        //    if (!EditorUtility.IsPersistent(takeObj))
                        //        path = EditorUtility.SaveFilePanelInProject("Save Take", takeObj.name, "asset", "Select asset path");
                        //    else
                        //        path = AssetDatabase.GetAssetPath(takeObj);

                        //    if (!string.IsNullOrEmpty(path))
                        //    {
                        //        takeObj.SaveAsset(mb, path);
                        //        EUtil.ShowNotification("Saved Take at: " + path, 3f);
                        //    }
                        //}
                        //EUtil.PopGUIColor();
                    }
                    else
                    {
                        GUILayout.Label("This slot is null reference");
                    }
                }
                GUILayout.EndHorizontal();
            }

            serializedObject.ApplyModifiedProperties();
        }
Beispiel #22
0
        // Use this for initialization
        void OnGUI()
        {
            AMTimeline.loadSkin(ref skin, ref cachedSkinName, position);
            GUIStyle padding = new GUIStyle();

            padding.padding = new RectOffset(4, 4, 4, 4);
            GUILayout.BeginVertical(padding);
            AMEditorUtil.ResetDisplayControls();
            GUILayout.BeginHorizontal();
            GUILayout.Label(newReference.Count + " possible duplicate" + (newReference.Count > 1 ? "s" : "") + " found:");
            GUILayout.FlexibleSpace();
            GUILayout.Label("Keep: ");
            if (GUILayout.Button("All", GUILayout.Width(width_button_action)))
            {
                for (int i = 0; i < actions.Count; i++)
                {
                    actions[i] = 0;
                }
            }
            if (GUILayout.Button("New", GUILayout.Width(width_button_action)))
            {
                for (int i = 0; i < actions.Count; i++)
                {
                    actions[i] = 1;
                }
            }
            if (GUILayout.Button("Previous", GUILayout.Width(width_button_action)))
            {
                for (int i = 0; i < actions.Count; i++)
                {
                    actions[i] = 2;
                }
            }
            GUILayout.Space(18f);
            GUILayout.EndHorizontal();
            GUILayout.Space(4f);
            GUIStyle styleScrollView = new GUIStyle(GUI.skin.scrollView);

            styleScrollView.normal.background = GUI.skin.GetStyle("GroupElementBG").onNormal.background;
            styleScrollView.padding           = new RectOffset(0, 0, 4, 4);
            scrollPos = GUILayout.BeginScrollView(scrollPos, false, true, GUI.skin.horizontalScrollbar, GUI.skin.verticalScrollbar, styleScrollView);

            int maxGameObjects = Mathf.CeilToInt((position.height - 62f) / height_gameobject);

            maxGameObjects = Mathf.Clamp(maxGameObjects, 0, newReference.Count);
            int FirstIndex = Mathf.FloorToInt(scrollPos.y / height_gameobject) - 1;

            FirstIndex = Mathf.Clamp(FirstIndex, 0, newReference.Count);
            int LastIndex = FirstIndex + maxGameObjects;

            LastIndex = Mathf.Clamp(LastIndex, 0, newReference.Count);
            if (LastIndex - FirstIndex < maxGameObjects)
            {
                FirstIndex = Mathf.Clamp(LastIndex - maxGameObjects, 0, newReference.Count);
            }

            for (int i = 0; i < newReference.Count; i++)
            {
                if (newReference.Count > maxGameObjects && (i < FirstIndex || i > LastIndex))
                {
                    GUILayout.Space(height_gameobject);
                    continue;
                }
                GUILayout.BeginHorizontal(GUILayout.Height(height_gameobject));
                GUILayout.Label("New: ", GUILayout.Width(40f));
                GUI.enabled = false;
                EditorGUILayout.ObjectField(newReference[i], typeof(GameObject), true, GUILayout.Width(width_object_field));
                GUI.enabled = true;
                GUILayout.Label("Prev: ", GUILayout.Width(40f));
                // do not allow null values
                GameObject go = (GameObject)EditorGUILayout.ObjectField(oldReference[i], typeof(GameObject), true, GUILayout.Width(width_object_field));
                if (go)
                {
                    oldReference[i] = go;
                }
                GUILayout.FlexibleSpace();
                bool keepBoth = actions[i] == 0;
                keepBoth = GUILayout.Toggle(keepBoth, "");
                GUILayout.BeginVertical();
                GUILayout.Space(height_label_offset);
                GUILayout.Label("Both", GUILayout.Width(width_toggle_label));
                GUILayout.EndVertical();
                bool keepFirst = actions[i] == 1;
                keepFirst = GUILayout.Toggle(keepFirst, "");
                GUILayout.BeginVertical();
                GUILayout.Space(height_label_offset);
                GUILayout.Label("New", GUILayout.Width(width_toggle_label));
                GUILayout.EndVertical();
                bool keepSecond = actions[i] == 2;
                keepSecond = GUILayout.Toggle(keepSecond, "");
                GUILayout.BeginVertical();
                GUILayout.Space(height_label_offset);
                GUILayout.Label("Prev.", GUILayout.Width(width_toggle_label));
                GUILayout.EndVertical();
                GUILayout.EndHorizontal();
                // set action
                if (keepBoth && actions[i] != 0)
                {
                    actions[i] = 0;
                }
                else if (keepFirst && actions[i] != 1)
                {
                    actions[i] = 1;
                }
                else if (keepSecond && actions[i] != 2)
                {
                    actions[i] = 2;
                }
            }
            GUILayout.EndScrollView();
            GUILayout.Space(4f);
            GUILayout.BeginHorizontal();
            if (GUILayout.Button("Apply"))
            {
                saveChanges();
            }
            if (GUILayout.Button("Cancel"))
            {
                this.Close();
            }
            GUILayout.EndHorizontal();
            GUILayout.EndVertical();
        }
Beispiel #23
0
        void OnGUI()
        {
            AMTimeline.loadSkin(ref skin, ref cachedSkinName, position);
            if (aData == null)
            {
                AMTimeline.MessageBox("Animator requires an AnimatorData component in your scene. Launch Animator to add the component.", AMTimeline.MessageBoxType.Warning);
                return;
            }

            if (!mTrack)
            {
                return;
            }

            Renderer render = mTrack.GetTarget(aData.target) as Renderer;

            if (!render)
            {
                AMTimeline.MessageBox("Assign a Renderer to the track first.", AMTimeline.MessageBoxType.Warning);
                return;
            }

            //select material
            Material[] mats = render.sharedMaterials;

            string[] matNames = new string[mats.Length];
            int[]    matInds  = new int[mats.Length];
            for (int i = 0; i < mats.Length; i++)
            {
                matNames[i] = mats[i].name;
                matInds[i]  = i;
            }

            //grab track info
            int      matInd         = Mathf.Clamp(mTrack.materialIndex, 0, mats.Length - 1);
            Material matOverride    = mTrack.materialOverride;
            string   shaderProperty = mTrack.property;

            //material select
            matInd = EditorGUILayout.IntPopup("Material", matInd, matNames, matInds);

            //material override select
            matOverride = EditorGUILayout.ObjectField("Material Override", matOverride, typeof(Material), false) as Material;

            Material mat = matOverride ? matOverride : mats[matInd];

            //grab material info
            string[] shaderPropertyNames, shaderPropertyDetails;
            AMMaterialTrack.ValueType[] shaderPropertyTypes;
            int[] shaderPropertyInds;
            GetPropertyInfos(mat, out shaderPropertyNames, out shaderPropertyDetails, out shaderPropertyTypes, out shaderPropertyInds);

            int shaderPropertyInd = -1;

            AMMaterialTrack.ValueType shaderPropertyType = mTrack.propertyType;

            for (int i = 0; i < shaderPropertyNames.Length; i++)
            {
                if (shaderProperty == shaderPropertyNames[i])
                {
                    shaderPropertyInd = i;

                    //special case for texture offset and scale
                    if (shaderPropertyTypes[i] == AMMaterialTrack.ValueType.TexEnv && i + 2 < shaderPropertyNames.Length)
                    {
                        if (shaderPropertyType == shaderPropertyTypes[i + 1])
                        {
                            shaderPropertyInd += 1;
                        }
                        else if (shaderPropertyType == shaderPropertyTypes[i + 2])
                        {
                            shaderPropertyInd += 2;
                        }
                    }
                    break;
                }
            }

            if (shaderPropertyInd == -1)
            {
                shaderPropertyInd = 0;
            }

            EditorUtility.DrawSeparator();

            //shader property select
            shaderPropertyInd = EditorGUILayout.IntPopup("Property", shaderPropertyInd, shaderPropertyDetails, shaderPropertyInds);

            shaderProperty     = shaderPropertyNames[shaderPropertyInd];
            shaderPropertyType = shaderPropertyTypes[shaderPropertyInd];

            //check for change
            if (mTrack.materialIndex != matInd || mTrack.materialOverride != matOverride || mTrack.property != shaderProperty || mTrack.propertyType != shaderPropertyType)
            {
                Undo.RecordObject(mTrack, "Material Track Property Change");

                mTrack.materialIndex    = matInd;
                mTrack.materialOverride = matOverride;
                mTrack.property         = shaderProperty;
                mTrack.propertyType     = shaderPropertyType;
            }
        }
Beispiel #24
0
        void OnGUI()
        {
            AMTimeline.loadSkin(ref skin, ref cachedSkinName, position);
            if (aData == null)
            {
                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();
            }
            GUILayout.BeginHorizontal();
            #region tab selection
            //GUI.DrawTexture(new Rect(0f,0f,120f,position.height),GUI.skin.GetStyle("GroupElementBG")/*GUI.skin.GetStyle("GroupElementBG").onNormal.background*/);
            GUIStyle styleTabSelectionBG = new GUIStyle(GUI.skin.GetStyle("GroupElementBG"));
            styleTabSelectionBG.normal.background = EditorStyles.toolbar.normal.background;
            GUILayout.BeginVertical(/*GUI.skin.GetStyle("GroupElementBG")*/ styleTabSelectionBG, GUILayout.Width(121f));
            EditorUtility.ResetDisplayControls();
            GUIStyle styleTabButton = new GUIStyle(EditorStyles.toolbarButton);
            styleTabButton.fontSize             = 12;
            styleTabButton.fixedHeight          = 30;
            styleTabButton.onNormal.background  = styleTabButton.onActive.background;
            styleTabButton.onFocused.background = null;
            styleTabButton.onHover.background   = null;
            tabIndex = GUILayout.SelectionGrid(tabIndex, tabNames, 1, styleTabButton);
            GUILayout.EndVertical();
            #endregion
            #region options
            GUILayout.BeginVertical();
            EditorUtility.ResetDisplayControls();

            GUIStyle styleArea = new GUIStyle(GUI.skin.textArea);
            scrollView = GUILayout.BeginScrollView(scrollView, styleArea);
            List <string> takeNames = getTakeNames();

            GUIStyle styleTitle = new GUIStyle(GUI.skin.label);
            styleTitle.fontSize  = 20;
            styleTitle.fontStyle = FontStyle.Bold;

            // tab title
            GUILayout.BeginHorizontal();
            GUILayout.Space(width_indent);
            GUILayout.Label(tabNames[tabIndex], styleTitle);
            GUILayout.EndHorizontal();
            GUILayout.Space(10f);

            #region general
            if (tabIndex == (int)tabType.General)
            {
                List <string> takeNamesWithNone = new List <string>(takeNames);
                takeNamesWithNone.Insert(0, "None");

                // gizmo size
                GUILayout.BeginHorizontal();
                GUILayout.Space(width_indent);
                GUILayout.BeginVertical(GUILayout.Height(26f), GUILayout.Width(80f));
                GUILayout.FlexibleSpace();
                GUILayout.Label("Gizmo size", GUILayout.Width(80f));
                GUILayout.FlexibleSpace();
                GUILayout.EndVertical();

                float newGizmoSize = GUILayout.HorizontalSlider(oData.gizmo_size, 0f, 0.1f, GUILayout.ExpandWidth(true));
                if (oData.gizmo_size != newGizmoSize)
                {
                    oData.gizmo_size             = newGizmoSize;
                    AnimatorTimeline.e_gizmoSize = newGizmoSize;
                    GUIUtility.keyboardControl   = 0;
                    UnityEditor.EditorUtility.SetDirty(oData);
                }

                GUILayout.BeginVertical(GUILayout.Height(26f), GUILayout.Width(75f));
                GUILayout.FlexibleSpace();
                newGizmoSize = EditorGUILayout.FloatField(oData.gizmo_size, GUI.skin.textField, GUILayout.Width(75f));
                if (oData.gizmo_size != newGizmoSize)
                {
                    oData.gizmo_size             = newGizmoSize;
                    AnimatorTimeline.e_gizmoSize = newGizmoSize;
                    UnityEditor.EditorUtility.SetDirty(oData);
                }

                GUILayout.FlexibleSpace();
                GUILayout.EndVertical();
                GUILayout.EndHorizontal();
                // pixel/unit default
                GUILayout.BeginHorizontal();
                GUILayout.Space(width_indent);
                EditorGUIUtility.labelWidth = 250.0f;
                float ppu = EditorGUILayout.FloatField("Pixel/Unit Default", oData.pixelPerUnitDefault);
                if (ppu <= 0.001f)
                {
                    ppu = 0.001f;
                }
                if (oData.pixelPerUnitDefault != ppu)
                {
                    oData.pixelPerUnitDefault = ppu;
                    // save
                    UnityEditor.EditorUtility.SetDirty(oData);
                }
                GUILayout.EndHorizontal();
                GUILayout.Space(4.0f);
                // dynamic max frames
                GUILayout.BeginHorizontal();
                GUILayout.Space(width_indent);
                EditorGUIUtility.labelWidth = 100.0f;
                var lastFieldWidth = EditorGUIUtility.fieldWidth;
                EditorGUIUtility.fieldWidth = 50.0f;
                int fpp = EditorGUILayout.IntField("Frames/Page", oData.framesPerPage);
                if (fpp < 15)
                {
                    fpp = 15;
                }
                if (oData.framesPerPage != fpp)
                {
                    oData.framesPerPage = fpp;
                    // save
                    UnityEditor.EditorUtility.SetDirty(oData);
                }

                int mp = EditorGUILayout.IntField("Max Page", oData.maxPage);
                if (mp < 1)
                {
                    mp = 1;
                }
                if (oData.maxPage != mp)
                {
                    oData.maxPage = mp;
                    // save
                    UnityEditor.EditorUtility.SetDirty(oData);
                }
                GUILayout.EndHorizontal();
                GUILayout.Space(4.0f);
                EditorGUIUtility.fieldWidth = lastFieldWidth;
                // sprite drag/drop fps
                GUILayout.BeginHorizontal();
                GUILayout.Space(width_indent);
                EditorGUIUtility.labelWidth = 250.0f;
                int nfps = EditorGUILayout.IntField("Sprite Insert Frame/Second", oData.spriteInsertFramePerSecond);
                if (nfps <= 0)
                {
                    nfps = 1;
                }
                if (oData.spriteInsertFramePerSecond != nfps)
                {
                    oData.spriteInsertFramePerSecond = nfps;
                    // save
                    UnityEditor.EditorUtility.SetDirty(oData);
                }
                GUILayout.EndHorizontal();
                // time instead of frame numbers
                GUILayout.BeginHorizontal();
                GUILayout.Space(width_indent);
                GUILayout.BeginVertical(GUILayout.Height(26f));
                GUILayout.FlexibleSpace();
                GUILayout.Label("Show time instead of frame numbers");
                GUILayout.FlexibleSpace();
                GUILayout.EndVertical();
                if (oData.setTimeNumbering(GUILayout.Toggle(oData.time_numbering, "")))
                {
                    // save
                    UnityEditor.EditorUtility.SetDirty(oData);
                }
                GUILayout.EndHorizontal();
                // scrubby zoom cursor
                GUILayout.BeginHorizontal();
                GUILayout.Space(width_indent);
                GUILayout.BeginVertical(GUILayout.Height(26f));
                GUILayout.FlexibleSpace();
                GUILayout.Label("Scrubby zoom cursor");
                GUILayout.FlexibleSpace();
                GUILayout.EndVertical();
                if (oData.setScrubbyZoomCursor(GUILayout.Toggle(oData.scrubby_zoom_cursor, "")))
                {
                    // save
                    UnityEditor.EditorUtility.SetDirty(oData);
                }
                GUILayout.EndHorizontal();
                // scrubby zoom slider
                GUILayout.BeginHorizontal();
                GUILayout.Space(width_indent);
                GUILayout.BeginVertical(GUILayout.Height(26f));
                GUILayout.FlexibleSpace();
                GUILayout.Label("Scrubby zoom slider");
                GUILayout.FlexibleSpace();
                GUILayout.EndVertical();
                if (oData.setScrubbyZoomSlider(GUILayout.Toggle(oData.scrubby_zoom_slider, "")))
                {
                    // save
                    UnityEditor.EditorUtility.SetDirty(oData);
                }
                GUILayout.EndHorizontal();
                // show warning for lost references

                /*GUILayout.BeginHorizontal();
                 *  GUILayout.Space(width_indent);
                 *  GUILayout.BeginVertical(GUILayout.Height(26f));
                 *      GUILayout.FlexibleSpace();
                 *      GUILayout.Label ("Show warning for lost references");
                 *      GUILayout.FlexibleSpace();
                 *  GUILayout.EndVertical();
                 *  if(oData.setShowWarningForLostReferences(GUILayout.Toggle(oData.showWarningForLostReferences,""))) {
                 *      // save
                 *      EditorUtility.SetDirty(oData);
                 *  }
                 * GUILayout.EndHorizontal();*/
                // ignore minimum window size warning
                GUILayout.BeginHorizontal();
                GUILayout.Space(width_indent);
                GUILayout.BeginVertical(GUILayout.Height(26f));
                GUILayout.FlexibleSpace();
                GUILayout.Label("Ignore minimum window size warning");
                GUILayout.FlexibleSpace();
                GUILayout.EndVertical();
                if (oData.setIgnoreMinimumSizeWarning(GUILayout.Toggle(oData.ignoreMinSize, "")))
                {
                    // save
                    UnityEditor.EditorUtility.SetDirty(oData);
                }
                GUILayout.EndHorizontal();
                // show frames for collapsed tracks
                GUILayout.BeginHorizontal();
                GUILayout.Space(width_indent);
                GUILayout.BeginVertical(GUILayout.Height(26f));
                GUILayout.FlexibleSpace();
                GUILayout.Label("Show frames for collapsed tracks");
                GUILayout.FlexibleSpace();
                GUILayout.EndVertical();
                if (oData.setShowFramesForCollapsedTracks(GUILayout.Toggle(oData.showFramesForCollapsedTracks, "")))
                {
                    // save
                    UnityEditor.EditorUtility.SetDirty(oData);
                }
                GUILayout.EndHorizontal();
                // disable timeline actions
                GUILayout.BeginHorizontal();
                GUILayout.Space(width_indent);
                GUILayout.BeginVertical(GUILayout.Height(26f));
                GUILayout.FlexibleSpace();
                GUILayout.Label("Hide Timeline Actions (May increase editor performance)");
                GUILayout.FlexibleSpace();
                GUILayout.EndVertical();
                if (oData.setDisableTimelineActions(GUILayout.Toggle(oData.disableTimelineActions, "")))
                {
                    // save
                    UnityEditor.EditorUtility.SetDirty(oData);
                    AMTimeline.recalculateNumFramesToRender();
                }
                GUILayout.EndHorizontal();
                // disable timeline actions tooltip
                if (oData.disableTimelineActions)
                {
                    GUI.enabled = false;
                }
                GUILayout.BeginHorizontal();
                GUILayout.Space(width_indent);
                GUILayout.BeginVertical(GUILayout.Height(26f));
                GUILayout.FlexibleSpace();
                GUILayout.Label("Enable Timeline Actions tooltip");
                GUILayout.FlexibleSpace();
                GUILayout.EndVertical();
                if (oData.disableTimelineActions)
                {
                    GUILayout.Toggle(false, "");
                }
                else
                {
                    if (oData.setDisableTimelineActionsTooltip(!GUILayout.Toggle(!oData.disableTimelineActionsTooltip, "")))
                    {
                        // save
                        UnityEditor.EditorUtility.SetDirty(oData);
                    }
                }
                GUILayout.EndHorizontal();
            }
            #endregion
            #region quick add
            else if (tabIndex == (int)tabType.QuickAdd)
            {
                EditorUtility.ResetDisplayControls();
                GUILayout.Space(3f);
                GUILayout.BeginHorizontal();
                GUILayout.Space(width_indent);
                GUILayout.Label("Combinations");
                GUILayout.EndHorizontal();
                if (oData.quickAdd_Combos == null)
                {
                    oData.quickAdd_Combos = new List <List <int> >();
                }
                for (int j = 0; j < oData.quickAdd_Combos.Count; j++)
                {
                    GUILayout.Space(3f);
                    GUILayout.BeginHorizontal();
                    GUILayout.Space(width_indent);
                    for (int i = 0; i < oData.quickAdd_Combos[j].Count; i++)
                    {
                        if (oData.setQuickAddCombo(j, i, EditorGUILayout.Popup(oData.quickAdd_Combos[j][i], AMTimeline.TrackNames, GUILayout.Width(80f))))
                        {
                            oData.flatten_quickAdd_Combos();
                            UnityEditor.EditorUtility.SetDirty(oData);
                        }
                        if (i < oData.quickAdd_Combos[j].Count - 1)
                        {
                            GUILayout.Label("+");
                        }
                    }
                    GUILayout.FlexibleSpace();
                    if (oData.quickAdd_Combos[j].Count > 0)
                    {
                        if (GUILayout.Button("-", GUILayout.Width(20f), GUILayout.Height(20f)))
                        {
                            oData.quickAdd_Combos[j].RemoveAt(oData.quickAdd_Combos[j].Count - 1);
                            if (oData.quickAdd_Combos[j].Count == 0)
                            {
                                oData.quickAdd_Combos.RemoveAt(j);
                                j--;
                            }
                            oData.flatten_quickAdd_Combos();
                            UnityEditor.EditorUtility.SetDirty(oData);
                        }
                    }
                    if (GUILayout.Button("+", GUILayout.Width(20f), GUILayout.Height(20f)))
                    {
                        oData.quickAdd_Combos[j].Add((int)AMTimeline.Track.Translation);
                        oData.flatten_quickAdd_Combos();
                        UnityEditor.EditorUtility.SetDirty(oData);
                    }
                    GUILayout.EndHorizontal();
                }
                GUILayout.Space(3f);
                GUILayout.BeginHorizontal();
                if (oData.quickAdd_Combos.Count <= 0)
                {
                    GUILayout.Space(width_indent);
                    GUILayout.Label("Click '+' to add a new combination");
                }
                GUILayout.FlexibleSpace();
                // new combo
                if (GUILayout.Button("+", GUILayout.Width(20f), GUILayout.Height(20f)))
                {
                    oData.quickAdd_Combos.Add(new List <int> {
                        (int)AMTimeline.Track.Translation
                    });
                    oData.flatten_quickAdd_Combos();
                    UnityEditor.EditorUtility.SetDirty(oData);
                }
                GUILayout.EndHorizontal();
            }
            #endregion
            #region import / export
            else if (tabIndex == (int)tabType.ImportExport)
            {
                GUIStyle labelRight = new GUIStyle(GUI.skin.label);
                labelRight.alignment = TextAnchor.MiddleRight;
                GUILayout.Space(10f);
                GUILayout.BeginHorizontal(GUILayout.Width(300f));
                GUILayout.Space(width_indent);
                GUILayout.BeginVertical();
                GUILayout.Space(1f);
                GUILayout.Label("Take(s):", labelRight, GUILayout.Width(55f));
                GUILayout.EndVertical();
                GUILayout.BeginVertical();
                GUILayout.Space(1f);
                if (GUILayout.Button("Import", GUILayout.Width(60f)))
                {
                    //TODO: undo "Import Take(s)"
                    string importTakesPath = UnityEditor.EditorUtility.OpenFilePanel("Import Take(s)", "Assets/", "unity");
                    if (importTakesPath != "")
                    {
                        AMTakeImport.openAdditiveAndDeDupe(importTakesPath);
                    }
                }
                GUILayout.EndVertical();
                GUILayout.BeginVertical();
                GUILayout.Space(1f);
                if (GUILayout.Button("Export:", GUILayout.Width(60f)))
                {
                    if (!exportAllTakes)
                    {
                        AMTakeExport.take = aData.GetTake(takeNames[exportTakeIndex]);
                    }
                    else
                    {
                        AMTakeExport.take = null;
                    }
                    //AMTakeExport.aData = aData;
                    //EditorWindow.GetWindow (typeof (AMTakeExport)).ShowUtility();
                    EditorWindow windowExport = ScriptableObject.CreateInstance <AMTakeExport>();
                    windowExport.ShowUtility();
                }
                GUILayout.EndVertical();
                GUILayout.BeginVertical();
                exportAllTakes = (GUILayout.Toggle(!exportAllTakes, "") ? false : exportAllTakes);
                GUILayout.EndVertical();
                GUILayout.BeginVertical();
                GUILayout.Space(4f);
                setExportTakeIndex(EditorGUILayout.Popup(exportTakeIndex, takeNames.ToArray(), GUILayout.Width(100f)));
                GUILayout.EndVertical();
                GUILayout.BeginVertical();
                exportAllTakes = (GUILayout.Toggle(exportAllTakes, "") ? true : exportAllTakes);
                GUILayout.EndVertical();
                GUILayout.BeginVertical();
                GUILayout.Space(2f);
                GUILayout.Label("All Takes");
                GUILayout.EndVertical();

                GUILayout.EndHorizontal();
                GUILayout.Space(3f);
                GUILayout.BeginHorizontal();
                GUILayout.Space(width_indent);
                GUILayout.Label("Options:", labelRight, GUILayout.Width(55f));
                if (GUILayout.Button("Import", GUILayout.Width(60f)))
                {
                    //TODO: undo for "Import Options"
                    string importOptionsPath = UnityEditor.EditorUtility.OpenFilePanel("Import Options", "Assets/Animator", "unitypackage");
                    if (importOptionsPath != "")
                    {
                        AssetDatabase.ImportPackage(importOptionsPath, true);
                        this.Close();
                    }
                }
                if (GUILayout.Button("Export", GUILayout.Width(60f)))
                {
                    AMOptionsFile.export();
                }
                GUILayout.EndHorizontal();
            }
            #endregion
            #region about
            else if (tabIndex == (int)tabType.About)
            {
                GUILayout.Space(3f);

                string message = "Animator v" + version + ", Originally by Abdulla Ameen (c) 2012.  Modified by David Dionisio under the Creative Commons Attribution-NonCommercial 3.0 Unported License.\n\nPlease have a look at the documentation if you need help, or e-mail [email protected] for further assistance.";
                message += "\n\nHOTween by Daniele Giardini\n\nAdditional code contributions by:\nQuick Fingers, Eric Haines";
                GUIStyle styleInfo = new GUIStyle(GUI.skin.label);
                GUILayout.BeginHorizontal();
                GUILayout.Space(5);
                styleInfo.wordWrap = true;
                GUILayout.Label(message, styleInfo);
                GUILayout.EndHorizontal();
            }
            #endregion
            GUILayout.EndScrollView();
            GUILayout.EndVertical();
            #endregion
            GUILayout.EndHorizontal();
        }
Beispiel #25
0
    void OnEnable()
    {
        if(!texLoaded) {
            tex_cursor_zoomin = AMEditorResource.LoadEditorTexture("am_cursor_zoomin");
            tex_cursor_zoomout = AMEditorResource.LoadEditorTexture("am_cursor_zoomout");
            tex_cursor_zoom_blank = AMEditorResource.LoadEditorTexture("am_cursor_zoom_blank");
            tex_cursor_zoom = null;
            tex_cursor_grab = AMEditorResource.LoadEditorTexture("am_cursor_grab");
            tex_icon_track = AMEditorResource.LoadEditorTexture("am_icon_track");
            tex_icon_track_hover = AMEditorResource.LoadEditorTexture("am_icon_track_hover");
            tex_icon_group_closed = AMEditorResource.LoadEditorTexture("am_icon_group_closed");
            tex_icon_group_open = AMEditorResource.LoadEditorTexture("am_icon_group_open");
            tex_icon_group_hover = AMEditorResource.LoadEditorTexture("am_icon_group_hover");
            tex_element_position = AMEditorResource.LoadEditorTexture("am_element_position");
            texFrKey = AMEditorResource.LoadEditorTexture("am_key");
            texFrSet = AMEditorResource.LoadEditorTexture("am_frame_set");
            //texFrU = AMEditorResource.LoadTexture("am_frame");
            //texFrM = AMEditorResource.LoadTexture("am_frame-m");
            //texFrUS = AMEditorResource.LoadTexture("am_frame-s");
            //texFrMS = AMEditorResource.LoadTexture("am_frame-m-s");
            //texFrUG = AMEditorResource.LoadTexture("am_frame-g");
            texKeyBirdsEye = AMEditorResource.LoadEditorTexture("am_key_birdseye");
            texIndLine = AMEditorResource.LoadEditorTexture("am_indicator_line");
            texIndHead = AMEditorResource.LoadEditorTexture("am_indicator_head");
            texProperties = AMEditorResource.LoadEditorTexture("am_information");
            texRightArrow = AMEditorResource.LoadEditorTexture("am_nav_right");// inspector right arrow
            texLeftArrow = AMEditorResource.LoadEditorTexture("am_nav_left");	// inspector left arrow
            texInterpl[0] = AMEditorResource.LoadEditorTexture("am_interpl_curve"); texInterpl[1] = AMEditorResource.LoadEditorTexture("am_interpl_linear");
            texBoxBorder = AMEditorResource.LoadEditorTexture("am_box_border");
            texBoxRed = AMEditorResource.LoadEditorTexture("am_box_red");
            //texBoxBlue = AMEditorResource.LoadTexture("am_box_blue");
            texBoxLightBlue = AMEditorResource.LoadEditorTexture("am_box_lightblue");
            texBoxDarkBlue = AMEditorResource.LoadEditorTexture("am_box_darkblue");
            texBoxGreen = AMEditorResource.LoadEditorTexture("am_box_green");
            texBoxPink = AMEditorResource.LoadEditorTexture("am_box_pink");
            texBoxYellow = AMEditorResource.LoadEditorTexture("am_box_yellow");
            texBoxOrange = AMEditorResource.LoadEditorTexture("am_box_orange");
            texIconTranslation = AMEditorResource.LoadEditorTexture("am_icon_translation");
            texIconRotation = AMEditorResource.LoadEditorTexture("am_icon_rotation");
            texIconAnimation = AMEditorResource.LoadEditorTexture("am_icon_animation");
            texIconAudio = AMEditorResource.LoadEditorTexture("am_icon_audio");
            texIconProperty = AMEditorResource.LoadEditorTexture("am_icon_property");
            texIconEvent = AMEditorResource.LoadEditorTexture("am_icon_event");
            texIconOrientation = AMEditorResource.LoadEditorTexture("am_icon_orientation");

            texLoaded = true;
        }

        this.title = "Animator";
        this.minSize = new Vector2(width_track + width_playback_controls + width_inspector_open + 70f, 190f);
        window = this;
        //this.wantsMouseMove = true;
        // find component
        if(!aData && !EditorApplication.isPlayingOrWillChangePlaymode) {
            GameObject go = Selection.activeGameObject;
            if(go && PrefabUtility.GetPrefabType(go) != PrefabType.Prefab) {
                aData = go.GetComponent<AnimatorData>();
            }
        }

        oData = AMOptionsFile.loadFile();
        // set default current dimensions of frames
        //current_width_frame = width_frame;
        //current_height_frame = height_frame;
        // set is playing to false
        isPlaying = false;

        // add track menu
        buildAddTrackMenu();

        // playmode callback
        EditorApplication.playmodeStateChanged += OnPlayMode;

        // check for pro license
        AMTake.isProLicense = PlayerSettings.advancedLicense;

        //autoRepaintOnSceneChange = true;

        mTempHolder = new GameObject();
        mTempHolder.hideFlags = HideFlags.HideAndDontSave;
    }
Beispiel #26
0
    void OnGUI()
    {
        AMTimeline.loadSkin(oData, ref skin, ref cachedSkinName, position);
        if (!aData)
        {
            AMTimeline.MessageBox("Animator requires an AnimatorData component in your scene. Launch Animator to add the component.", AMTimeline.MessageBoxType.Warning);
            return;
        }
        if (!track)
        {
            return;
        }
        if (!(track).obj)
        {
            AMTimeline.MessageBox("Assign a GameObject to the track first.", AMTimeline.MessageBoxType.Warning);
            return;
        }
        GUILayout.Label("Select a property to add to track '" + track.name + "'" /*, styleLabel*/);
        scrollView = GUILayout.BeginScrollView(scrollView);
        if (arrComponents != null && arrComponents.Length > 0)
        {
            for (int i = 0; i < arrComponents.Length; i++)
            {
                // skip behaviours because they may repeat properties
                // if script is missing (unlikely but it happens in error) then catch and skip
                try {
                    if (arrComponents[i].GetType() == typeof(Behaviour))
                    {
                        continue;
                    }
                } catch {
                    continue;
                }
                Component myComponent = _go.GetComponent(arrComponents[i].GetType());
                if (myComponent == null)
                {
                    continue;
                }

                // component button
                GUILayout.BeginHorizontal(GUILayout.Width(position.width - 5f));
                string componentName = myComponent.GetType().Name;
                if (GUILayout.Button(componentName /*,buttonStyle*/))
                {
                    if (selectionIndex != i)
                    {
                        selectionIndex = i;
                    }
                    else
                    {
                        selectionIndex = -1;
                    }
                }
                string lblToggle;
                if (selectionIndex != i)
                {
                    lblToggle = "+";
                }
                else
                {
                    lblToggle = "-";
                }

                GUILayout.Label(lblToggle, GUILayout.Width(15f));

                GUILayout.EndHorizontal();

                if (selectionIndex == i)
                {
                    //scrollViewComponent = GUILayout.BeginScrollView(scrollViewComponent);
                    int numberOfProperties = 0;
                    // check for special properties
                    if (componentName == "MegaMorph")
                    {
                        processMegaMorph(myComponent);
                        numberOfProperties++;
                    }
                    FieldInfo[] fields = myComponent.GetType().GetFields();
                    // loop through all fields sfields
                    foreach (FieldInfo fieldInfo in fields)
                    {
                        if (!AMPropertyTrack.isValidType(fieldInfo.FieldType))
                        {
                            // invalid type
                            continue;
                        }
                        // fields
                        GUILayout.BeginHorizontal();
                        // field button
                        if (GUILayout.Button(fieldInfo.Name, GUILayout.Width(150f)))
                        {
                            // select the field
                            processSelectProperty(myComponent, fieldInfo, null);
                        }
                        GUILayout.Label(fieldInfo.GetValue(myComponent).ToString());
                        GUILayout.EndHorizontal();
                        numberOfProperties++;
                    }
                    PropertyInfo[] properties = myComponent.GetType().GetProperties();
                    // properties
                    foreach (PropertyInfo propertyInfo in properties)
                    {
                        if (propertyInfo.PropertyType == typeof(HideFlags))
                        {
                            continue;
                        }
                        if (shouldIgnoreProperty(propertyInfo.Name))
                        {
                            continue;
                        }
                        if (propertyInfo.CanWrite && AMPropertyTrack.isValidType(propertyInfo.PropertyType))
                        {
                            object propertyValue;
                            try{
                                propertyValue = propertyInfo.GetValue(myComponent, null);
                            } catch {
                                continue;
                            }
                            GUILayout.BeginHorizontal();
                            if (GUILayout.Button(propertyInfo.Name, GUILayout.Width(150f)))
                            {
                                // select the property
                                processSelectProperty(myComponent, null, propertyInfo);
                            }

                            GUILayout.Label(propertyValue.ToString());
                            GUILayout.EndHorizontal();
                            numberOfProperties++;
                        }
                    }
                    if (numberOfProperties <= 0)
                    {
                        GUILayout.Label("No usable properties found");
                    }
                    //GUILayout.EndScrollView();
                }
            }
        }
        GUILayout.EndScrollView();
    }
Beispiel #27
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();
    }
Beispiel #28
0
    void loadAnimatorData()
    {
        aData = AMTimeline.GetAnimatorData();

        createAllCurves();
    }
Beispiel #29
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();
        }
Beispiel #30
0
    void OnGUI()
    {
        AMTimeline.loadSkin(oData, ref skin, ref cachedSkinName, position);
        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();
        }
        GUILayout.BeginHorizontal();
        #region tab selection
        //GUI.DrawTexture(new Rect(0f,0f,120f,position.height),GUI.skin.GetStyle("GroupElementBG")/*GUI.skin.GetStyle("GroupElementBG").onNormal.background*/);
        GUIStyle styleTabSelectionBG = new GUIStyle(GUI.skin.GetStyle("GroupElementBG"));
        styleTabSelectionBG.normal.background = EditorStyles.toolbar.normal.background;
        GUILayout.BeginVertical(/*GUI.skin.GetStyle("GroupElementBG")*/ styleTabSelectionBG, GUILayout.Width(121f));
        EditorGUIUtility.LookLikeControls();
        GUIStyle styleTabButton = new GUIStyle(EditorStyles.toolbarButton);
        styleTabButton.fontSize             = 12;
        styleTabButton.fixedHeight          = 30;
        styleTabButton.onNormal.background  = styleTabButton.onActive.background;
        styleTabButton.onFocused.background = null;
        styleTabButton.onHover.background   = null;
        tabIndex = GUILayout.SelectionGrid(tabIndex, tabNames, 1, styleTabButton);
        GUILayout.EndVertical();
        #endregion
        #region options
        GUILayout.BeginVertical();
        EditorGUIUtility.LookLikeControls();

        GUIStyle styleArea = new GUIStyle(GUI.skin.textArea);
        scrollView = GUILayout.BeginScrollView(scrollView, styleArea);
        List <string> takeNames = getTakeNames();

        GUIStyle styleTitle = new GUIStyle(GUI.skin.label);
        styleTitle.fontSize  = 20;
        styleTitle.fontStyle = FontStyle.Bold;

        // tab title
        GUILayout.BeginHorizontal();
        GUILayout.Space(width_indent);
        GUILayout.Label(tabNames[tabIndex], styleTitle);
        GUILayout.EndHorizontal();
        GUILayout.Space(10f);

        #region general
        if (tabIndex == (int)tabType.General)
        {
            List <string> takeNamesWithNone = new List <string>(takeNames);
            takeNamesWithNone.Insert(0, "None");
            // play on start
            GUILayout.BeginHorizontal();
            GUILayout.Space(width_indent);
            GUILayout.BeginVertical(GUILayout.Height(26f));
            GUILayout.Space(1f);
            GUILayout.Label("Play On Start");
            GUILayout.FlexibleSpace();
            GUILayout.EndVertical();
            if (setPlayOnStartIndex(EditorGUILayout.Popup(playOnStartIndex, takeNamesWithNone.ToArray(), GUILayout.Width(200f))))
            {
                if (playOnStartIndex == 0)
                {
                    aData.playOnStart = null;
                }
                else
                {
                    aData.playOnStart = aData.getTake(takeNames[playOnStartIndex - 1]);
                }
            }
            GUILayout.EndHorizontal();
            // gizmo size
            GUILayout.BeginHorizontal();
            GUILayout.Space(width_indent);
            GUILayout.BeginVertical(GUILayout.Height(26f), GUILayout.Width(80f));
            GUILayout.FlexibleSpace();
            GUILayout.Label("Gizmo size", GUILayout.Width(80f));
            GUILayout.FlexibleSpace();
            GUILayout.EndVertical();
            if (aData.setGizmoSize(GUILayout.HorizontalSlider(aData.gizmo_size, 0f, 0.1f, GUILayout.ExpandWidth(true))))
            {
                GUIUtility.keyboardControl = 0;
                EditorUtility.SetDirty(aData);
            }
            GUILayout.BeginVertical(GUILayout.Height(26f), GUILayout.Width(75f));
            GUILayout.FlexibleSpace();
            if (aData.setGizmoSize(EditorGUILayout.FloatField(aData.gizmo_size, GUI.skin.textField, GUILayout.Width(75f))))
            {
                EditorUtility.SetDirty(aData);
            }
            GUILayout.FlexibleSpace();
            GUILayout.EndVertical();
            GUILayout.EndHorizontal();
            // time instead of frame numbers
            GUILayout.BeginHorizontal();
            GUILayout.Space(width_indent);
            GUILayout.BeginVertical(GUILayout.Height(26f));
            GUILayout.FlexibleSpace();
            GUILayout.Label("Show time instead of frame numbers");
            GUILayout.FlexibleSpace();
            GUILayout.EndVertical();
            if (oData.setTimeNumbering(GUILayout.Toggle(oData.time_numbering, "")))
            {
                // save
                EditorUtility.SetDirty(oData);
            }
            GUILayout.EndHorizontal();
            // scrubby zoom cursor
            GUILayout.BeginHorizontal();
            GUILayout.Space(width_indent);
            GUILayout.BeginVertical(GUILayout.Height(26f));
            GUILayout.FlexibleSpace();
            GUILayout.Label("Scrubby zoom cursor");
            GUILayout.FlexibleSpace();
            GUILayout.EndVertical();
            if (oData.setScrubbyZoomCursor(GUILayout.Toggle(oData.scrubby_zoom_cursor, "")))
            {
                // save
                EditorUtility.SetDirty(oData);
            }
            GUILayout.EndHorizontal();
            // scrubby zoom slider
            GUILayout.BeginHorizontal();
            GUILayout.Space(width_indent);
            GUILayout.BeginVertical(GUILayout.Height(26f));
            GUILayout.FlexibleSpace();
            GUILayout.Label("Scrubby zoom slider");
            GUILayout.FlexibleSpace();
            GUILayout.EndVertical();
            if (oData.setScrubbyZoomSlider(GUILayout.Toggle(oData.scrubby_zoom_slider, "")))
            {
                // save
                EditorUtility.SetDirty(oData);
            }
            GUILayout.EndHorizontal();
            // show warning for lost references

            /*GUILayout.BeginHorizontal();
             *      GUILayout.Space(width_indent);
             *      GUILayout.BeginVertical(GUILayout.Height(26f));
             *              GUILayout.FlexibleSpace();
             *              GUILayout.Label ("Show warning for lost references");
             *              GUILayout.FlexibleSpace();
             *      GUILayout.EndVertical();
             *      if(oData.setShowWarningForLostReferences(GUILayout.Toggle(oData.showWarningForLostReferences,""))) {
             *              // save
             *              EditorUtility.SetDirty(oData);
             *      }
             * GUILayout.EndHorizontal();*/
            // ignore minimum window size warning
            GUILayout.BeginHorizontal();
            GUILayout.Space(width_indent);
            GUILayout.BeginVertical(GUILayout.Height(26f));
            GUILayout.FlexibleSpace();
            GUILayout.Label("Ignore minimum window size warning");
            GUILayout.FlexibleSpace();
            GUILayout.EndVertical();
            if (oData.setIgnoreMinimumSizeWarning(GUILayout.Toggle(oData.ignoreMinSize, "")))
            {
                // save
                EditorUtility.SetDirty(oData);
            }
            GUILayout.EndHorizontal();
            // show frames for collapsed tracks
            GUILayout.BeginHorizontal();
            GUILayout.Space(width_indent);
            GUILayout.BeginVertical(GUILayout.Height(26f));
            GUILayout.FlexibleSpace();
            GUILayout.Label("Show frames for collapsed tracks");
            GUILayout.FlexibleSpace();
            GUILayout.EndVertical();
            if (oData.setShowFramesForCollapsedTracks(GUILayout.Toggle(oData.showFramesForCollapsedTracks, "")))
            {
                // save
                EditorUtility.SetDirty(oData);
            }
            GUILayout.EndHorizontal();
            // disable timeline actions
            GUILayout.BeginHorizontal();
            GUILayout.Space(width_indent);
            GUILayout.BeginVertical(GUILayout.Height(26f));
            GUILayout.FlexibleSpace();
            GUILayout.Label("Hide Timeline Actions (May increase editor performance)");
            GUILayout.FlexibleSpace();
            GUILayout.EndVertical();
            if (oData.setDisableTimelineActions(GUILayout.Toggle(oData.disableTimelineActions, "")))
            {
                // save
                EditorUtility.SetDirty(oData);
                AMTimeline.recalculateNumFramesToRender();
            }
            GUILayout.EndHorizontal();
            // disable timeline actions tooltip
            if (oData.disableTimelineActions)
            {
                GUI.enabled = false;
            }
            GUILayout.BeginHorizontal();
            GUILayout.Space(width_indent);
            GUILayout.BeginVertical(GUILayout.Height(26f));
            GUILayout.FlexibleSpace();
            GUILayout.Label("Enable Timeline Actions tooltip");
            GUILayout.FlexibleSpace();
            GUILayout.EndVertical();
            if (oData.disableTimelineActions)
            {
                GUILayout.Toggle(false, "");
            }
            else
            {
                if (oData.setDisableTimelineActionsTooltip(!GUILayout.Toggle(!oData.disableTimelineActionsTooltip, "")))
                {
                    // save
                    EditorUtility.SetDirty(oData);
                }
            }
            GUILayout.EndHorizontal();
            GUI.enabled = true;
            // skin
            GUILayout.BeginHorizontal();
            GUILayout.Space(width_indent);
            GUILayout.BeginVertical(GUILayout.Height(26f));
            GUILayout.Space(1f);
            GUILayout.Label("Skin");
            GUILayout.FlexibleSpace();
            GUILayout.EndVertical();
            skinIndex = EditorGUILayout.Popup(skinIndex, skin_names, GUILayout.Width(200f));
            if (oData.setSkin(skin_ids[skinIndex]))
            {
                //if(playOnStartIndex == 0) aData.playOnStart = null;
                //else aData.playOnStart = aData.getTake(takeNames[playOnStartIndex-1]);
            }
            GUILayout.EndHorizontal();
        }
        #endregion
        #region quick add
        else if (tabIndex == (int)tabType.QuickAdd)
        {
            EditorGUIUtility.LookLikeControls();
            GUILayout.Space(3f);
            GUILayout.BeginHorizontal();
            GUILayout.Space(width_indent);
            GUILayout.Label("Combinations");
            GUILayout.EndHorizontal();
            if (oData.quickAdd_Combos == null)
            {
                oData.quickAdd_Combos = new List <List <int> >();
            }
            for (int j = 0; j < oData.quickAdd_Combos.Count; j++)
            {
                GUILayout.Space(3f);
                GUILayout.BeginHorizontal();
                GUILayout.Space(width_indent);
                for (int i = 0; i < oData.quickAdd_Combos[j].Count; i++)
                {
                    if (oData.setQuickAddCombo(j, i, EditorGUILayout.Popup(oData.quickAdd_Combos[j][i], AMTimeline.TrackNames, GUILayout.Width(80f))))
                    {
                        oData.flatten_quickAdd_Combos();
                        EditorUtility.SetDirty(oData);
                    }
                    if (i < oData.quickAdd_Combos[j].Count - 1)
                    {
                        GUILayout.Label("+");
                    }
                }
                GUILayout.FlexibleSpace();
                if (oData.quickAdd_Combos[j].Count > 0)
                {
                    if (GUILayout.Button("-", GUILayout.Width(20f), GUILayout.Height(20f)))
                    {
                        oData.quickAdd_Combos[j].RemoveAt(oData.quickAdd_Combos[j].Count - 1);
                        if (oData.quickAdd_Combos[j].Count == 0)
                        {
                            oData.quickAdd_Combos.RemoveAt(j);
                            j--;
                        }
                        oData.flatten_quickAdd_Combos();
                        EditorUtility.SetDirty(oData);
                    }
                }
                if (GUILayout.Button("+", GUILayout.Width(20f), GUILayout.Height(20f)))
                {
                    oData.quickAdd_Combos[j].Add((int)AMTimeline.Track.Translation);
                    oData.flatten_quickAdd_Combos();
                    EditorUtility.SetDirty(oData);
                }
                GUILayout.EndHorizontal();
            }
            GUILayout.Space(3f);
            GUILayout.BeginHorizontal();
            if (oData.quickAdd_Combos.Count <= 0)
            {
                GUILayout.Space(width_indent);
                GUILayout.Label("Click '+' to add a new combination");
            }
            GUILayout.FlexibleSpace();
            // new combo
            if (GUILayout.Button("+", GUILayout.Width(20f), GUILayout.Height(20f)))
            {
                oData.quickAdd_Combos.Add(new List <int> {
                    (int)AMTimeline.Track.Translation
                });
                oData.flatten_quickAdd_Combos();
                EditorUtility.SetDirty(oData);
            }
            GUILayout.EndHorizontal();
        }
        #endregion
        #region import / export
        else if (tabIndex == (int)tabType.ImportExport)
        {
            GUIStyle labelRight = new GUIStyle(GUI.skin.label);
            labelRight.alignment = TextAnchor.MiddleRight;
            GUILayout.Space(10f);
            GUILayout.BeginHorizontal(GUILayout.Width(300f));
            GUILayout.Space(width_indent);
            GUILayout.BeginVertical();
            GUILayout.Space(1f);
            GUILayout.Label("Take(s):", labelRight, GUILayout.Width(55f));
            GUILayout.EndVertical();
            GUILayout.BeginVertical();
            GUILayout.Space(1f);
            if (GUILayout.Button("Import", GUILayout.Width(60f)))
            {
                AMTimeline.registerUndo("Import Take(s)");
                string importTakesPath = EditorUtility.OpenFilePanel("Import Take(s)", "Assets/", "unity");
                if (importTakesPath != "")
                {
                    AMTakeImport.openAdditiveAndDeDupe(importTakesPath);
                }
            }
            GUILayout.EndVertical();
            GUILayout.BeginVertical();
            GUILayout.Space(1f);
            if (GUILayout.Button("Export:", GUILayout.Width(60f)))
            {
                if (!exportAllTakes)
                {
                    AMTakeExport.take = aData.getTake(takeNames[exportTakeIndex]);
                }
                else
                {
                    AMTakeExport.take = null;
                }
                //AMTakeExport.aData = aData;
                //EditorWindow.GetWindow (typeof (AMTakeExport)).ShowUtility();
                EditorWindow windowExport = ScriptableObject.CreateInstance <AMTakeExport>();
                windowExport.ShowUtility();
            }
            GUILayout.EndVertical();
            GUILayout.BeginVertical();
            exportAllTakes = (GUILayout.Toggle(!exportAllTakes, "") ? false : exportAllTakes);
            GUILayout.EndVertical();
            GUILayout.BeginVertical();
            GUILayout.Space(4f);
            setExportTakeIndex(EditorGUILayout.Popup(exportTakeIndex, takeNames.ToArray(), GUILayout.Width(100f)));
            GUILayout.EndVertical();
            GUILayout.BeginVertical();
            exportAllTakes = (GUILayout.Toggle(exportAllTakes, "") ? true : exportAllTakes);
            GUILayout.EndVertical();
            GUILayout.BeginVertical();
            GUILayout.Space(2f);
            GUILayout.Label("All Takes");
            GUILayout.EndVertical();

            GUILayout.EndHorizontal();
            GUILayout.Space(3f);
            GUILayout.BeginHorizontal();
            GUILayout.Space(width_indent);
            GUILayout.Label("Options:", labelRight, GUILayout.Width(55f));
            if (GUILayout.Button("Import", GUILayout.Width(60f)))
            {
                AMTimeline.registerUndo("Import Options");
                string importOptionsPath = EditorUtility.OpenFilePanel("Import Options", "Assets/Animator", "unitypackage");
                if (importOptionsPath != "")
                {
                    AssetDatabase.ImportPackage(importOptionsPath, true);
                    this.Close();
                }
            }
            if (GUILayout.Button("Export", GUILayout.Width(60f)))
            {
                AMOptionsFile.export();
            }
            GUILayout.EndHorizontal();
        }
        #endregion
        #region about
        else if (tabIndex == (int)tabType.About)
        {
            GUILayout.Space(3f);

            string message = "Animator v" + version + ", Created by Abdulla Ameen (c) 2012.\nAMTween is derived from Bob Berkebile's iTween which falls under the MIT license.\n\nPlease have a look at the documentation if you need help, or e-mail [email protected] for further assistance.";
            message += "\n\nAdditional code contributions by:\nQuick Fingers, Eric Haines";
            GUIStyle styleInfo = new GUIStyle(GUI.skin.label);
            GUILayout.BeginHorizontal();
            GUILayout.Space(5);
            styleInfo.wordWrap = true;
            GUILayout.Label(message, styleInfo);
            GUILayout.EndHorizontal();
        }
        #endregion
        GUILayout.EndScrollView();
        GUILayout.EndVertical();
        #endregion
        GUILayout.EndHorizontal();
    }