protected override void OnRotateToolWindowGUI(CardinalPathWithRotation path)
            {
                EditorGUILayout.LabelField("Rotation", EditorStyles.centeredGreyMiniLabel);

                using (var scope = new ChangeCheckScope(path))
                {
                    using (new LabelWidthScope(EditorGUIUtility.singleLineHeight))
                    {
                        Vector3 eulerAngles = default(Vector3);
                        bool lookTangent = true;
                        eulerAngles = path.GetNodeRatation(selectedNode, Space.Self).eulerAngles;
                        lookTangent = path.IsNodeLookTangent(selectedNode);

                        eulerAngles.x = EditorGUILayout.FloatField("X", eulerAngles.x);
                        eulerAngles.y = EditorGUILayout.FloatField("Y", eulerAngles.y);
                        eulerAngles.z = EditorGUILayout.FloatField("Z", eulerAngles.z);
                        lookTangent = EditorGUIKit.IndentedToggleButton("Look Tangent", lookTangent);

                        if (scope.changed)
                        {
                            path.SetNodeRatation(selectedNode, Quaternion.Euler(eulerAngles), Space.Self);
                            path.SetNodeLookTangent(selectedNode, lookTangent);
                        }
                    }
                }
            }
        protected static void FromToFieldLayout(string label, ref float from, ref float to, out bool fromChanged, out bool toChanged)
        {
            var   rect       = EditorGUILayout.GetControlRect();
            float labelWidth = EditorGUIUtility.labelWidth;

            var fromRect = new Rect(rect.x + labelWidth, rect.y, (rect.width - labelWidth) / 2 - 2, rect.height);
            var toRect   = new Rect(rect.xMax - fromRect.width, fromRect.y, fromRect.width, fromRect.height);

            rect.width = labelWidth - 8;

            var content = EditorGUIKit.TempContent(label);

            EditorGUI.LabelField(rect, content);

            rect.width = EditorStyles.label.CalcSize(content).x;
            float delta = EditorGUIKit.DragValue(rect, 0, 0.01f);

            using (new LabelWidthScope(14))
            {
                float newFrom = EditorGUI.FloatField(fromRect, "F", from + delta);
                float newTo   = EditorGUI.FloatField(toRect, "T", to + delta);

                fromChanged = from != newFrom;
                from        = newFrom;

                toChanged = to != newTo;
                to        = newTo;
            }
        }
            public override void OnInspectorGUI()
            {
                if (target._target == null) target._target = target.GetComponent<UIText>();

                if (target._target.text.Trim().Length != target._target.text.Length)
                {
                    EditorGUILayout.Space();
                    using (new GUIColorScope(new Color(1, 0.5f, 0.5f)))
                    {
                        if (EditorGUIKit.IndentedButton("Trim Text Name"))
                        {
                            Undo.RecordObject(target._target, "Trim Text Name");
                            target._target.text = target._target.text.Trim();

                            // force update UIText
                            if (target._target.enabled)
                            {
                                target._target.enabled = false;
                                target._target.enabled = true;
                            }
                        }
                    }

                    EditorGUILayout.Space();
                }

                base.OnInspectorGUI();
            }
            protected override void OnMoveToolWindowGUI(T path)
            {
                string label = _selectedType == 0 ? "Position" : (_selectedType == 1 ? "Forward Ctrl-point" : "Back Ctrl-point");

                EditorGUILayout.LabelField(label, EditorStyles.centeredGreyMiniLabel);

                using (var scope = new ChangeCheckScope(path))
                {
                    Vector3 point;

                    if (_selectedType == -1)
                    {
                        point = path.GetNodeBackControlPoint(selectedNode, Space.Self);
                    }
                    else if (_selectedType == 0)
                    {
                        point = path.GetNodePosition(selectedNode, Space.Self);
                    }
                    else
                    {
                        point = path.GetNodeForwardControlPoint(selectedNode, Space.Self);
                    }

                    using (new LabelWidthScope(EditorGUIUtility.singleLineHeight))
                    {
                        point.x = EditorGUILayout.FloatField("X", point.x);
                        point.y = EditorGUILayout.FloatField("Y", point.y);
                        point.z = EditorGUILayout.FloatField("Z", point.z);
                    }

                    if (scope.changed)
                    {
                        if (_selectedType == -1)
                        {
                            path.SetNodeBackControlPoint(selectedNode, point, Space.Self);
                        }
                        else if (_selectedType == 0)
                        {
                            path.SetNodePosition(selectedNode, point, Space.Self);
                        }
                        else
                        {
                            path.SetNodeForwardControlPoint(selectedNode, point, Space.Self);
                        }
                    }
                }

                using (var scope = new ChangeCheckScope(path))
                {
                    using (new LabelWidthScope(EditorGUIUtility.singleLineHeight))
                    {
                        bool broken = EditorGUIKit.IndentedToggleButton("Broken", path.IsNodeBroken(selectedNode));
                        if (scope.changed)
                        {
                            path.SetNodeBroken(selectedNode, broken);
                        }
                    }
                }
            }
            public override void OnInspectorGUI()
            {
                base.OnInspectorGUI();

                var path = target as CardinalPathWithRotation;

                using (var scope = new ChangeCheckScope(path))
                {
                    bool value = EditorGUIKit.IndentedToggleButton("Preview Rotation", path._previewRotation);
                    if (scope.changed) path._previewRotation = value;
                }
            }
