Beispiel #1
0
        public static void DelayFloatField(SerializedProperty o, GUIContent _title, GUIContent _width = null)
        {
            Rect  size  = GUILayoutUtility.GetRect(_title, GUI.skin.label);
            float width = 0;

            if (_width != null)
            {
                width = GUI.skin.label.CalcSize(_width).x;
            }
            else
            {
                width = GUI.skin.label.CalcSize(_title).x;
            }
            size.x     += width + 0.5f;
            size.width -= width;
            if (o.hasMultipleDifferentValues)
            {
                EditorGUI.BeginProperty(size, new GUIContent(""), o);
                int   input = Random.Range(int.MinValue, int.MaxValue);
                float v     = EditorGUI.DelayedFloatField(size, input);
                if (v != input)
                {
                    o.floatValue = v;
                }
                EditorGUI.EndProperty();
            }
            else
            {
                o.floatValue = EditorGUI.DelayedFloatField(size, o.floatValue);
            }
            size.x -= width + 1.5f;
            EditorGUI.LabelField(size, _title);
        }
Beispiel #2
0
        public override void OnGUI(Rect position, SerializedProperty property, GUIContent label)
        {
            EditorGUI.BeginProperty(position, label, property);
            var value = property.objectReferenceValue as SharedFloatSO;

            if (value != null)
            {
                EditorGUI.BeginChangeCheck();
                float totalWidth   = position.width;
                float positionX    = position.x;
                float ElementWidth = totalWidth * 0.9f;
                EditorGUI.PropertyField(new Rect(positionX, position.y, ElementWidth, position.height), property, label, true);
                positionX   += ElementWidth;
                ElementWidth = totalWidth * 0.1f;
                var newValue = EditorGUI.DelayedFloatField(new Rect(positionX, position.y, ElementWidth, position.height), value.Value);
                if (EditorGUI.EndChangeCheck())
                {
                    value.Value = newValue;
                }
            }
            else
            {
                EditorGUI.PropertyField(position, property, label, false);
            }
            EditorGUI.EndProperty();
        }
    public override void OnGUI(Rect position, SerializedProperty property, GUIContent label)
    {
        if (property.propertyType == SerializedPropertyType.Vector2)
        {
            Vector2 range = property.vector2Value;
            float   min   = range.x;
            float   max   = range.y;
            MinMaxSliderAttribute attr = (MinMaxSliderAttribute)attribute;
            EditorGUI.BeginChangeCheck();

            Rect   context = EditorGUI.PrefixLabel(position, label);
            Rect[] cols    = context.SplitLeft(50f);
            min  = EditorGUI.DelayedFloatField(cols[0], min);
            cols = cols[1].SplitRight(50f);
            EditorGUI.MinMaxSlider(cols[0], ref min, ref max, attr.min, attr.max);
            max = EditorGUI.DelayedFloatField(cols[1], max);

            if (EditorGUI.EndChangeCheck())
            {
                range.x = min;
                range.y = max;
                property.vector2Value = range;
            }
        }
        else
        {
            EditorGUI.LabelField(position, label, "Use only with Vector2");
        }
    }
        private void DrawPoint(Rect position, SerializedProperty property)
        {
            var isReadOnlyProp = property.FindPropertyRelative(ChronoPoint.kIsReadOnlyPropName);
            var valueProp      = property.FindPropertyRelative(ChronoPoint.kValuePropName);

            bool isReadOnly = isReadOnlyProp != null
                            ? isReadOnlyProp.boolValue
                            : false;

            position.y      += kHeightReduction * 0.5f;
            position.height -= kHeightReduction;
            float valueRectWidth = position.width - kValueRectWidth - kGapWidth - kMarginWidth;
            var   valueRect      = new Rect(position)
            {
                width = kValueRectWidth,
                x     = position.x + kMarginWidth
            };
            var displayRect = new Rect(position)
            {
                width = valueRectWidth,
                x     = valueRect.x + kValueRectWidth + kGapWidth
            };

            using (var group = new EditorGUI.DisabledGroupScope(isReadOnly))
            {
                float  value        = valueProp.floatValue;
                string displayValue = GetDisplayValue(value);
                valueProp.floatValue = EditorGUI.DelayedFloatField(valueRect, GUIContent.none, value, _styles.chronoValueField);
                EditorGUI.LabelField(displayRect, displayValue);
            }
        }
Beispiel #5
0
        public override void OnGUI(Rect position, SerializedProperty property, GUIContent label)
        {
            var key      = property.FindPropertyRelative("Key");
            var value    = property.FindPropertyRelative("Value");
            var once     = property.FindPropertyRelative("Once");
            var priority = property.FindPropertyRelative("Priority");

            EditorGUI.indentLevel++;
            GUI.Box(position, "");

            float width = position.width;

            position.width  = 30;
            value.boolValue = EditorGUI.Toggle(position, "", value.boolValue);

            position.x     += position.width;
            position.width  = width - 200;
            key.stringValue = EditorGUI.DelayedTextField(position, key.stringValue);

            position.x    += position.width + 5;
            position.width = 50;
            once.boolValue = GUI.Toggle(position, once.boolValue, new GUIContent("Once", "是否是一次性目标,若是一次性,则在完成目标后移除该目标"), "ButtonMid");

            position.x    += position.width - 10;
            position.width = 120;
            float lableWidth = EditorGUIUtility.labelWidth;

            EditorGUIUtility.labelWidth = 75;
            priority.floatValue         = EditorGUI.DelayedFloatField(position, new GUIContent("Priority", "优先级,越高越先执行"), priority.floatValue);
            EditorGUIUtility.labelWidth = lableWidth;

            EditorGUI.indentLevel--;
        }
    public override void OnInspectorGUI()
    {
        serializedObject.Update();

        EditorGUILayout.BeginHorizontal();
        EditorGUILayout.PrefixLabel("HP / Max HP");
        var hpRect = GUILayoutUtility.GetRect(50, 20, EditorStyles.numberField);

        EditorGUI.DelayedFloatField(hpRect, HPprop, GUIContent.none);
        EditorGUILayout.LabelField("/", EditorStyles.miniLabel, miniButtonWidth);
        hpRect = GUILayoutUtility.GetRect(50, 20, "TextField");
        EditorGUI.DelayedFloatField(hpRect, maxHPprop.floatValue);
        EditorGUILayout.EndHorizontal();
        if (!HPprop.hasMultipleDifferentValues || !maxHPprop.hasMultipleDifferentValues)
        {
            ProgressBar(HPprop.floatValue / maxHPprop.floatValue, "HP");
        }

        RenderFieldWithButtons(ATTprop, "ATT");
        RenderFieldWithButtons(DEFprop, "DEF");

        //EditorGUILayout.PropertyField(dataProp, new GUIContent("Resistance"), true);

        RenderListUI(dataProp, "Resistance");

        serializedObject.ApplyModifiedProperties();
        //EditorGUILayout.LabelField("The HP is" + _target.HP);
        //DrawDefaultInspector();
    }
