public override void OnGUI(Rect position, SerializedProperty property, GUIContent label)
    {
        var Enabled         = new EditorEntry("Enabled", property.FindPropertyRelative("Enabled"));
        var IsPlayer        = new EditorEntry("Is Player", property.FindPropertyRelative("IsPlayer"));
        var Name            = new EditorEntry(property.FindPropertyRelative("Name"));
        var aiMode          = new EditorEntry("Mode", property.FindPropertyRelative("AiMoterMode"));
        var aiReaction      = new EditorEntry("Reaction", property.FindPropertyRelative("aiReaction"));
        var halfRowWidth    = position.width / 2;
        var thirdRowWidth   = position.width / 3;
        var x               = position.x;
        var playerOrAi      = IsPlayer.Property.boolValue? "Player" : "Ai";
        var playerOrAiWidth = EditorHelpers.GetStringLengthinPix(playerOrAi);

        EditorGUI.LabelField(new Rect(halfRowWidth - playerOrAiWidth, position.y, IsPlayer, singleLine), playerOrAi);
        EditorGUI.LabelField(new Rect(halfRowWidth, position.y, Enabled, singleLine), Enabled);
        EditorGUI.PropertyField(new Rect(halfRowWidth + Enabled, position.y, 10, singleLine), Enabled, GUIContent.none);

        if (IsPlayer.Property.boolValue)
        {
            EditorGUI.LabelField(new Rect(halfRowWidth + 20 + Enabled, position.y, position.width, singleLine), Name);
        }

        EditorGUI.LabelField(new Rect(x, position.y + singleLine, IsPlayer, singleLine), IsPlayer);
        x += IsPlayer;
        EditorGUI.PropertyField(new Rect(x, position.y + singleLine, thirdRowWidth - IsPlayer, singleLine), IsPlayer, GUIContent.none);
        x += thirdRowWidth - IsPlayer;
        EditorGUI.LabelField(new Rect(x, position.y + singleLine, aiMode, singleLine), aiMode);
        x += aiMode;
        EditorGUI.PropertyField(new Rect(x, position.y + singleLine, thirdRowWidth - aiMode, singleLine), aiMode, GUIContent.none);
        x += thirdRowWidth - aiMode;
        EditorGUI.LabelField(new Rect(x, position.y + singleLine, aiReaction, singleLine), aiReaction);
        x += aiReaction;
        EditorGUI.PropertyField(new Rect(x, position.y + singleLine, thirdRowWidth - aiReaction, singleLine), aiReaction, GUIContent.none);
    }
Exemple #2
0
        public void AddParameter(string name, Func <float> getValue, Action <float> setValue, float delta = 0.001f)
        {
            if (entries.Any(e => e.Name == name))
            {
                throw new InvalidOperationException($"ParameterEditor: key {name} already exists.");
            }

            // set initial index if this is the first entry
            if (!entries.Any())
            {
                selectedIndex = 0;
            }

            var a = new EditorEntry();

            a.Name       = name;
            a.GetValue   = getValue;
            a.SetValue   = setValue;
            a.Delta      = delta;
            a.IsSelected = false;
            a.LabelBlock = new TextBlock(name, "", currentPos, textSize, ColourDeselected);

            entries.Add(a);

            currentPos += offset;

            UpdateLabels();
        }
