Example #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();
        }
Example #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();
        }