Beispiel #7
0
        private MinMax DrawMinMaxSlider(float minIn, float maxIn, float minLimit, float maxLimit, bool showDegrees = true)
        {
            //int holdindent = EditorGUI.indentLevel;

            const float input1offset = 10;
            float       inputWidth   = (holdindent < 2) ? (showDegrees ? 40f : 50f) : showDegrees ? 30f : 40f;
            float       degreeSpace  = showDegrees ? 10f : 0;
            GUIContent  lbl          = showDegrees ? new GUIContent("°") : GUIContent.none;

            //float sliderwidth = fieldwidth - inputWidth + input1offset - PADDING * 2 - degreeSpace * 2;
            float left = r.xMin;

            float input1left  = fieldleft - inputWidth - input1offset;
            float input2left  = rightinputsleft;
            float sliderleft  = fieldleft /*- input1offset + PADDING */ /*+ degreeSpace*/;            // + fieldwidth + padding;
            float sliderwidth = /*fieldwidth -*/ (input2left - fieldleft) - PADDING;

            //EditorGUI.indentLevel = 0;
            float minOut = EditorGUI.DelayedFloatField(new Rect(input1left, line, inputWidth, LINEHEIGHT), GUIContent.none, minIn, (GUIStyle)"MiniTextField");
            float maxOut = EditorGUI.DelayedFloatField(new Rect(input2left, line, inputWidth, LINEHEIGHT), GUIContent.none, maxIn, (GUIStyle)"MiniTextField");

            EditorGUI.LabelField(new Rect(input1left, line, inputWidth + degreeSpace, LINEHEIGHT), lbl, (GUIStyle)"RightLabel");
            EditorGUI.LabelField(new Rect(input2left, line, inputWidth + degreeSpace, LINEHEIGHT), lbl, (GUIStyle)"RightLabel");

            EditorGUI.MinMaxSlider(new Rect(sliderleft, line - 1, sliderwidth, LINEHEIGHT), ref minOut, ref maxOut, minLimit, maxLimit);
            //EditorGUI.indentLevel = holdindent;

            return(new MinMax()
            {
                min = minOut, max = maxOut
            });
        }
Beispiel #8
0
        private MinMax DrawMinMaxSlider(float minIn, float maxIn, float minLimit, float maxLimit, bool showDegrees = true)
        {
            const float input1offset = 10;
            float       inputWidth   = (holdindent < 2) ? (showDegrees ? 40f : 50f) : showDegrees ? 30f : 40f;
            float       degreeSpace  = showDegrees ? 10f : 0;
            GUIContent  lbl          = showDegrees ? new GUIContent("°") : GUIContent.none;

            float left = r.xMin;

            float input1left  = fieldleft - inputWidth - input1offset;
            float input2left  = rightinputsleft;
            float sliderleft  = fieldleft;
            float sliderwidth = (input2left - fieldleft) - PADDING;

            float minOut = EditorGUI.DelayedFloatField(new Rect(input1left, line, inputWidth, LINEHEIGHT), GUIContent.none, minIn, MINI_TXT_FLD_STYLE);
            float maxOut = EditorGUI.DelayedFloatField(new Rect(input2left, line, inputWidth, LINEHEIGHT), GUIContent.none, maxIn, MINI_TXT_FLD_STYLE);

            EditorGUI.LabelField(new Rect(input1left, line, inputWidth + degreeSpace, LINEHEIGHT), lbl, (GUIStyle)"RightLabel");
            EditorGUI.LabelField(new Rect(input2left, line, inputWidth + degreeSpace, LINEHEIGHT), lbl, (GUIStyle)"RightLabel");

            EditorGUI.MinMaxSlider(new Rect(sliderleft, line - 1, sliderwidth, LINEHEIGHT), ref minOut, ref maxOut, minLimit, maxLimit);

            return(new MinMax()
            {
                min = minOut, max = maxOut
            });
        }
Beispiel #9
0
        /************************************************************************************************************************/

        /// <summary>
        /// Draws controls for <see cref="AnimancerNode.FadeSpeed"/> and <see cref="AnimancerNode.TargetWeight"/>.
        /// </summary>
        private void DoFadeDetailsGUI()
        {
            var area = AnimancerGUI.LayoutSingleLineRect(AnimancerGUI.SpacingMode.Before);

            area = EditorGUI.IndentedRect(area);

            var speedLabel  = AnimancerGUI.GetNarrowText("Fade Speed");
            var targetLabel = AnimancerGUI.GetNarrowText("Target Weight");

            float speedWidth, weightWidth;
            Rect  speedRect, weightRect;

            AnimancerGUI.SplitHorizontally(area, speedLabel, targetLabel,
                                           out speedWidth, out weightWidth, out speedRect, out weightRect);

            var labelWidth  = EditorGUIUtility.labelWidth;
            var indentLevel = EditorGUI.indentLevel;

            EditorGUI.indentLevel = 0;

            EditorGUI.BeginChangeCheck();

            // Fade Speed.
            EditorGUIUtility.labelWidth = speedWidth;
            Target.FadeSpeed            = EditorGUI.DelayedFloatField(speedRect, speedLabel, Target.FadeSpeed);
            if (AnimancerGUI.TryUseClickEvent(speedRect, 2))
            {
                Target.FadeSpeed = Target.FadeSpeed != 0 ?
                                   0 :
                                   Math.Abs(Target.Weight - Target.TargetWeight) / AnimancerPlayable.DefaultFadeDuration;
            }

            // Target Weight.
            EditorGUIUtility.labelWidth = weightWidth;
            Target.TargetWeight         = EditorGUI.FloatField(weightRect, targetLabel, Target.TargetWeight);
            if (AnimancerGUI.TryUseClickEvent(weightRect, 2))
            {
                if (Target.TargetWeight != Target.Weight)
                {
                    Target.TargetWeight = Target.Weight;
                }
                else if (Target.TargetWeight != 1)
                {
                    Target.TargetWeight = 1;
                }
                else
                {
                    Target.TargetWeight = 0;
                }
            }

            if (EditorGUI.EndChangeCheck() && Target.FadeSpeed != 0)
            {
                Target.StartFade(Target.TargetWeight, 1 / Target.FadeSpeed);
            }

            EditorGUI.indentLevel       = indentLevel;
            EditorGUIUtility.labelWidth = labelWidth;
        }