Exemple #3
0
        public override void OnGUI(Rect position, SerializedProperty prop, GUIContent label)
        {
            var property = new EditorEntry(label.text, prop);

            position.x     += 16;
            position.width -= 16;
            var pos = position;

            pos.width = position.width / MultiInLineAttribute.totalAmount;

            if (MultiInLineAttribute.index == 0)
            {
                property.Draw(pos);
                return;
            }

            pos.y     -= (singleLine + (2 * MultiInLineAttribute.index));
            pos.height = singleLine;
            pos.x     += (pos.width) * MultiInLineAttribute.index;
            if (MultiInLineAttribute.expandToWidth)
            {
                pos.width = position.width - (pos.width) * MultiInLineAttribute.index;
            }
            property.Draw(pos);
        }
 private static void ProgressBar(Rect pos, EditorEntry m_Value)
 {
     using (var horizontalScope = Disposables.RectHorizontalScope(2, pos)) {
         EditorGUI.LabelField(horizontalScope.GetNext(), ProgressBarContent);
         var value = (m_Value.Property.floatValue + 1) * 0.5f;
         FoCsGUI.ProgressBar(horizontalScope.GetNext(), value);
     }
 }
    public override void OnGUI(Rect position, SerializedProperty property, GUIContent label)
    {
        var detailsIndex  = new EditorEntry("Index", property.FindPropertyRelative("detailsIndex"));
        var input         = new EditorEntry("Input", property.FindPropertyRelative("input"));
        var halfRowWidth  = position.width / 2;
        var thirdRowWidth = position.width / 3;

        EditorGUI.LabelField(new Rect(thirdRowWidth, position.y, detailsIndex, singleLine), detailsIndex);
        EditorGUI.PropertyField(new Rect(thirdRowWidth + detailsIndex, position.y, thirdRowWidth - detailsIndex, singleLine), detailsIndex, GUIContent.none);
        EditorGUI.LabelField(new Rect(thirdRowWidth + thirdRowWidth, position.y, input, singleLine), input);
        EditorGUI.PropertyField(new Rect(thirdRowWidth + thirdRowWidth + input, position.y, thirdRowWidth - input, singleLine), input, GUIContent.none);
    }
        public override void OnGUI(Rect position, SerializedProperty property, GUIContent label)
        {
            var showLabel = ShowLabel(label.text);

            using (var propScope = Disposables.PropertyScope(position, label, property)) {
                label = propScope.content;

                if (EditorGUI.indentLevel <= 1)
                {
                    position = position.Edit(RectEdit.ChangeX(16f));
                }

                var axisProp         = property.FindPropertyRelative("Axis");
                var ValueInverted    = new EditorEntry("Invert Result", property.FindPropertyRelative("ValueInverted"));
                var OnlyButtonEvents = new EditorEntry("Only Button Events", property.FindPropertyRelative("OnlyButtonEvents"));
                var UseSmoothInput   = new EditorEntry("Use Smooth Input", property.FindPropertyRelative("UseSmoothInput"));
                var Axis             = new EditorEntry($"Axis: {axisProp.stringValue}", axisProp);

                var value = new EditorEntry($"{(ValueInverted.Property.boolValue? "Non Inverted " : "")}Value",
                                            property.FindPropertyRelative(UseSmoothInput.Property.boolValue? "valueSmooth" : "valueRaw"));

                var deadZone = new EditorEntry("DeadZone", property.FindPropertyRelative("deadZone"));

                using (var horizontalScope = Disposables.RectHorizontalScope(2, position)) {
                    using (Disposables.LabelFieldSetWidth(horizontalScope.FirstRect.width * LABEL_SIZE)) {
                        using (var verticalScope = Disposables.RectVerticalScope(showLabel? 5 : 4, horizontalScope.GetNext())) {
                            if (showLabel)
                            {
                                FoCsGUI.Label(verticalScope.GetNext(RectEdit.SetHeight(SingleLine), RectEdit.SubtractX(16f)), label);
                            }

                            DrawDropDown(Axis, verticalScope.GetNext(RectEdit.SetHeight(SingleLine)));
                            ProgressBar(verticalScope.GetNext(RectEdit.SetHeight(SingleLine)), value);
                            deadZone.Draw(verticalScope.GetNext(RectEdit.SetHeight(SingleLine)));
                            OnlyButtonEvents.Draw(verticalScope.GetNext(RectEdit.SetHeight(SingleLine)));
                        }

                        using (var verticalScope = Disposables.RectVerticalScope(showLabel? 5 : 4, horizontalScope.GetNext(RectEdit.ChangeX(SingleLine)))) {
                            if (showLabel)
                            {
                                verticalScope.GetNext();
                            }

                            Axis.Draw(verticalScope.GetNext(RectEdit.SetHeight(SingleLine)));
                            value.Draw(verticalScope.GetNext(RectEdit.SetHeight(SingleLine)));
                            ValueInverted.Draw(verticalScope.GetNext(RectEdit.SetHeight(SingleLine)));
                            UseSmoothInput.Draw(verticalScope.GetNext(RectEdit.SetHeight(SingleLine)));
                        }
                    }
                }
            }
        }
    public override void OnGUI(Rect position, SerializedProperty property, GUIContent label)
    {
        var name         = new EditorEntry("Name", property.FindPropertyRelative("name"));
        var team         = new EditorEntry("Value", property.FindPropertyRelative("team"));
        var mat          = new EditorEntry("Material", property.FindPropertyRelative("mat"));
        var halfRowWidth = position.width / 2;

        EditorGUI.LabelField(new Rect((position.x + halfRowWidth) - name, position.y, halfRowWidth / 2, singleLine), name);
        EditorGUI.PropertyField(new Rect(position.x + halfRowWidth, position.y, halfRowWidth, singleLine), name, GUIContent.none);
        EditorGUI.LabelField(new Rect(position.x, position.y + singleLine, mat, singleLine), mat);
        EditorGUI.PropertyField(new Rect(position.x + mat, position.y + singleLine, halfRowWidth - mat, singleLine), mat, GUIContent.none);
        EditorGUI.LabelField(new Rect(position.x + halfRowWidth, position.y + singleLine, halfRowWidth / 2, singleLine), team);
        EditorGUI.PropertyField(new Rect(position.x + halfRowWidth + team, position.y + singleLine, halfRowWidth - team, singleLine), team, GUIContent.none);
        property.serializedObject.ApplyModifiedProperties();
    }
    public override void OnGUI(Rect position, SerializedProperty property, GUIContent label)
    {
        var Axis          = new EditorEntry("Axis", property.FindPropertyRelative("Axis"));
        var m_Value       = new EditorEntry("Value", property.FindPropertyRelative("m_Value"));
        var ValueInverted = new EditorEntry("Inverted Resualt", property.FindPropertyRelative("ValueInverted"));
        var halfRowWidth  = position.width / 2;
        var thirdRowWidth = position.width / 3;

        EditorGUI.LabelField(new Rect((position.x + halfRowWidth) - Axis, position.y, Axis, singleLine), Axis);
        EditorGUI.PropertyField(new Rect(position.x + halfRowWidth, position.y, halfRowWidth, singleLine), Axis, GUIContent.none);
        EditorGUI.LabelField(new Rect(position.x, position.y + singleLine, m_Value, singleLine), m_Value);
        EditorGUI.PropertyField(new Rect(position.x + m_Value, position.y + singleLine, thirdRowWidth, singleLine), m_Value, GUIContent.none);
        EditorGUI.LabelField(new Rect((position.x + (thirdRowWidth * 2)) - (ValueInverted / 2), position.y + singleLine, ValueInverted, singleLine), ValueInverted);
        EditorGUI.PropertyField(new Rect(position.x + (thirdRowWidth * 2) + (ValueInverted / 2), position.y + singleLine, halfRowWidth / 2, singleLine), ValueInverted, GUIContent.none);
        property.serializedObject.ApplyModifiedProperties();
    }
    public override void OnGUI(Rect position, SerializedProperty property, GUIContent label)
    {
        var player       = new EditorEntry("Motor", property.FindPropertyRelative("_player"));
        var team         = new EditorEntry("Team", property.FindPropertyRelative("team"));
        var Scores       = new EditorEntry("Scores", property.FindPropertyRelative("Scores"));
        var BallHits     = new EditorEntry("Ball Hits", property.FindPropertyRelative("BallHits"));
        var halfRowWidth = position.width / 2;

        EditorGUI.LabelField(new Rect(position.x, position.y + singleLine, player, singleLine), player);
        EditorGUI.PropertyField(new Rect(position.x + player, position.y + singleLine, halfRowWidth - player, singleLine), player, GUIContent.none);
        EditorGUI.LabelField(new Rect(position.x + halfRowWidth, position.y + singleLine, team, singleLine), team);
        EditorGUI.PropertyField(new Rect(position.x + halfRowWidth + team, position.y + singleLine, halfRowWidth - team, singleLine), team, GUIContent.none);
        EditorGUI.LabelField(new Rect(position.x, position.y + (singleLine * 2), halfRowWidth / 2, singleLine), Scores);
        EditorGUI.PropertyField(new Rect(position.x + (halfRowWidth / 2), position.y + (singleLine * 2), halfRowWidth / 2, singleLine), Scores, GUIContent.none);
        EditorGUI.LabelField(new Rect(position.x + halfRowWidth, position.y + (singleLine * 2), halfRowWidth / 2, singleLine), BallHits);
        EditorGUI.PropertyField(new Rect(position.x + halfRowWidth + (halfRowWidth / 2), position.y + (singleLine * 2), halfRowWidth / 2, singleLine), BallHits, GUIContent.none);
    }
        public override void OnGUI(Rect position, SerializedProperty property, GUIContent label)
        {
            var ValueInverted = new EditorEntry("Invert Result", property.FindPropertyRelative("ValueInverted"));
            var Axis          = new EditorEntry(string.Format("{0} Axis", property.FindPropertyRelative("Axis").stringValue), property.FindPropertyRelative("Axis"));
            var UAxis         = new EditorEntry(string.Format("{0} Unity Axis", property.FindPropertyRelative("UnityAxis").stringValue),
                                                property.FindPropertyRelative("UnityAxis"));
            var m_Value = new EditorEntry(string.Format("{0}Value", (ValueInverted.Property.boolValue? "Non Inverted " : "")), property.FindPropertyRelative("m_Value"));

            var AxisRect = position;

            AxisRect.height = singleLine;
            Axis.Draw(AxisRect, EditorEntry.SplitType.Normal);
            AxisRect.y += singleLine;
            UAxis.Draw(AxisRect, EditorEntry.SplitType.Normal);
            AxisRect.y += singleLine;
            m_Value.Draw(AxisRect, EditorEntry.SplitType.Normal);
            AxisRect.y += singleLine;
            ValueInverted.Draw(AxisRect, EditorEntry.SplitType.Normal);
        }
