Ejemplo n.º 1
0
        private static void DrawProperties(Rect rect, EditorState editor)
        {
            if (editor._foldout.faded < 0.01f)
            {
                return;
            }

            EditorGUI.BeginDisabledGroup(editor._foldout.faded < 0.2f || !editor._state.Enabled);

            const float timeFieldWidth = 54;
            var         nameFieldWidth = rect.width - timeFieldWidth * 2 - EditorConfig.Sizes.Offset * 4;

            var fieldStyle = EditorConfig.Styles.GreyMiniLabel;

            EditorLayout.PushColor();
            GUI.color *= Mathf.Clamp01(editor._foldout.faded - 0.5f) / 0.5f;

            EditorLayout.SetPosition(rect.x, rect.y + EditorConfig.Sizes.SingleLine);
            EditorLayout.Control(nameFieldWidth, r => EditorGUI.LabelField(r, ContentLabel, fieldStyle));

            EditorLayout.SetWidth(timeFieldWidth);
            EditorLayout.Control(r => EditorGUI.LabelField(r, DelayLabel, fieldStyle));
            EditorLayout.Control(r => EditorGUI.LabelField(r, DurationLabel, fieldStyle));

            EditorLayout.Space(2);
            EditorLayout.SetWidth(nameFieldWidth);
            EditorGUI.BeginDisabledGroup(editor._state.IsDefaultState);
            editor._state.Name = EditorLayout.PropertyField(editor._state.Name, InspectorStates.Record);
            EditorGUI.EndDisabledGroup();

            EditorLayout.SetWidth(timeFieldWidth);
            EditorLayout.PropertyField(ref editor._state.Delay, EditorGUI.FloatField, InspectorStates.Record);
            EditorLayout.PropertyField(ref editor._state.Duration, EditorGUI.FloatField, InspectorStates.Record);

            EditorLayout.Space(6);
            EditorLayout.SetWidth(rect.width - EditorConfig.Sizes.Offset * 2);
            EditorLayout.Control(r => editor._tweensList.DoList(r));

            EditorLayout.PullColor();

            EditorGUI.EndDisabledGroup();
        }
Ejemplo n.º 2
0
        public void DrawHeader(Rect rect, T tween)
        {
            EditorLayout.SetSize(new Vector2(rect.width, rect.height));
            EditorLayout.SetPosition(rect.x, rect.y);

            EditorGUI.BeginDisabledGroup(!tween.Component);

            EditorLayout.Control(18, r =>
            {
                var tweenEnabled = EditorGUI.ToggleLeft(r, GUIContent.none, tween.Enabled, EditorStyles.label);
                if (tweenEnabled != tween.Enabled)
                {
                    EditorActions.Add(() => tween.Enabled = tweenEnabled, InspectorStates.States);
                }
            });

            EditorGUI.EndDisabledGroup();

            EditorGUI.BeginDisabledGroup(!tween.Enabled);

            EditorLayout.Control(rect.width - EditorConfig.Sizes.Offset * 5 - 150, r =>
            {
                EditorGUI.LabelField(r, DisplayName, EditorStyles.label);
            });

            EditorLayout.Control(100, r =>
            {
                if (tween.EaseFunc != null)
                {
                    EditorEase.Draw(r, tween);
                }
                else
                {
                    EditorGUI.HelpBox(r, tween.EaseName, MessageType.Warning);
                }
            });

            EditorLayout.Control(18, r =>
            {
                if (GUI.Button(r, EditorConfig.Content.IconRecord, EditorConfig.Styles.IconButton))
                {
                    EditorActions.Add(() => Capture(tween), InspectorStates.States);
                }
            });

            EditorLayout.Control(18, r =>
            {
                if (GUI.Button(r, EditorConfig.Content.IconReturn, EditorConfig.Styles.IconButton))
                {
                    EditorActions.Add(tween.Apply, tween.Component);
                }
            });

            EditorLayout.Space(0);

            var rangeMin = tween.Range.x;
            var rangeMax = tween.Range.y;

            EditorLayout.Control(rect.width, r =>
            {
                EditorGUI.BeginChangeCheck();
                EditorGUI.MinMaxSlider(r, ref rangeMin, ref rangeMax, 0, 1);

                if (EditorGUI.EndChangeCheck())
                {
                    EditorActions.Add(() => tween.Range = new Vector2(rangeMin, rangeMax), InspectorStates.States, "tween range");
                }
            });

            EditorGUI.EndDisabledGroup();

            if (!tween.Component)
            {
                var rectWarning = new Rect(rect.x, rect.y - EditorConfig.Sizes.Offset, rect.width + EditorConfig.Sizes.Offset * 2, TotalHeight - EditorConfig.Sizes.Offset);
                EditorGUI.DrawRect(rectWarning, EditorConfig.Colors.EditorBackGrey);
                EditorGUI.HelpBox(rectWarning, $"Tween {DisplayName} require {typeof(C)} component!", MessageType.Warning);

                var rectButton = new Rect(rect.width, rect.y + rect.height - 30, 50, 20);

                return;
            }

            if (DrawValueFunc == null)
            {
                return;
            }

            EditorGUI.BeginDisabledGroup(!tween.Enabled);

            EditorLayout.Space(0);
            EditorLayout.SetWidth(rect.width);
            EditorLayout.PropertyField(ref tween.Value, DrawValueFunc, InspectorStates.Record, _content);

            EditorGUI.EndDisabledGroup();
        }
