Example #1
0
        private static CatalogTuple DrawCell(Rect rect, CatalogTuple tuple)
        {
            tuple.Value = (GameObject)SirenixEditorFields.UnityPreviewObjectField(
                new Rect(rect)
            {
                x = rect.x - 8f, yMax = rect.yMax - 16f
            },
                tuple.Value,
                typeof(GameObject),
                dragOnly: false,
                allowMove: true,
                allowSwap: true,
                allowSceneObjects: false
                );

            tuple.Key = SirenixEditorFields.TextField(
                new Rect(rect)
            {
                yMin = rect.yMax - 16f
            },
                tuple.Key
                );

            return(tuple);
        }
Example #2
0
    protected override void DrawPropertyLayout(GUIContent label)
    {
        string  text     = this.ValueEntry.SmartValue.text;
        int     number   = this.ValueEntry.SmartValue.number;
        Vector3 location = this.ValueEntry.SmartValue.location;

        Rect rect = EditorGUILayout.GetControlRect();

        if (label != null)
        {
            rect = EditorGUI.PrefixLabel(rect, label);
        }

        rect = EditorGUILayout.GetControlRect();

        GUIHelper.PushLabelWidth(75);
        text     = SirenixEditorFields.TextField(rect.Split(0, 2), "Text", text);
        number   = SirenixEditorFields.IntField(rect.Split(1, 2), "Number", number);
        location = SirenixEditorFields.Vector3Field("Location", location);
        GUIHelper.PopLabelWidth();

        this.ValueEntry.SmartValue.text     = text;
        this.ValueEntry.SmartValue.number   = number;
        this.ValueEntry.SmartValue.location = location;
    }
Example #3
0
        /// <summary>
        /// Draws the property.
        /// </summary>
        protected override void DrawPropertyLayout(IPropertyValueEntry <char> entry, GUIContent label)
        {
            EditorGUI.BeginChangeCheck();
            string s = new string(entry.SmartValue, 1);

            s = SirenixEditorFields.TextField(label, s);

            if (EditorGUI.EndChangeCheck() && s.Length > 0)
            {
                entry.SmartValue = s[0];
            }
        }
    protected override void DrawPropertyLayout(GUIContent label)
    {
        Rect   rect      = EditorGUILayout.GetControlRect();
        Color  tempColor = this.ValueEntry.SmartValue;
        string hexCode   = ColorUtility.ToHtmlStringRGB(tempColor);

        if (label != null)
        {
            rect = EditorGUI.PrefixLabel(rect, label);
        }

        rect      = EditorGUILayout.GetControlRect();
        tempColor = SirenixEditorFields.ColorField(rect.AlignLeft(rect.width * 0.75f), tempColor);

        //hexcode
        hexCode = SirenixEditorFields.TextField(rect.AlignRight(rect.width * 0.25f), "#" + hexCode);
        if (ColorUtility.TryParseHtmlString(hexCode, out tempColor))
        {
            this.ValueEntry.SmartValue = tempColor;
        }

        //rgb values
        rect = EditorGUILayout.GetControlRect();

        GUIHelper.PushLabelWidth(15);
        tempColor.r = EditorGUI.Slider(rect.AlignLeft(rect.width * 0.3f), "R", tempColor.r, 0f, 1f);
        tempColor.g = EditorGUI.Slider(rect.AlignCenter(rect.width * 0.3f), "G", tempColor.g, 0f, 1f);
        tempColor.b = EditorGUI.Slider(rect.AlignRight(rect.width * 0.3f), "B", tempColor.b, 0f, 1f);
        GUIHelper.PopLabelWidth();

        //hsv values
        Color.RGBToHSV(tempColor, out float h, out float s, out float v);
        rect = EditorGUILayout.GetControlRect();

        GUIHelper.PushLabelWidth(15);
        h = EditorGUI.Slider(rect.AlignLeft(rect.width * 0.3f), "H", h, 0f, 1f);
        s = EditorGUI.Slider(rect.AlignCenter(rect.width * 0.3f), "S", s, 0f, 1f);
        v = EditorGUI.Slider(rect.AlignRight(rect.width * 0.3f), "V", v, 0f, 1f);
        GUIHelper.PopLabelWidth();

        tempColor = Color.HSVToRGB(h, s, v);

        this.ValueEntry.SmartValue = tempColor;
    }