示例#6
0
            protected override void OnPropertiesGUI(Tween tween)
            {
                EditorGUILayout.Space();

                EditorGUILayout.PropertyField(_useGradientProp);

                if (target.useGradient)
                {
                    var rect = EditorGUILayout.GetControlRect();
                    var rect2 = rect;

                    rect.width = rect.height + EditorStyles.label.CalcSize(EditorGUIKit.TempContent("RGB")).x;
                    _toggleRGBProp.boolValue = EditorGUI.ToggleLeft(rect, "RGB", _toggleRGBProp.boolValue);

                    rect.x = rect.xMax + rect.height;
                    rect.width = rect.height + EditorStyles.label.CalcSize(EditorGUIKit.TempContent("A")).x;
                    _toggleAlphaProp.boolValue = EditorGUI.ToggleLeft(rect, "A", _toggleAlphaProp.boolValue);

                    using (new DisabledScope(!target.toggleRGB && !target.toggleAlpha))
                    {
                        rect2.xMin += EditorGUIUtility.labelWidth;
                        EditorGUI.PropertyField(rect2, _gradientProp, GUIContent.none);
                    }
                }
                else
                {
                    var rect = EditorGUILayout.GetControlRect();
                    float labelWidth = EditorGUIUtility.labelWidth;

                    var fromRect = new Rect(rect.x + labelWidth, rect.y, (rect.width - labelWidth) / 2 - 2, rect.height);
                    var toRect = new Rect(rect.xMax - fromRect.width, fromRect.y, fromRect.width, fromRect.height);
                    rect.width = labelWidth - 8;

                    _toggleRGBProp.boolValue = EditorGUI.ToggleLeft(rect, "RGB", _toggleRGBProp.boolValue);

                    using (new DisabledScope(!target.toggleRGB))
                    {
                        using (new LabelWidthScope(14))
                        {
                            _fromProp.colorValue = EditorGUI.ColorField(fromRect, EditorGUIKit.TempContent("F"), _fromProp.colorValue, false, false, hdr);
                            _toProp.colorValue = EditorGUI.ColorField(toRect, EditorGUIKit.TempContent("T"), _toProp.colorValue, false, false, hdr);
                        }
                    }

                    FromToFieldLayout("A", _fromAProp, _toAProp, _toggleAlphaProp);
                }
            }
            protected override void OnPropertiesGUI(Tween tween)
            {
                EditorGUILayout.Space();

                EditorGUILayout.PropertyField(_targetRendererProp);

                int materialCount = target.GetMaterials();
                DrawMaterialMask(materialCount);
                DrawProperty(materialCount);

                EditorGUILayout.Space();

                switch (target.propertyType)
                {
                    case Type.Float:
                    case Type.Range:
                        FromToFieldLayout("Value", _fromXProp, _toXProp);
                        break;

                    case Type.Vector:
                        FromToFieldLayout("X", _fromXProp, _toXProp);
                        FromToFieldLayout("Y", _fromYProp, _toYProp);
                        FromToFieldLayout("Z", _fromZProp, _toZProp);
                        FromToFieldLayout("W", _fromWProp, _toWProp);
                        break;

                    case Type.Color:
                        var rect = EditorGUILayout.GetControlRect();
                        float labelWidth = EditorGUIUtility.labelWidth;

                        var fromRect = new Rect(rect.x + labelWidth, rect.y, (rect.width - labelWidth) / 2 - 2, rect.height);
                        var toRect = new Rect(rect.xMax - fromRect.width, fromRect.y, fromRect.width, fromRect.height);
                        rect.width = labelWidth - 8;

                        EditorGUI.LabelField(rect, "Color");

                        using (new LabelWidthScope(14))
                        {
                            _fromProp.vector4Value = EditorGUI.ColorField(fromRect, EditorGUIKit.TempContent("F"), _fromProp.vector4Value, false, true, true);
                            _toProp.vector4Value = EditorGUI.ColorField(toRect, EditorGUIKit.TempContent("T"), _toProp.vector4Value, false, true, true);
                        }
                        break;
                }
            }
            void ShowAddMenu(Rect rect)
            {
                if (_addMenu == null)
                {
                    _addMenu = EditorGUIKit.CreateMenu(
                        TweenAnimation.allTypes.Keys,
                        t => new GUIContent(TweenAnimation.allTypes[t].menu),
                        t => MenuItemState.Normal,
                        t =>
                    {
                        var cmpt = Undo.AddComponent(target.gameObject, t) as TweenAnimation;
                        Undo.RecordObject(cmpt, "AddComponent");
                        cmpt.Reset();

                        Undo.RecordObject(target, "AddComponent");
                        target.AddAnimationInternal(cmpt);
                    });
                }

                _addMenu.DropDown(rect);
            }
            void DrawProperty(int materialCount)
            {
                var rect = EditorGUILayout.GetControlRect();
                rect = EditorGUI.PrefixLabel(rect, EditorGUIKit.TempContent("Property"));

                if (!string.IsNullOrEmpty(target.propertyName))
                {
                    _builder.Append(target.propertyName);
                    _builder.Append(" (");
                    _builder.Append(target._propertyType);
                    _builder.Append(')');
                }

                if (GUI.Button(rect, _builder.ToString(), EditorStyles.layerMaskField))
                {
                    var properties = new HashSet<Property>();
                    var menu = new GenericMenu();

                    for (int i = 0; i < materialCount; i++)
                    {
                        if (target.IsMaterialSelected(i) && _materials[i] && _materials[i].shader)
                        {
                            var shader = _materials[i].shader;
                            int count = ShaderUtil.GetPropertyCount(shader);

                            for (int idx = 0; idx < count; idx++)
                            {
                                if (!ShaderUtil.IsShaderPropertyHidden(shader, idx))
                                {
                                    var prop = new Property
                                    {
                                        name = ShaderUtil.GetPropertyName(shader, idx),
                                        type = ShaderUtil.GetPropertyType(shader, idx)
                                    };

                                    if (properties.Contains(prop)) continue;
                                    properties.Add(prop);

                                    string description = ShaderUtil.GetPropertyDescription(shader, idx);

                                    if (prop.type == ShaderUtil.ShaderPropertyType.TexEnv)
                                    {
                                        prop.name += "_ST";
                                        prop.type = ShaderUtil.ShaderPropertyType.Vector;
                                        description += " Scale and Offest";
                                    }

                                    _builder.Clear();
                                    _builder.Append(prop.name);
                                    _builder.Append(" (\"");
                                    _builder.Append(description);
                                    _builder.Append("\", ");
                                    _builder.Append(prop.type);
                                    _builder.Append(')');

                                    menu.AddItem(new GUIContent(_builder.ToString()),
                                        target._propertyName == prop.name && target._propertyType == (Type)(int)prop.type,
                                        () =>
                                        {
                                            Undo.RecordObject(target, "Select Property");
                                            Type oldType = target.propertyType;
                                            target.SetProperty(prop.name, (Type)(int)prop.type);

                                            if (oldType != target.propertyType)
                                            {
                                                if (target.propertyType == Type.Color)
                                                    target.from = target.to = Color.white;

                                                if (target.propertyType == Type.Float || target.propertyType == Type.Range)
                                                    target.from.x = target.to.x = 1f;

                                                if (target.propertyType == Type.Vector)
                                                {
                                                    if (prop.name.EndsWith("_ST"))
                                                        target.from = target.to = new Vector4(1, 1, 0, 0);
                                                    else
                                                        target.from = target.to = new Vector4(1, 1, 1, 1);
                                                }
                                            }
                                        });

                                    _builder.Clear();
                                }
                            }
                        }
                    }

                    if (properties.Count == 0) menu.AddItem(new GUIContent("(No Valid Property)"), false, () => { });

                    menu.DropDown(rect);
                }

                _builder.Clear();
            }
            void DrawMaterialMask(int materialCount)
            {
                int count = 0;

                if (target.allMaterialSelected) _builder.Append("All (Apply to Renderer)");
                else if (target.noneMaterialSelected) _builder.Append("None");
                else
                {
                    for (int i = 0; i < materialCount; i++)
                    {
                        if (target.IsMaterialSelected(i))
                        {
                            count++;

                            if (count > 1)
                            {
                                _builder.Append(", ");
                                if (count == 4)
                                {
                                    _builder.Append("...");
                                    break;
                                }
                            }

                            _builder.Append(i);
                            _builder.Append(": ");
                            _builder.Append(_materials[i] ? _materials[i].name : "(None)");
                        }
                    }
                }

                var rect = EditorGUILayout.GetControlRect();
                rect = EditorGUI.PrefixLabel(rect, EditorGUIKit.TempContent("Materials"));

                if (GUI.Button(rect, _builder.ToString(), EditorStyles.layerMaskField))
                {
                    GenericMenu menu = new GenericMenu();

                    menu.AddItem(new GUIContent("All (Apply to Renderer)"), target.allMaterialSelected, () =>
                    {
                        Undo.RecordObject(target, "Select Material");
                        target.SelectAllMaterials();
                    });

                    menu.AddItem(new GUIContent("None"), target.noneMaterialSelected, () =>
                    {
                        Undo.RecordObject(target, "Select Material");
                        target.DeselectAllMaterials();
                    });

                    if (materialCount > 0) menu.AddSeparator(string.Empty);

                    for (int i = 0; i < materialCount; i++)
                    {
                        int index = i;

                        menu.AddItem(new GUIContent(index + ": " + (_materials[index] ? _materials[index].name : "(None)")),
                            target.IsMaterialSelected(index),
                            () =>
                            {
                                Undo.RecordObject(target, "Select Material");
                                target.SetMaterialSelected(index, !target.IsMaterialSelected(index));
                            });
                    }

                    menu.DropDown(rect);
                }

                _builder.Clear();
            }