Beispiel #10
0
        public override void OnGUI(Rect position, SerializedProperty property, GUIContent label)
        {
            Vec2AsRangeAttribute attr = attribute as Vec2AsRangeAttribute;

            EditorGUI.BeginProperty(position, label, property);

            Vector2 vec2 = property.vector2Value;
            float   min  = Mathf.Min(vec2.x, vec2.y);
            float   max  = Mathf.Max(vec2.x, vec2.y);

            if (attr.Slider)
            {
                var sliderRect = position;
                sliderRect.xMax -= 2 * FLOAT_WIDTH + PAD;
                position.xMin    = position.xMax - 2 * FLOAT_WIDTH;
                EditorGUI.MinMaxSlider(sliderRect, label, ref min, ref max, attr.LowerBound, attr.UpperBound);

                var mid   = position.x + position.width / 2;
                var rectA = position;
                rectA.xMax = mid;
                min        = EditorGUI.DelayedFloatField(rectA, GUIContent.none, min);
                var rectB = position;
                rectB.xMin = mid;
                if (!attr.HideMax)
                {
                    max = EditorGUI.DelayedFloatField(rectB, GUIContent.none, max);
                }
            }
            else
            {
                position = EditorGUI.PrefixLabel(position, GUIUtility.GetControlID(FocusType.Passive), label);

                var mid = position.x + position.width / 2;
                EditorGUIUtility.labelWidth = SOLO_LABEL_WIDTH;
                var rectA = position;
                rectA.xMax = mid;
                min        = EditorGUI.DelayedFloatField(rectA, "min", min);
                var rectB = position;
                rectB.xMin = mid;
                if (!attr.HideMax)
                {
                    max = EditorGUI.DelayedFloatField(rectB, "max", max);
                }

                EditorGUIUtility.labelWidth = 0;
            }

            Vector2 newVec2 = new Vector2(min, max);

            if (newVec2 != vec2)
            {
                property.vector2Value = newVec2;
            }

            EditorGUI.EndProperty();
        }
Beispiel #11
0
    public override void OnGUI(Rect position, SerializedProperty property, GUIContent label)
    {
        EditorGUI.BeginProperty(position, label, property);

        EditorGUI.indentLevel = 0;
        position = EditorGUI.PrefixLabel(position, GUIUtility.GetControlID(FocusType.Passive), new GUIContent("Biome mapping"));

        Undo.RecordObject(property.serializedObject.targetObject, "name");

        EditorGUI.BeginChangeCheck();

        float[]            rectWidthPercents     = new float[] { 0.0f, 0.1f, 0.2f, 0.3f, 0.5f, 0.6f, 0.8f, 1.0f };
        string[]           propertyNames         = new string[] { "m_originClass", "m_targetClass", "m_failClass", "m_predicateType", "m_predicatePerlinScale", "m_predicateThresholdA", "m_predicateThresholdB" };
        Rect[]             rects                 = new Rect[rectWidthPercents.Length - 1];
        SerializedProperty predciateTypeProperty = property.FindPropertyRelative(propertyNames[3]);
        bool isPerlinBlend = !HeightmapBiomeFilter.IsBlendedExterior(predciateTypeProperty.intValue);

        for (int i = 0; i < rects.Length; i++)
        {
            // for perlin blend function, skip drawing m_predicateThresholdA and m_predicateThresholdB. Just draw m_predicatePerlinScale
            if (i > 4 && !isPerlinBlend)
            {
                continue;
            }

            float rectStartX = position.x + position.width * rectWidthPercents[i];
            float rectWidth  = position.width * (rectWidthPercents[i + 1] - rectWidthPercents[i]);
            rects[i] = new Rect(rectStartX, position.y, rectWidth, position.height);

            SerializedProperty propertyI = property.FindPropertyRelative(propertyNames[i]);

            switch (i)
            {
            default:
            case 0:
            case 1:
            case 2:
                propertyI.intValue = EditorGUI.DelayedIntField(rects[i], propertyI.intValue);
                break;

            case 3:
                propertyI.intValue = EditorGUI.Popup(rects[i], propertyI.intValue, HeightmapBiomeFilter.predicateTypes);
                break;

            case 4:
            case 5:
            case 6:
                propertyI.floatValue = EditorGUI.DelayedFloatField(rects[i], propertyI.floatValue);
                break;
            }
        }

        EditorGUI.EndProperty();

        property.serializedObject.ApplyModifiedProperties();
    }
