Exemplo n.º 1
0
            public override void OnGUI(Rect position)
            {
                var rect       = RectHelper.Inset(position, 5.0f);
                var nameRect   = RectHelper.TakeLine(ref rect);
                var buttonRect = RectHelper.TakeTrailingHeight(ref rect, EditorGUIUtility.singleLineHeight);

                RectHelper.TakeTrailingHeight(ref rect, RectHelper.VerticalSpace);

                var isExpanded = false;

                _name       = EditorGUI.TextField(nameRect, _name);
                _definition = ValueDefinitionControl.Draw(rect, GUIContent.none, _definition, VariableInitializerType.None, null, false, ref isExpanded);

                if (GUI.Button(buttonRect, "Apply"))
                {
                    _control.ApplyDefinition(_index, _name, _definition);
                    editorWindow.Close();
                }
            }
Exemplo n.º 2
0
            public override void OnGUI(Rect rect)
            {
                rect = RectHelper.Inset(rect, _padding);

                var add     = false;
                var addRect = RectHelper.TakeTrailingWidth(ref rect, 32.0f);

                RectHelper.TakeTrailingWidth(ref rect, RectHelper.HorizontalSpace);

                using (new InvalidScope(_valid))
                {
                    using (var changes = new EditorGUI.ChangeCheckScope())
                    {
                        add = EnterField.DrawString("AddWatchVariable", rect, GUIContent.none, ref _variable);

                        if (changes.changed)
                        {
                            _valid = true;
                        }
                    }
                }

                if (GUI.Button(addRect, _addButton.Content))
                {
                    add = true;
                }

                if (add)
                {
                    _valid = Window.AddWatch(_variable);

                    if (_valid)
                    {
                        _variable = string.Empty;
                        editorWindow.Close();
                    }
                    else
                    {
                        editorWindow.Repaint();
                    }
                }
            }
Exemplo n.º 3
0
            public override void OnGUI(Rect rect)
            {
                rect = RectHelper.Inset(rect, 5.0f);
                var nameRect   = RectHelper.TakeLine(ref rect);
                var buttonRect = RectHelper.TakeTrailingHeight(ref rect, EditorGUIUtility.singleLineHeight);

                RectHelper.TakeTrailingHeight(ref rect, RectHelper.VerticalSpace);

                Name = EditorGUI.TextField(nameRect, Name);
                var valid = !string.IsNullOrEmpty(Name) && !Store.Map.ContainsKey(Name);

                using (new EditorGUI.DisabledScope(!valid))
                {
                    if (GUI.Button(buttonRect, "Add"))
                    {
                        Store.AddVariable(Name, VariableValue.Empty);
                        editorWindow.Close();
                    }
                }
            }