Exemple #11
0
        /// <summary>
        /// Initializes the bindings for the page controls.
        /// </summary>
        void InitBindings()
        {
            CoverImage.SetBinding(Image.SourceProperty, "ImageSmall");

            SeriesNoEntry.SetBinding(Entry.TextProperty,
                                     new Binding("SeriesNumber")
            {
                Mode = BindingMode.TwoWay
            });
            SeriesNameEntry.SetBinding(Entry.TextProperty,
                                       new Binding("SeriesName")
            {
                Mode = BindingMode.TwoWay
            });
            WriterEntry.SetBinding(Entry.TextProperty,
                                   new Binding("Writer")
            {
                Mode = BindingMode.TwoWay
            });
            PencillerEntry.SetBinding(Entry.TextProperty,
                                      new Binding("Penciller")
            {
                Mode = BindingMode.TwoWay
            });
            InkerEntry.SetBinding(Entry.TextProperty,
                                  new Binding("Inker")
            {
                Mode = BindingMode.TwoWay
            });
            ColoristEntry.SetBinding(Entry.TextProperty,
                                     new Binding("Colorist")
            {
                Mode = BindingMode.TwoWay
            });
            LettererEntry.SetBinding(Entry.TextProperty,
                                     new Binding("Letterer")
            {
                Mode = BindingMode.TwoWay
            });
            EditorEntry.SetBinding(Entry.TextProperty,
                                   new Binding("Editor")
            {
                Mode = BindingMode.TwoWay
            });
            StoryTitleEntry.SetBinding(Entry.TextProperty,
                                       new Binding("StoryTitle")
            {
                Mode = BindingMode.TwoWay
            });
            CharacterEntry.SetBinding(Entry.TextProperty,
                                      new Binding("Character")
            {
                Mode = BindingMode.TwoWay
            });
            ISBNEntry.SetBinding(Entry.TextProperty,
                                 new Binding("ISBN")
            {
                Mode = BindingMode.TwoWay
            });
            BarcodeEntry.SetBinding(Entry.TextProperty,
                                    new Binding("Barcode")
            {
                Mode = BindingMode.TwoWay
            });
        }