Beispiel #12
0
    public void DelayedFloatField()
    {
        EditorGUI.BeginChangeCheck();
        float num = EditorGUI.DelayedFloatField(rect, guiContent.text, serializedProperty.floatValue);

        if (EditorGUI.EndChangeCheck())
        {
            serializedProperty.floatValue = num;
        }
    }
 void DrawDelayedFloatProperty(MaterialProperty prop, GUIContent content)
 {
     Rect position = EditorGUILayout.GetControlRect();
     EditorGUI.BeginChangeCheck();
     EditorGUI.showMixedValue = prop.hasMixedValue;
     float newValue = EditorGUI.DelayedFloatField(position, content, prop.floatValue);
     EditorGUI.showMixedValue = false;
     if (EditorGUI.EndChangeCheck())
         prop.floatValue = newValue;
 }
    public void DrawProperties(SerializedObject toDraw, Rect rect)
    {
        Rect drawRect = new Rect(rect.position + new Vector2(2, 4), new Vector2(rect.width - 4, 0));

        EditorGUI.LabelField(new Rect(drawRect.position, new Vector2(drawRect.width, 24)), toDraw.targetObject.name + ": " + toDraw.targetObject.GetType());
        drawRect = new Rect(drawRect.position + new Vector2(0, 32), drawRect.size);
        toDraw.Update();
        var obj = toDraw.GetIterator();

        if (obj.Next(true))
        {
            do
            {
                if (obj.propertyPath != "m_ObjectHideFlags")
                {
                    if (obj.propertyType == SerializedPropertyType.Integer)
                    {
                        EditorGUI.LabelField(new Rect(drawRect.position, new Vector2(drawRect.width, 24)), obj.displayName + ":");
                        obj.intValue = EditorGUI.DelayedIntField(new Rect(drawRect.position + new Vector2(0, 24), new Vector2(drawRect.width, 19)), obj.intValue);
                        drawRect     = new Rect(drawRect.position + new Vector2(0, 48), drawRect.size);
                    }
                    else if (obj.propertyType == SerializedPropertyType.Float)
                    {
                        EditorGUI.LabelField(new Rect(drawRect.position, new Vector2(drawRect.width, 24)), obj.displayName + ":");
                        obj.floatValue = EditorGUI.DelayedFloatField(new Rect(drawRect.position + new Vector2(0, 24), new Vector2(drawRect.width, 19)), obj.floatValue);
                        drawRect       = new Rect(drawRect.position + new Vector2(0, 48), drawRect.size);
                    }
                    else if (obj.propertyType == SerializedPropertyType.Boolean)
                    {
                        obj.boolValue = EditorGUI.Toggle(new Rect(drawRect.position, new Vector2(32, 24)), obj.boolValue);
                        EditorGUI.LabelField(new Rect(drawRect.position + new Vector2(24, 0), new Vector2(drawRect.width - 32, 24)), obj.displayName);
                        drawRect = new Rect(drawRect.position + new Vector2(0, 48), drawRect.size);
                    }
                    else if (obj.propertyType == SerializedPropertyType.Color)
                    {
                        EditorGUI.LabelField(new Rect(drawRect.position, new Vector2(drawRect.width, 24)), obj.displayName + ":");
                        obj.colorValue = EditorGUI.ColorField(new Rect(drawRect.position + new Vector2(0, 24), new Vector2(drawRect.width, 24)), obj.colorValue);
                        drawRect       = new Rect(drawRect.position + new Vector2(0, 48), drawRect.size);
                    }
                    else if (obj.propertyType == SerializedPropertyType.Vector3)
                    {
                        obj.vector3Value = EditorGUI.Vector3Field(new Rect(drawRect.position, new Vector2(drawRect.width, 28)), obj.displayName, obj.vector3Value);
                        drawRect         = new Rect(drawRect.position + new Vector2(0, 36), drawRect.size);
                    }
                    else
                    {
                    }
                }
                //EditorGUI.ObjectField(new Rect(rect.position, new Vector2(rect.width, 64)), ref1test, typeof(Component));
                //EditorGUI.FloatField(new Rect(rect.position + new Vector2(0, 128), new Vector2(rect.width, 64)), ref3test);
            } while (obj.NextVisible(false));
        }

        toDraw.ApplyModifiedProperties();
    }
Beispiel #15
0
        protected float DrawPerLevelGain(float startX, float startY, LevelProgressionStats stats)
        {
            string text = "Stats Gain Per Level " + (!foldPerLevelGain ? "(show):" : "(hide):");

            foldPerLevelGain = EditorGUI.Foldout(new Rect(startX, startY, width, height), foldPerLevelGain, text, foldoutStyle);
            if (foldPerLevelGain)
            {
                cont = new GUIContent(" - HitPoint:", "");
                EditorGUI.LabelField(new Rect(startX, startY += spaceY, width, height), cont);
                stats.hitPointGain = EditorGUI.DelayedFloatField(new Rect(startX + spaceX, startY, widthS, height), stats.hitPointGain);

                cont = new GUIContent(" - HitPoint Regen:", "");
                EditorGUI.LabelField(new Rect(startX, startY += spaceY, width, height), cont);
                stats.hitPointRegenGain = EditorGUI.DelayedFloatField(new Rect(startX + spaceX, startY, widthS, height), stats.hitPointRegenGain);

                startY += 5;

                cont = new GUIContent(" - Energy:", "");
                EditorGUI.LabelField(new Rect(startX, startY += spaceY, width, height), cont);
                stats.energyGain = EditorGUI.DelayedFloatField(new Rect(startX + spaceX, startY, widthS, height), stats.energyGain);

                cont = new GUIContent(" - Energy Regen:", "");
                EditorGUI.LabelField(new Rect(startX, startY += spaceY, width, height), cont);
                stats.energyRegenGain = EditorGUI.DelayedFloatField(new Rect(startX + spaceX, startY, widthS, height), stats.energyRegenGain);

                startY += 5;

                cont = new GUIContent(" - Speed Multiplier:", "");
                EditorGUI.LabelField(new Rect(startX, startY += spaceY, width, height), cont);
                stats.speedMulGain = EditorGUI.DelayedFloatField(new Rect(startX + spaceX, startY, widthS, height), stats.speedMulGain);

                startY += 5;

                cont = new GUIContent(" - Damage Multiplier:", "");
                EditorGUI.LabelField(new Rect(startX, startY += spaceY, width, height), cont);
                stats.dmgMulGain = EditorGUI.DelayedFloatField(new Rect(startX + spaceX, startY, widthS, height), stats.dmgMulGain);

                cont = new GUIContent(" - Critical Chance Mul.:", "");
                EditorGUI.LabelField(new Rect(startX, startY += spaceY, width, height), cont);
                stats.critChanceMulGain = EditorGUI.DelayedFloatField(new Rect(startX + spaceX, startY, widthS, height), stats.critChanceMulGain);

                cont = new GUIContent(" - Critical Multiplier Mul.:", "");
                EditorGUI.LabelField(new Rect(startX, startY += spaceY, width, height), cont);
                stats.critMultiplierMulGain = EditorGUI.DelayedFloatField(new Rect(startX + spaceX, startY, widthS, height), stats.critMultiplierMulGain);

                startY += 10;

                cont = new GUIContent(" - Perk Currency:", "");
                EditorGUI.LabelField(new Rect(startX, startY += spaceY, width, height), cont);
                stats.perkCurrencyGain = EditorGUI.DelayedIntField(new Rect(startX + spaceX, startY, widthS, height), stats.perkCurrencyGain);
            }

            return(startY);
        }