Example #5
0
    protected override void DrawPropertyLayout(GUIContent label)
    {
        Rect rect = EditorGUILayout.GetControlRect();

        if (label != null)
        {
            rect = EditorGUI.PrefixLabel(rect, label);
        }

        rect = EditorGUILayout.GetControlRect();

        GUIHelper.PushLabelWidth(75);
        text.ValueEntry.WeakSmartValue = SirenixEditorFields.TextField(rect.Split(0, 2),
                                                                       "Text", (string)text.ValueEntry.WeakSmartValue);
        number.ValueEntry.WeakSmartValue = SirenixEditorFields.IntField(rect.Split(1, 2),
                                                                        "Number", (int)number.ValueEntry.WeakSmartValue);
        location.Draw();
        GUIHelper.PopLabelWidth();
    }
Example #6
0
    protected override void DrawPropertyLayout(GUIContent label)
    {
        display = this.ValueEntry.SmartValue.ToString();

        SirenixEditorGUI.BeginShakeableGroup(key);

        display = SirenixEditorFields.TextField(label, display);

        if (DateTime.TryParse(display, out DateTime result))
        {
            this.ValueEntry.SmartValue = result;
        }
        else
        {
            SirenixEditorGUI.StartShakingGroup(key);
        }

        SirenixEditorGUI.EndShakeableGroup(key);
    }
Example #7
0
        /// <summary>
        /// Draws the property.
        /// </summary>
        protected override void DrawPropertyLayout(IPropertyValueEntry <T> entry, GUIContent label)
        {
            Context context;

            if (entry.Context.Get(this, "context", out context))
            {
                context.uniqueControlName = Guid.NewGuid().ToString();
                context.typeNameTemp      = entry.SmartValue == null ? "" : Binder.BindToName(entry.SmartValue);
            }

            EditorGUI.BeginChangeCheck();

            if (!context.isValid)
            {
                GUIHelper.PushColor(Color.red);
            }

            GUI.SetNextControlName(context.uniqueControlName);

            context.typeNameTemp = SirenixEditorFields.TextField(label, context.typeNameTemp);

            if (!context.isValid)
            {
                GUIHelper.PopColor();
            }

            bool isFocused = GUI.GetNameOfFocusedControl() == context.uniqueControlName;
            bool defocused = false;

            if (isFocused != context.wasFocusedControl)
            {
                defocused = !isFocused;
                context.wasFocusedControl = isFocused;
            }

            if (EditorGUI.EndChangeCheck())
            {
                if (string.IsNullOrEmpty(context.typeNameTemp.Trim()))
                {
                    // String is empty
                    entry.SmartValue = null;
                    context.isValid  = true;
                }
                else
                {
                    Type type = Binder.BindToType(context.typeNameTemp);

                    if (type == null)
                    {
                        type = AssemblyUtilities.GetTypeByCachedFullName(context.typeNameTemp);
                    }

                    if (type == null)
                    {
                        context.isValid = false;
                    }
                    else
                    {
                        // Use WeakSmartValue in case of a different Type-derived instance showing up somehow, so we don't get cast errors
                        entry.WeakSmartValue = type;
                        context.isValid      = true;
                    }
                }
            }

            if (defocused)
            {
                // Ensure we show the full type name when the control is defocused
                context.typeNameTemp = entry.SmartValue == null ? "" : Binder.BindToName(entry.SmartValue);
                context.isValid      = true;
            }
        }