示例#11
0
            public override void OnInspectorGUI()
            {
                // Edit Button

                var rect = EditorGUILayout.GetControlRect(true, 23);

                rect.x    += EditorGUIUtility.labelWidth;
                rect.width = 33;

                using (var scope = new ChangeCheckScope(null))
                {
                    bool edit = GUI.Toggle(rect, FloatingWindow.target == target, EditorGUIUtility.IconContent("EditCollider"), EditorGUIKit.buttonStyle);
                    rect.x     = rect.xMax + 5;
                    rect.width = 140;
                    EditorGUI.LabelField(rect, "Edit Path", EditorGUIKit.middleLeftLabelStyle);
                    if (scope.changed)
                    {
                        FloatingWindow.target = edit ? target : null;
                    }
                }

                // circular

                using (var scope = new ChangeCheckScope(target))
                {
                    bool circular = EditorGUILayout.Toggle("Circular", target.circular);
                    if (scope.changed)
                    {
                        target.circular = circular;
                    }
                }

                // World Scale

                using (var scope = new ChangeCheckScope(target))
                {
                    float value = EditorGUILayout.FloatField(
                        EditorGUIKit.TempContent("World Scale", null, "Use \"World Scale\" to scale the path instead of scales of transform."),
                        target.worldScale);
                    if (scope.changed)
                    {
                        target.worldScale = value;
                    }
                }

                // Length Error

                using (var scope = new ChangeCheckScope(target))
                {
                    float value = EditorGUILayout.FloatField("Length Error", target.lengthError);
                    if (scope.changed)
                    {
                        target.lengthError = value;
                    }
                }

                // Length

                if (target.isSamplesValid)
                {
                    EditorGUILayout.FloatField("Length", target.length);
                }
                else
                {
                    rect = EditorGUILayout.GetControlRect();
                    EditorGUI.LabelField(rect, "Length");
                    rect.xMin += EditorGUIUtility.labelWidth;

                    // Calculate Button

                    if (GUI.Button(rect, "Calculate", EditorStyles.miniButton))
                    {
                        Undo.RecordObject(target, "Calculate");
                        target.ValidateSamples();
                    }
                }

                // Visible

                using (var scope = new ChangeCheckScope(target))
                {
                    bool value = EditorGUIKit.IndentedToggleButton("Always Visible", target._alwaysVisible);
                    if (scope.changed)
                    {
                        target._alwaysVisible = value;
                    }
                }
            }