Beispiel #16
0
        private float DrawExpListGenerator(float startX, float startY, LevelProgressionStats stats)
        {
            EditorGUI.LabelField(new Rect(startX, startY += spaceY, width, height), "Generate Exp List:", headerStyle);

            cont = new GUIContent(" - Sum Recursively:", "");
            EditorGUI.LabelField(new Rect(startX, startY += spaceY, width, height), cont);
            stats.sumRecursively = EditorGUI.Toggle(new Rect(startX + spaceX, startY, widthS, height), stats.sumRecursively);

            cont = new GUIContent(" - Increment Rate:", "");
            EditorGUI.LabelField(new Rect(startX, startY += spaceY, width, height), cont);
            stats.expTHM = EditorGUI.DelayedFloatField(new Rect(startX + spaceX, startY, widthS, height), stats.expTHM);

            cont = new GUIContent(" - Starting Value:", "");
            EditorGUI.LabelField(new Rect(startX, startY += spaceY, width, height), cont);
            stats.expTHC = EditorGUI.DelayedIntField(new Rect(startX + spaceX, startY, widthS, height), stats.expTHC);

            if (GUI.Button(new Rect(startX + 15, startY += spaceY + 2, widthS - 5, height + 2), "Reset"))
            {
                stats.sumRecursively = stats.sumRecursively_Cached;
                stats.expTHM         = stats.expTHM_Cached;
                stats.expTHC         = stats.expTHC_Cached;
            }

            bool regenNeeded = stats.sumRecursively != stats.sumRecursively_Cached;

            regenNeeded = regenNeeded || stats.expTHM != stats.expTHM_Cached;
            regenNeeded = regenNeeded || stats.expTHC != stats.expTHC_Cached;
            regenNeeded = regenNeeded || stats.expThresholdList.Count != stats.levelCap;
            if (regenNeeded)
            {
                GUI.color = new Color(0, 1f, 1f, 1f);
            }

            if (GUI.Button(new Rect(startX + 10 + widthS, startY, spaceX + 5 - 15, height + 2), "Generate Exp"))
            {
                stats.expThresholdList = PlayerProgression.GenerateExpTH(stats.sumRecursively, stats.expTHM, stats.expTHC, stats.levelCap);

                stats.sumRecursively_Cached = stats.sumRecursively;
                stats.expTHM_Cached         = stats.expTHM;
                stats.expTHC_Cached         = stats.expTHC;
            }

            string textRS = stats.sumRecursively ? "Σ(" : "";
            string textRE = stats.sumRecursively ? ")" : "";

            cont = new GUIContent("exp = " + textRS + "(" + stats.expTHM + "*lvl)+" + stats.expTHC + textRE, "The formula used to generate current exp list");
            //cont=new GUIContent(" - Starting Value:", "");
            EditorGUI.LabelField(new Rect(startX + spaceX + width - 80, startY, width * 2, height), cont);

            GUI.color = Color.white;

            return(startY);
        }
        private static void DrawGUI(Rect position, SerializedProperty minProperty, SerializedProperty maxProperty, bool delayed)
        {
            position.height = EditorGUIUtility.singleLineHeight;

            const float spacing    = 2;
            const float labelWidth = 28;
            float       totalWidth = position.width;
            float       fieldWith  = totalWidth / 2 - spacing / 2 - labelWidth;

            using (EditorGUI.PropertyScope propertyScope = new EditorGUI.PropertyScope(position, new GUIContent(nameof(FloatRange.Min)), minProperty))
            {
                position.width = labelWidth;
                EditorGUI.LabelField(position, propertyScope.content);

                position.x    += position.width;
                position.width = fieldWith;

                using (EditorGUI.ChangeCheckScope changeCheckScope = new EditorGUI.ChangeCheckScope())
                {
                    float value = delayed
                                      ? EditorGUI.DelayedFloatField(position, minProperty.floatValue)
                                      : EditorGUI.FloatField(position, minProperty.floatValue);

                    if (changeCheckScope.changed)
                    {
                        minProperty.floatValue = value;
                        maxProperty.floatValue = Mathf.Max(value, maxProperty.floatValue);
                    }
                }
            }

            using (EditorGUI.PropertyScope propertyScope = new EditorGUI.PropertyScope(position, new GUIContent(nameof(FloatRange.Max)), maxProperty))
            {
                position.x    += position.width + spacing;
                position.width = labelWidth;
                EditorGUI.LabelField(position, propertyScope.content);

                position.x    += position.width;
                position.width = fieldWith;

                using (EditorGUI.ChangeCheckScope changeCheckScope = new EditorGUI.ChangeCheckScope())
                {
                    float value = delayed
                                      ? EditorGUI.DelayedFloatField(position, maxProperty.floatValue)
                                      : EditorGUI.FloatField(position, maxProperty.floatValue);

                    if (changeCheckScope.changed)
                    {
                        maxProperty.floatValue = Mathf.Max(value, minProperty.floatValue);
                    }
                }
            }
        }
    public override void OnGUI(Rect position, SerializedProperty property, GUIContent label)
    {
        label    = EditorGUI.BeginProperty(position, label, property);
        position = EditorGUI.PrefixLabel(position, label);

        SerializedProperty minProp = property.FindPropertyRelative("min");
        SerializedProperty maxProp = property.FindPropertyRelative("max");

        float min = minProp.floatValue;
        float max = maxProp.floatValue;

        float rangeMin = 0;
        float rangeMax = 1;

        var ranges = (MinMaxRangeAttribute[])fieldInfo.GetCustomAttributes(typeof(MinMaxRangeAttribute), true);

        if (ranges.Length > 0)
        {
            rangeMin = ranges[0].Min;
            rangeMax = ranges[0].Max;
        }

        EditorGUI.BeginChangeCheck();

        const float floatFieldRectWidth = 50f;
        // Min value
        var minFloatFieldRect = new Rect(position);

        minFloatFieldRect.width = floatFieldRectWidth;
        min            = EditorGUI.DelayedFloatField(minFloatFieldRect, min);
        min            = Mathf.Min(min, max);
        position.xMin += floatFieldRectWidth + 5;

        // Max value
        var maxFloatFieldRect = new Rect(position);

        maxFloatFieldRect.xMin = maxFloatFieldRect.xMax - floatFieldRectWidth;
        max            = EditorGUI.DelayedFloatField(maxFloatFieldRect, max);
        max            = Mathf.Max(min, max);
        position.xMax -= floatFieldRectWidth + 5;

        //Slider
        EditorGUI.MinMaxSlider(position, ref min, ref max, rangeMin, rangeMax);

        if (EditorGUI.EndChangeCheck())
        {
            minProp.floatValue = min;
            maxProp.floatValue = max;
        }

        EditorGUI.EndProperty();
    }
