Exemplo n.º 1
0
        public static void Draw(Rect position, Expression expression, GUIContent label, bool fullWidth)
        {
            var errorHeight = GetErrorHeight(expression);
            var errorRect   = RectHelper.TakeTrailingHeight(ref position, errorHeight);
            var expanded    = true;

            DrawExpression(position, expression, label, fullWidth, false, ref expanded);
            DrawError(errorRect, expression, label, fullWidth);
        }
Exemplo n.º 2
0
        public static void DrawFoldout(Rect position, Expression expression, GUIContent label, ref bool isExpanded, bool fullWidth)
        {
            var errorHeight = GetErrorHeight(expression);
            var errorRect   = RectHelper.TakeTrailingHeight(ref position, errorHeight);

            DrawExpression(position, expression, label, fullWidth, true, ref isExpanded);

            if (isExpanded)
            {
                DrawError(errorRect, expression, label, fullWidth);
            }
        }
Exemplo n.º 3
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.º 4
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();
                    }
                }
            }
Exemplo n.º 5
0
        private static void DrawConstraint(Rect rect, VariableType type, bool isConstraintLocked, ref VariableConstraint constraint, bool top)
        {
            RectHelper.TakeTrailingHeight(ref rect, RectHelper.VerticalSpace);

            using (new EditorGUI.DisabledScope(isConstraintLocked))
            {
                switch (type)
                {
                case VariableType.Int:
                case VariableType.Float:
                {
                    if (top)
                    {
                        DrawIndentedLabel(ref rect, _numberConstraintLabel);
                    }
                    DrawNumberConstraint(rect, type, ref constraint);
                    break;
                }

                case VariableType.String:
                {
                    if (top)
                    {
                        DrawIndentedLabel(ref rect, _stringConstraintLabel);
                    }
                    DrawStringConstraint(rect, ref constraint);
                    break;
                }

                case VariableType.Object:
                {
                    if (top)
                    {
                        DrawIndentedLabel(ref rect, _objectConstraintLabel);
                    }
                    DrawObjectConstraint(rect, ref constraint);
                    break;
                }

                case VariableType.Enum:
                {
                    if (top)
                    {
                        DrawIndentedLabel(ref rect, _enumConstraintLabel);
                    }
                    DrawEnumConstraint(rect, ref constraint);
                    break;
                }

                case VariableType.Store:
                {
                    if (top)
                    {
                        DrawIndentedLabel(ref rect, _storeConstraintLabel);
                    }
                    DrawStoreConstraint(rect, ref constraint);
                    break;
                }

                case VariableType.List:
                {
                    if (top)
                    {
                        DrawIndentedLabel(ref rect, _listConstraintLabel);
                    }
                    DrawListConstraint(rect, ref constraint);
                    break;
                }
                }
            }
        }