示例#12
0
            void OnGUI()
            {
                var path = target;

                if (path)
                {
                    selectedNode = Mathf.Clamp(selectedNode, 0, path.nodeCount - 1);

                    EditorGUILayout.LabelField("Tools", EditorStyles.centeredGreyMiniLabel);

                    using (new GUIContentColorScope(EditorGUIKit.defaultTextColor))
                    {
                        var rect = EditorGUILayout.GetControlRect(false, 25);

                        rect.width /= 3;
                        if (GUI.Toggle(rect, selectedTool == 0,
                                       EditorGUIKit.TempContent(null, EditorAsset.instance.moveToolPan, "Pan Move Tool"),
                                       EditorGUIKit.buttonLeftStyle))
                        {
                            selectedTool = 0;
                        }

                        rect.x = rect.xMax;
                        if (GUI.Toggle(rect, selectedTool == 1,
                                       EditorGUIKit.TempContent(null, EditorAsset.instance.moveTool3D, "3D Move Tool"),
                                       EditorGUIKit.buttonMiddleStyle))
                        {
                            selectedTool = 1;
                        }

                        using (new DisabledScope(disableRotateTool))
                        {
                            rect.x = rect.xMax;
                            if (GUI.Toggle(rect, selectedTool == 2,
                                           EditorGUIKit.TempContent(null, EditorAsset.instance.RotateTool, "Rotate Tool"),
                                           EditorGUIKit.buttonRightStyle))
                            {
                                selectedTool = 2;
                            }
                        }

                        EditorGUILayout.GetControlRect(false, 0);

                        rect = EditorGUILayout.GetControlRect(false, 25);

                        rect.width /= 3;
                        if (GUI.Button(rect,
                                       EditorGUIKit.TempContent(null, EditorAsset.instance.addNodeBack, "Add Node Back"),
                                       EditorGUIKit.buttonLeftStyle))
                        {
                            Undo.RecordObject(path, "Add Node Back");
                            path.InsertNode(selectedNode);
                        }

                        using (new DisabledScope(path.nodeCount == 2))
                        {
                            rect.x = rect.xMax;
                            if (GUI.Button(rect,
                                           EditorGUIKit.TempContent(null, EditorAsset.instance.removeNode, "Remove Node"),
                                           EditorGUIKit.buttonMiddleStyle))
                            {
                                Undo.RecordObject(path, "Remove Node");
                                path.RemoveNode(selectedNode);
                                selectedNode = Mathf.Clamp(selectedNode - 1, 0, path.nodeCount - 1);
                            }
                        }

                        rect.x = rect.xMax;
                        if (GUI.Button(rect,
                                       EditorGUIKit.TempContent(null, EditorAsset.instance.addNodeForward, "Add Node Forward"),
                                       EditorGUIKit.buttonRightStyle))
                        {
                            Undo.RecordObject(path, "Add Node Forward");
                            selectedNode++;
                            path.InsertNode(selectedNode);
                        }
                    }

                    OnWindowGUI(path);
                }
                else
                {
                    Close();
                }
            }