Beispiel #19
0
    public override void OnGUI(Rect position, SerializedProperty property, GUIContent label)
    {
        // Store min-max sub-properties for ease of use
        SerializedProperty min = property.FindPropertyRelative("_min");
        SerializedProperty max = property.FindPropertyRelative("_max");

        // Put in the prefix label
        position = EditorGUI.PrefixLabel(position, label);

        // Store the old indent
        int oldIndent = EditorGUI.indentLevel;

        EditorGUI.indentLevel = 0;

        // Build a single-line layout where the float editors stretch and the labels stay at the same width
        Layout.Builder builder = new Layout.Builder();
        builder.PushChild(LayoutChild.Width(LayoutSize.Exact(35f)));
        builder.PushChild(LayoutChild.Width(LayoutSize.RatioOfRemainder(0.5f), LayoutMargin.Right(5f)));
        builder.PushChild(LayoutChild.Width(LayoutSize.Exact(35f)));
        builder.PushChild(LayoutChild.Width(LayoutSize.RatioOfRemainder(0.5f)));
        Layout layout = builder.Compile(position);

        // Create the min label
        EditorGUI.LabelField(layout.Next(), new GUIContent("Min:"));

        // Create the min editor
        EditorGUI.BeginChangeCheck();
        min.floatValue = EditorGUI.DelayedFloatField(layout.Next(), min.floatValue);

        // If the max was modified, ensure that the max is not smaller than the new min
        if (EditorGUI.EndChangeCheck())
        {
            max.floatValue = Mathf.Max(min.floatValue, max.floatValue);
        }

        // Create the max label
        EditorGUI.LabelField(layout.Next(), new GUIContent("Max:"));

        // Create the max editor
        EditorGUI.BeginChangeCheck();
        max.floatValue = EditorGUI.DelayedFloatField(layout.Next(), max.floatValue);

        // If the max was modified, ensure that the min is not bigger than the new max
        if (EditorGUI.EndChangeCheck())
        {
            min.floatValue = Mathf.Min(min.floatValue, max.floatValue);
        }

        // Restore indent level
        EditorGUI.indentLevel = oldIndent;
    }
Beispiel #20
0
        public override void OnGUI(Rect pos, SerializedProperty prop, GUIContent label)
        {
            var mp = prop.FindPropertyRelative("min");
            var np = prop.FindPropertyRelative("max");
            var mm = attribute as MinMaxAttribute;

            if (mp != null && np != null && mm != null)
            {
                var oldColor = GUI.color;
                if (mm.colorize)
                {
                    GUI.color = ColorizeDrawer.GetColor(prop.propertyPath);
                }

                int i = EditorGUI.indentLevel;

                float mv = mp.floatValue;
                float nv = np.floatValue;

                float dx1 = EditorGUIUtility.fieldWidth * 2 + Mathf.Clamp01(i) * 9;
                float dx2 = EditorGUIUtility.fieldWidth * 2 + (i - 1) * 9;

                Rect r = pos;
                r.width = r.width - dx1;
                EditorGUI.MinMaxSlider(
                    new GUIContent(ObjectNames.NicifyVariableName(prop.name)), r,
                    ref mv, ref nv, mm.min, mm.max);

                EditorGUI.indentLevel = 0;

                r.x     = pos.width - dx2 + i * 9 + 3;
                r.width = EditorGUIUtility.fieldWidth;
                var s = new GUIStyle(EditorStyles.numberField);
                s.fixedWidth = EditorGUIUtility.fieldWidth;
                mv           = EditorGUI.DelayedFloatField(r, mv, s);
                r.x         += EditorGUIUtility.fieldWidth + 2;
                nv           = EditorGUI.DelayedFloatField(r, nv, s);

                mp.floatValue = Mathf.Min(Mathf.Max(mv, mm.min), Mathf.Min(nv, mm.max));
                np.floatValue = Mathf.Max(Mathf.Max(mv, mm.min), Mathf.Min(nv, mm.max));

                EditorGUI.indentLevel = i;

                if (mm.colorize)
                {
                    GUI.color = oldColor;
                }
            }
        }
        private void DelayedPropertyField(Rect position, SerializedProperty property)
        {
            switch (property.propertyType)
            {
            case SerializedPropertyType.Integer:
                property.intValue = EditorGUI.DelayedIntField(position, property.displayName, property.intValue);
                break;

            case SerializedPropertyType.Float:
                property.floatValue = EditorGUI.DelayedFloatField(position, property.displayName, property.floatValue);
                break;

            default:
                break;
            }
        }
Beispiel #22
0
        /// <inheritdoc />
        public override Rect Draw(Rect rect, object currentValue, Action <object> changeValueCallback, GUIContent label)
        {
            rect.height = EditorDrawingHelper.SingleLineHeight;

            float value    = (float)currentValue;
            float newValue = EditorGUI.DelayedFloatField(rect, label, value);

            // Rounding error can't take place here.
            // ReSharper disable once CompareOfFloatsByEqualityOperator
            if (value != newValue)
            {
                ChangeValue(() => newValue, () => value, changeValueCallback);
            }

            return(rect);
        }
