public override void OnGUILayout(IGUIProperty property, Attribute attribute)
 {
     using (new GUILayout.HorizontalScope())
     {
         GUILayoutx.PrefixLabel(property);
         bool value = (bool)property.Value;
         value = GUILayout.Toggle(value, GUIContent.none);
         property.SetValue(value);
     }
 }
 public override void OnGUILayout(IGUIProperty property, Attribute attribute)
 {
     using (new GUILayout.HorizontalScope())
     {
         GUILayoutx.PrefixLabel(property);
         int value = (int)property.Value;
         value = GUILayoutx.DelayedInt32Field(value);
         property.SetValue(value);
     }
 }
Example #3
0
 public override void OnGUILayout(IGUIProperty property, Attribute attribute)
 {
     using (new GUILayout.HorizontalScope())
     {
         GUILayoutx.PrefixLabel(property.DisplayName);
         Vector3 value = (Vector3)property.Value;
         value = GUILayoutx.Vector3Field(value);
         property.SetValue(value);
     }
 }
Example #4
0
 public override void OnGUILayout(IGUIProperty property, Attribute attribute)
 {
     UnityEngine.RangeAttribute attr = attribute as UnityEngine.RangeAttribute;
     using (new GUILayout.HorizontalScope())
     {
         GUILayoutx.PrefixLabel(property.DisplayName);
         float value = (float)property.Value;
         value = GUILayout.HorizontalSlider(value, attr.min, attr.max);
         property.SetValue(value);
     }
 }
        public override void OnGUILayout(IGUIProperty property, Attribute attribute)
        {
            using (new GUILayout.HorizontalScope())
            {
                GUILayoutx.PrefixLabel(property);
                int value = (int)property.Value;

                Array arr = Enum.GetValues(property.ValueType);

                if (property.ValueType.IsDefined(typeof(FlagsAttribute), false))
                {
                    int[]        intValues = new int[arr.Length];
                    GUIContent[] conents   = new GUIContent[arr.Length];
                    int          mask      = 0;
                    for (int i = 0; i < arr.Length; i++)
                    {
                        int val = (int)arr.GetValue(i);
                        conents[i]   = new GUIContent(arr.GetValue(i).ToString());
                        intValues[i] = val;
                        if ((value & val) == val)
                        {
                            mask |= val;
                        }
                    }
                    int newMask = GUILayoutx.Mask(mask, intValues, conents);
                    if (mask != newMask)
                    {
                        property.SetValue(newMask);
                    }
                }
                else
                {
                    GUIContent[] conents       = new GUIContent[arr.Length];
                    int          selectedIndex = -1;
                    for (int i = 0; i < arr.Length; i++)
                    {
                        conents[i] = new GUIContent(arr.GetValue(i).ToString());
                        if (object.Equals(arr.GetValue(i), property.Value))
                        {
                            selectedIndex = i;
                        }
                    }
                    int newIndex = GUILayoutx.Popup(selectedIndex, conents);
                    if (newIndex != selectedIndex && newIndex >= 0)
                    {
                        property.SetValue(arr.GetValue(newIndex));
                    }
                }
            }
        }
Example #6
0
        public override void OnGUILayout(IGUIProperty property, Attribute attribute)
        {
            EnumValuesAttribute attr = attribute as EnumValuesAttribute;

            object value = property.Value;

            object[] values       = attr.Values;
            string[] displayTexts = attr.DisplayTexts;

            using (new GUILayout.HorizontalScope())
            {
                GUILayoutx.PrefixLabel(new GUIContent(property.DisplayName, property.Tooltip));

                int          selectedIndex2 = -1;
                GUIContent[] displays       = new GUIContent[values.Length];
                for (int i = 0; i < values.Length; i++)
                {
                    displays[i] = new GUIContent(displayTexts != null && displayTexts.Length > 0 ? displayTexts[i] : values[i].ToString());

                    if (object.Equals(values[i], property.Value))
                    {
                        selectedIndex2 = i;
                    }
                }

                if (attr.IsMask)
                {
                    int      maskValue  = 0;
                    string[] maskValues = ((string)value).Split(new string[] { attr.Separator }, StringSplitOptions.RemoveEmptyEntries);
                    int[]    intValues  = new int[values.Length];
                    for (int i = 0; i < values.Length; i++)
                    {
                        intValues[i] = 1 << i;
                        if (maskValues.Contains(values[i]))
                        {
                            maskValue |= intValues[i];
                        }
                    }
                    int newMask = GUILayoutx.Mask(maskValue, intValues, displays);
                    if (newMask != maskValue)
                    {
                        List <string> list = new List <string>();
                        for (int i = 0; i < values.Length; i++)
                        {
                            if ((intValues[i] & newMask) == intValues[i])
                            {
                                list.Add((string)values[i]);
                            }
                        }
                        value = string.Join(attr.Separator, list);
                    }
                }
                else
                {
                    int newIndex = GUILayoutx.Popup(selectedIndex2, displays);
                    if (newIndex != selectedIndex2)
                    {
                        value = values[newIndex];
                    }
                }
            }

            property.SetValue(value);
        }