Ejemplo n.º 3
0
        private static void DrawHeader(Rect rect, EditorState editor)
        {
            var rectBackground = new Rect(rect.x, rect.y, rect.width, rect.height - 6);

            EditorGUI.DrawRect(rectBackground, EditorConfig.Colors.LightGrey);

            var rectFoldOutBack = new Rect(rect.x, rect.y, rect.width, EditorConfig.Sizes.LineHeight);

            GUI.Box(rectFoldOutBack, GUIContent.none, GUI.skin.box);

            var rectStateTabColor = new Rect(rect.x, rect.y, 2, EditorConfig.Sizes.LineHeight);
            var tabColor          = Color.gray;

            if (editor._state.IsOpenedState)
            {
                tabColor = EditorConfig.Colors.Green;
            }
            if (editor._state.IsClosedState)
            {
                tabColor = EditorConfig.Colors.Red;
            }
            EditorGUI.DrawRect(rectStateTabColor, tabColor);

            var rectToggle = new Rect(rect.x + 5, rect.y + 2, 20, EditorConfig.Sizes.SingleLine);

            if (editor._state.IsDefaultState)
            {
                EditorGUI.BeginDisabledGroup(true);
                EditorGUI.Toggle(rectToggle, GUIContent.none, true);
                EditorGUI.EndDisabledGroup();
            }
            else
            {
                editor._state.Enabled = EditorLayout.PropertyField(rectToggle, editor._state.Enabled, EditorGUI.Toggle, InspectorStates.Record);
            }

            var rectFoldout = new Rect(rect.x + 34, rect.y + 2, rect.width - 116, EditorConfig.Sizes.SingleLine);

            editor._foldout.target = EditorGUI.Foldout(rectFoldout, editor._foldout.target, new GUIContent(editor._state.Name), true, EditorConfig.Styles.Foldout);

            var rectButton = new Rect(rect.width, rect.y + 3, 24, EditorConfig.Sizes.SingleLine);

            EditorGUI.BeginDisabledGroup(editor._state.IsDefaultState);
            if (GUI.Button(rectButton, EditorConfig.Content.IconToolbarMinus, EditorConfig.Styles.PreButton))
            {
                editor.OnRemoveButton();
            }
            EditorGUI.EndDisabledGroup();



            rectButton.x -= 24;
            if (GUI.Button(rectButton, EditorConfig.Content.IconReturn, EditorConfig.Styles.IconButton))
            {
                editor._state.Apply();
            }

            rectButton.x -= 24;
            if (GUI.Button(rectButton, EditorConfig.Content.IconRecord, EditorConfig.Styles.IconButton))
            {
                EditorActions.Add(editor._state.Capture, InspectorStates.States, "Record state values");
            }
        }