Beispiel #23
0
        public static void RectOneline(Rect position, SerializedProperty property, GUIContent label)
        {
            var labelWidth = 0f;

            if (!string.IsNullOrEmpty(label.text))
            {
                var labelRect = new Rect(position.x, position.y, EditorGUIUtility.labelWidth, position.height);
                EditorGUI.LabelField(labelRect, label.text);
                labelWidth = labelRect.width;
            }

            var perWidth = (position.width - labelWidth) / 4;

            var x = position.x + labelWidth;

            using (var check = new EditorGUI.ChangeCheckScope())
            {
                var charWidth  = EditorStyles.label.CalcSize(new GUIContent("W")).x;
                var xLabelRect = new Rect(x, position.y, 25f, position.height);
                var xValueRect = new Rect(x + charWidth + 1, position.y, perWidth - charWidth - 1, position.height);
                EditorGUI.LabelField(xLabelRect, "X");
                var valX = EditorGUI.DelayedFloatField(xValueRect, property.rectValue.x);
                x += perWidth;

                var yLabelRect = new Rect(x, position.y, 25f, position.height);
                var yValueRect = new Rect(x + charWidth + 1, position.y, perWidth - charWidth - 1, position.height);
                EditorGUI.LabelField(yLabelRect, "Y");
                var valY = EditorGUI.DelayedFloatField(yValueRect, property.rectValue.y);
                x += perWidth;

                var zLabelRect = new Rect(x, position.y, 30f, position.height);
                var zValueRect = new Rect(x + charWidth + 1, position.y, perWidth - charWidth - 1, position.height);
                EditorGUI.LabelField(zLabelRect, "W");
                var valWidth = EditorGUI.DelayedFloatField(zValueRect, property.rectValue.width);
                x += perWidth;

                var wLabelRect = new Rect(x, position.y, 30f, position.height);
                var wValueRect = new Rect(x + charWidth, position.y, perWidth - charWidth - 1, position.height);
                EditorGUI.LabelField(wLabelRect, "H");
                var valHeight = EditorGUI.DelayedFloatField(wValueRect, property.rectValue.height);

                if (check.changed)
                {
                    property.rectValue = new Rect(valX, valY, valWidth, valHeight);
                }
            }
        }
Beispiel #24
0
        public override void OnGUI(Rect position, SerializedProperty property, GUIContent label)
        {
            var minProp = property.FindPropertyRelative("Min");
            var maxProp = property.FindPropertyRelative("Max");

            var min = minProp.floatValue;
            var max = maxProp.floatValue;

            position = EditorGUI.PrefixLabel(position, label);

            EditorGUI.MinMaxSlider(new Rect(position.x + width + 5, position.y, position.width - width - width - 10, position.height), ref min, ref max, 0f, 1f);

            var newmin = EditorGUI.DelayedFloatField(new Rect(position.x, position.y, width, position.height), min);

            if (newmin > max)
            {
                min = max;
            }
            else
            {
                min = newmin;
            }

            var right = new GUIStyle(GUI.skin.FindStyle("label"));

            right.fontStyle = FontStyle.Normal;
            right.alignment = TextAnchor.MiddleRight;

            var newmax = EditorGUI.DelayedFloatField(new Rect(position.x + position.width - width, position.y, width, position.height), max);

            if (newmax <= min)
            {
                max = min;
            }
            else
            {
                max = newmax;
            }

            minProp.floatValue = min;
            maxProp.floatValue = max;
        }
Beispiel #25
0
 public override void OnGUI(Rect position, SerializedProperty property, GUIContent label)
 {
     // Now draw the property as a Slider or an IntSlider based on whether it's a float or integer.
     if (property.propertyType == SerializedPropertyType.Float)
     {
         EditorGUI.DelayedFloatField(position, property, label);
     }
     else if (property.propertyType == SerializedPropertyType.Integer)
     {
         EditorGUI.DelayedIntField(position, property, label);
     }
     else if (property.propertyType == SerializedPropertyType.String)
     {
         EditorGUI.DelayedTextField(position, property, label);
     }
     else
     {
         EditorGUI.LabelField(position, label.text, "Use MultiRange with float or int.");
     }
 }
Beispiel #26
0
    public override void OnGUI(Rect position, SerializedProperty property, GUIContent label)
    {
        EditorGUI.BeginProperty(position, label, property);
        Rect rect = new Rect(position)
        {
            width = label.text.Length * DVariableDrawer.CHARACTER_WIDTH
        };

        EditorGUI.LabelField(rect, label);

        rect.x    += rect.width;
        rect.width = 6f * DVariableDrawer.CHARACTER_WIDTH;
        EditorGUI.LabelField(rect, "Priority");

        rect.x    += rect.width + DVariableDrawer.SPACE;
        rect.width = 3 * DVariableDrawer.CHARACTER_WIDTH;
        SerializedProperty priorityProperty = property.FindPropertyRelative("priority");

        priorityProperty.intValue = EditorGUI.DelayedIntField(rect, priorityProperty.intValue);

        rect.x    += rect.width + DVariableDrawer.SPACE;
        rect.width = 5 * DVariableDrawer.CHARACTER_WIDTH;
        SerializedProperty typeProperty = property.FindPropertyRelative("type");

        typeProperty.enumValueIndex = EditorGUI.Popup(rect, typeProperty.enumValueIndex, typeProperty.enumDisplayNames);

        rect.x   += rect.width + DVariableDrawer.SPACE;
        rect.xMax = position.xMax;
        SerializedProperty valueProperty = property.FindPropertyRelative("value");

        switch (valueProperty.type)
        {
        case "int": valueProperty.intValue = EditorGUI.DelayedIntField(rect, valueProperty.intValue); break;

        case "long": valueProperty.longValue = EditorGUI.LongField(rect, valueProperty.longValue); break;

        case "float": valueProperty.floatValue = EditorGUI.DelayedFloatField(rect, valueProperty.floatValue); break;
        }

        EditorGUI.EndProperty();
    }
