Example #1
0
        public static object DrawChar(MemberInfoAndInspectAttr memberInfo, object value)
        {
            char   oldValue = (char)value;
            string newValue = EditorGUILayout.TextField(memberInfo.Info.Name, string.Empty + oldValue);

            if (newValue == null || newValue == string.Empty)
            {
                return(default(char));
            }

            return(char.Parse(newValue.Substring(0, 1)));
        }
Example #2
0
        public static object DrawUInt(MemberInfoAndInspectAttr memberInfo, object value)
        {
            long newValue = EditorGUILayout.LongField(memberInfo.Info.Name, (uint)value);

            if (newValue < uint.MinValue)
            {
                return(uint.MinValue);
            }
            else if (newValue > uint.MaxValue)
            {
                return(uint.MaxValue);
            }

            return((uint)newValue);
        }
Example #3
0
        public static object DrawEnum(MemberInfoAndInspectAttr memberInfo, object value)
        {
            var flagAttrs = memberInfo.RealType.GetCustomAttributes(typeof(FlagsAttribute), false);

            if (flagAttrs == null || flagAttrs.Length == 0)
            {
                return(EditorGUILayout.EnumPopup(memberInfo.Info.Name, (Enum)value));
            }
            else if (flagAttrs.Length == 1)
            {
                return(EditorGUILayout.EnumFlagsField(memberInfo.Info.Name, (Enum)value));
            }
            else
            {
                Debug.LogWarning("Multiple attributes of type " + typeof(FlagsAttribute).FullName + " found for enum of type " + memberInfo.RealType.FullName);
                return(value);
            }
        }
Example #4
0
        public static object DrawULong(MemberInfoAndInspectAttr memberInfo, object value)
        {
            ulong  oldValue = (ulong)value;
            string newValue = EditorGUILayout.TextField(memberInfo.Info.Name, string.Empty + oldValue);

            if (newValue == null || newValue == string.Empty)
            {
                return(default(ulong));
            }

            ulong result;

            if (ulong.TryParse(newValue, out result))
            {
                return(result);
            }

            return(oldValue);
        }
Example #5
0
        public static object DrawString(MemberInfoAndInspectAttr memberInfo, object value)
        {
            switch (memberInfo.InspectAttribute.InspectionType)
            {
            case InspectionType.DelayedString:
                return(EditorGUILayout.DelayedTextField(memberInfo.Info.Name, (string)value));

            case InspectionType.TagString:
                return(EditorGUILayout.TagField(memberInfo.Info.Name, (string)value));

            case InspectionType.AreaString:
                EditorGUILayout.BeginHorizontal();
                EditorGUILayout.PrefixLabel(memberInfo.Info.Name);
                string result = EditorGUILayout.TextArea((string)value);
                EditorGUILayout.EndHorizontal();
                return(result);
            }

            return(EditorGUILayout.TextField(memberInfo.Info.Name, (string)value));
        }
Example #6
0
        public static object DrawInt(MemberInfoAndInspectAttr memberInfo, object value)
        {
            if (memberInfo.InspectAttribute is InspectAsIntSliderAttribute)
            {
                var attr = (InspectAsIntSliderAttribute)memberInfo.InspectAttribute;

                EditorGUILayout.BeginHorizontal();
                EditorGUILayout.PrefixLabel(memberInfo.Info.Name);
                int newVal = EditorGUILayout.IntSlider((int)value, attr.SliderMin, attr.SliderMax);
                EditorGUILayout.EndHorizontal();
                return(newVal);
            }
            else
            {
                switch (memberInfo.InspectAttribute.InspectionType)
                {
                case InspectionType.DelayedInt:
                    return(EditorGUILayout.DelayedIntField(memberInfo.Info.Name, (int)value));
                }

                return(EditorGUILayout.IntField(memberInfo.Info.Name, (int)value));
            }
        }
Example #7
0
 public static object DrawAnimationCurve(MemberInfoAndInspectAttr memberInfo, object value)
 {
     return(EditorGUILayout.CurveField(memberInfo.Info.Name, (AnimationCurve)value));
 }
Example #8
0
 public static object DrawColor(MemberInfoAndInspectAttr memberInfo, object value)
 {
     return(EditorGUILayout.ColorField(memberInfo.Info.Name, (Color)value));
 }
Example #9
0
 public static object DrawBounds(MemberInfoAndInspectAttr memberInfo, object value)
 {
     return(EditorGUILayout.BoundsField(memberInfo.Info.Name, (Bounds)value));
 }
Example #10
0
 public static object DrawVector4(MemberInfoAndInspectAttr memberInfo, object value)
 {
     return(EditorGUILayout.Vector4Field(memberInfo.Info.Name, (Vector4)value));
 }
Example #11
0
 public static object DrawRect(MemberInfoAndInspectAttr memberInfo, object value)
 {
     return(EditorGUILayout.RectField(memberInfo.Info.Name, (Rect)value));
 }
Example #12
0
 public static object DrawLong(MemberInfoAndInspectAttr memberInfo, object value)
 {
     return(EditorGUILayout.LongField(memberInfo.Info.Name, (long)value));
 }
Example #13
0
 public static object DrawBool(MemberInfoAndInspectAttr memberInfo, object value)
 {
     return(EditorGUILayout.Toggle(memberInfo.Info.Name, (bool)value));
 }