示例#13
0
            public override void OnInspectorGUI()
            {
                EditorGUILayout.BeginVertical(EditorStyles.helpBox);

                var rect  = EditorGUILayout.GetControlRect();
                var rect2 = rect;

                // controller foldout
                using (var scope = new ChangeCheckScope(target))
                {
                    rect2.width = rect2.height;
                    var result = GUI.Toggle(rect2, target._foldoutController, GUIContent.none, EditorStyles.foldout);
                    if (scope.changed)
                    {
                        target._foldoutController = result;
                    }
                }

                // controller label
                rect.xMin = rect2.xMax;
                EditorGUI.LabelField(rect, "Controller", EditorStyles.boldLabel);

                serializedObject.Update();

                // controller settings
                if (target._foldoutController)
                {
                    EditorGUILayout.PropertyField(_durationProp);
                    EditorGUILayout.PropertyField(_updateModeProp);
                    EditorGUILayout.PropertyField(_timeModeProp);
                    EditorGUILayout.PropertyField(_wrapModeProp);
                    EditorGUILayout.PropertyField(_arrivedActionProp);
                    GUILayout.Space(4);
                }

                EditorGUI.DrawRect(EditorGUILayout.GetControlRect(false, 1), EditorStyles.centeredGreyMiniLabel.normal.textColor);
                GUILayout.Space(4);

                rect  = EditorGUILayout.GetControlRect();
                rect2 = rect;

                // play button
                rect2.width = EditorGUIUtility.singleLineHeight * 2 - 4;
                using (new GUIContentColorScope(target.playing ? progressForegroundValid : EditorGUIKit.defaultTextColor))
                {
                    target.playing = GUI.Toggle(rect2, target.playing,
                                                EditorGUIKit.TempContent(image: EditorAsset.instance.play), imageButtonStyle);
                }

                // direction button
                rect2.x = rect.xMax - rect2.width;
                using (new DisabledScope(!target.playing))
                {
                    using (new GUIContentColorScope(EditorGUIKit.defaultTextColor))
                    {
                        if (GUI.Button(rect2, EditorGUIKit.TempContent(image: target.direction == PlayDirection.Forward ?
                                                                       EditorAsset.instance.rightArrow : EditorAsset.instance.leftArrow), imageButtonStyle))
                        {
                            target.ReverseDirection();
                        }
                    }
                }

                rect.xMin += EditorGUIUtility.singleLineHeight * 2;
                rect.xMax -= EditorGUIUtility.singleLineHeight * 2;

                // 鼠标开始拖动
                if (Event.current.type == EventType.MouseDown)
                {
                    if (rect.Contains(Event.current.mousePosition))
                    {
                        target.dragging = true;
                    }
                }

                // 鼠标结束拖动
                if (Event.current.rawType == EventType.MouseUp)
                {
                    if (target.dragging)
                    {
                        target.dragging = false;
                        Repaint();
                    }
                }

                // progress bar
                using (var scope = new ChangeCheckScope(null))
                {
                    float progress = EditorGUIKit.ProgressBar(rect, target._normalizedTime, progressBackgroundInvalid, progressForegroundValid);
                    if (scope.changed && target.dragging)
                    {
                        target.normalizedTime = progress;
                    }
                }

                GUILayout.Space(4);

                EditorGUILayout.EndVertical();
                GUILayout.Space(4);
                EditorGUILayout.BeginVertical(EditorStyles.helpBox);

                rect  = EditorGUILayout.GetControlRect();
                rect2 = rect;

                // events foldout
                using (var scope = new ChangeCheckScope(target))
                {
                    rect2.width = rect2.height;
                    var result = GUI.Toggle(rect2, target._foldoutEvents, GUIContent.none, EditorStyles.foldout);
                    if (scope.changed)
                    {
                        target._foldoutEvents = result;
                    }
                }

                // events label
                rect.xMin = rect2.xMax;
                EditorGUI.LabelField(rect, "Events", EditorStyles.boldLabel);

                // events
                if (target._foldoutEvents)
                {
                    EditorGUILayout.PropertyField(_onForwardArrivedProp);
                    GUILayout.Space(2);
                    EditorGUILayout.PropertyField(_onBackArrivedProp);
                    GUILayout.Space(2);
                }

                serializedObject.ApplyModifiedProperties();

                EditorGUILayout.EndVertical();
                GUILayout.Space(4);
                EditorGUILayout.BeginVertical(EditorStyles.helpBox);

                // 绘制 Animation 列表。为了正确处理各种意外情况(比如其他代码增删了列表),因此处理比较复杂 :-/
                if (!GeneralKit.IsNullOrEmpty(target._animations))
                {
                    int editorIndex = 0;
                    for (int i = 0; i < target._animations.Count; i++)
                    {
                        var anim = target._animations[i];
                        if (anim)
                        {
                            if (_editors.Count <= editorIndex)
                            {
                                _editors.Add(null);
                            }

                            if (!_editors[editorIndex] || _editors[editorIndex].target != anim)
                            {
                                GeneralKit.DestroySafely(_editors[editorIndex]);
                                _editors[editorIndex] = CreateEditor(anim);
                            }

                            (_editors[editorIndex] as TweenAnimation.Editor).OnInspectorGUI(target);
                            editorIndex++;
                        }
                        else
                        {
                            target._animations.RemoveAt(i--);
                        }
                    }
                    for (; editorIndex < _editors.Count; editorIndex++)
                    {
                        GeneralKit.DestroySafely(_editors[editorIndex]);
                        _editors.RemoveAt(editorIndex--);
                    }
                }

                // add button
                GUILayout.Space(4);
                var buttonRect = EditorGUILayout.GetControlRect();

                if (GUI.Button(buttonRect, "Add Animation...", EditorStyles.miniButton))
                {
                    ShowAddMenu(buttonRect);
                }
                GUILayout.Space(4);

                EditorGUILayout.EndVertical();
            }