Beispiel #27
0
    public static T OnGUI <T>(Rect position, T decorator, GUIContent label) where T : VariableDecorator, new ()
    {
        decorator = decorator ?? new T();

        Rect rect = new Rect(position)
        {
            width = label.text.Length * DVariableDrawer.CHARACTER_WIDTH
        };

        EditorGUI.LabelField(rect, label);

        rect.x    += rect.width;
        rect.width = 6f * DVariableDrawer.CHARACTER_WIDTH;
        EditorGUI.LabelField(rect, "Priority");

        rect.x            += rect.width + DVariableDrawer.SPACE;
        rect.width         = 3 * DVariableDrawer.CHARACTER_WIDTH;
        decorator.priority = EditorGUI.DelayedIntField(rect, decorator.priority);

        rect.x        += rect.width + DVariableDrawer.SPACE;
        rect.width     = 5 * DVariableDrawer.CHARACTER_WIDTH;
        decorator.type = (VariableDecoratorType)EditorGUI.EnumPopup(rect, decorator.type);

        rect.x   += rect.width + DVariableDrawer.SPACE;
        rect.xMax = position.xMax;

        if (typeof(T) == typeof(IntDecorator))
        {
            (decorator as IntDecorator).value = EditorGUI.DelayedIntField(rect, (decorator as IntDecorator).value);
        }
        else if (typeof(T) == typeof(LongDecorator))
        {
            (decorator as LongDecorator).value = EditorGUI.LongField(rect, (decorator as LongDecorator).value);
        }
        else if (typeof(T) == typeof(FloatDecorator))
        {
            (decorator as FloatDecorator).value = EditorGUI.DelayedFloatField(rect, (decorator as FloatDecorator).value);
        }

        return(decorator);
    }
Beispiel #28
0
        internal override void OnGUI(Rect position, SerializedProperty property, GUIContent label, DecoratedDrawer drawer)
        {
            switch (property.propertyType)
            {
            case SerializedPropertyType.Float:
                EditorGUI.DelayedFloatField(position, property, label);
                break;

            case SerializedPropertyType.Integer:
                EditorGUI.DelayedIntField(position, property, label);
                break;

            case SerializedPropertyType.String:
                EditorGUI.DelayedTextField(position, property, label);
                break;

            default:
                EditorGUI.LabelField(position, label.text, "Delayed: must be float, integer, or string.");
                break;
            }
        }
Beispiel #29
0
        private void DrawBasicRanges()
        {
            EditorGUI.LabelField(new Rect(ir.xMin + PADDING, line - 2, labelwidth, LINEHEIGHT), new GUIContent(holdindent < 2 ? "Range:" : "Rng:"), (GUIStyle)"MiniLabel");

            //int holdindent = EditorGUI.indentLevel;
            //EditorGUI.indentLevel = 0;

            const float labelW = 48f;
            const float inputW = 50f;

            float input1Left = fieldleft;
            float input2Left = paddedright - inputW;
            float label1Left = input1Left - labelW;
            float label2Left = input2Left - labelW;


            EditorGUI.LabelField(new Rect(label1Left, line - 2, labelW, LINEHEIGHT), new GUIContent("min: "), miniLabelRight);

            float min = EditorGUI.DelayedFloatField(new Rect(input1Left, line, inputW, LINEHEIGHT), GUIContent.none, fc.Min, (GUIStyle)"MiniTextField");

            if (fc.Min != min)
            {
                haschanged = true;
                Undo.RecordObject(p.serializedObject.targetObject, "Min value Change");
                fc.Min = min;
            }

            EditorGUI.LabelField(new Rect(label2Left, line - 2, labelW, LINEHEIGHT), new GUIContent("max: "), miniLabelRight);

            float max = EditorGUI.DelayedFloatField(new Rect(input2Left, line, inputW, LINEHEIGHT), GUIContent.none, fc.Max, (GUIStyle)"MiniTextField");

            if (fc.Max != max)
            {
                haschanged = true;
                Undo.RecordObject(p.serializedObject.targetObject, "Max value change");
                fc.Max = max;
            }

            EditorGUI.indentLevel = holdindent;
        }
Beispiel #30
0
        protected Vector2 DrawDestroyEffectObj(float startX, float startY, Unit unit)
        {
            cont = new GUIContent("Spawn Immunity:", "How long the unit will stay immune to all attack when it's first spawned/respawned.");
            EditorGUI.LabelField(new Rect(startX, startY, width, height), cont);
            unit.spawnImmunity = EditorGUI.DelayedFloatField(new Rect(startX + spaceX, startY, 40, height), unit.spawnImmunity);

            startY += 10;

            cont = new GUIContent("DestroyCamShake:", "The camera shake magnitude whenever the unit is destroyed");
            EditorGUI.LabelField(new Rect(startX, startY += spaceY, width, height), cont);
            unit.destroyCamShake = EditorGUI.DelayedFloatField(new Rect(startX + spaceX, startY, 40, height), unit.destroyCamShake);

            startY += 10;

            cont = new GUIContent("DestroyedEffectObj:", "The object to be spawned when the unit is destroyed (optional)");
            EditorGUI.LabelField(new Rect(startX, startY += spaceY, width, height), cont);
            unit.destroyedEffectObj = (GameObject)EditorGUI.ObjectField(new Rect(startX + spaceX, startY, width, height), unit.destroyedEffectObj, typeof(GameObject), false);

            cont = new GUIContent("AutoDestroy Effect:", "Check if the effect object needs to be removed from the game");
            EditorGUI.LabelField(new Rect(startX, startY += spaceY, width, height), cont);
            if (unit.destroyedEffectObj != null)
            {
                unit.autoDestroyDObj = EditorGUI.Toggle(new Rect(startX + spaceX, startY, 40, height), unit.autoDestroyDObj);

                if (unit.autoDestroyDObj)
                {
                    cont = new GUIContent(" - Duration:", "The delay in seconds before the effect object is destroyed");
                    EditorGUI.LabelField(new Rect(startX + spaceX + 15, startY, width, height), cont);
                    unit.dObjActiveDuration = EditorGUI.DelayedFloatField(new Rect(startX + spaceX + width - 58, startY, 40, height), unit.dObjActiveDuration);
                }
            }
            else
            {
                EditorGUI.LabelField(new Rect(startX + spaceX, startY, 40, height), "-");
            }


            return(new Vector2(startX, startY));
        }