public override bool InspectSelf(Inspector inspector, string name, ref object data, Type type)
        {
            var      timestamp = (int)data;
            DateTime time      = CTIME_BEGIN.AddSeconds(timestamp).ToLocalTime();

            GUITools.LabelField(time.ToString(CultureInfo.InvariantCulture));
            return(false);
        }
Exemplo n.º 2
0
        public override bool InspectSelf(Inspector inspector, string name, ref object data, Type type)
        {
            if (data == null)
            {
                GUITools.LabelField(name, "null");
                return(false);
            }

            return(ApplyValueIfNotEqual(ref data, GUITools.TextField(name, (string)data)));
        }
Exemplo n.º 3
0
        public override bool InspectSelf(Inspector inspector, string name, ref object data, Type type)
        {
            var action = data as MulticastDelegate;

            if (action != null)
            {
                GUITools.LabelField("");
            }
            return(false);
        }
        public override bool InspectSelf(Inspector inspector, string name, ref object data, Type type)
        {
            var container = data as IEnumerable;

            if (container == null)
            {
                return(false);
            }

            GUITools.LabelField("Count: " + GetCount(data));
            return(false);
        }
Exemplo n.º 5
0
 public override bool InspectSelf(Inspector inspector, string name, ref object data, Type type)
 {
     if (data == null)
     {
         GUITools.LabelField("null [" + type.Name + "]");
     }
     else
     {
         GUITools.LabelField(type.Name);
     }
     GUILayout.FlexibleSpace();
     return(false);
 }
        public override bool InspectSelf(Inspector inspector, string name, ref object data, Type type)
        {
            if (GUITools.IsInEditor())
            {
#if UNITY_EDITOR
                if (data is Color)
                {
                    return(ApplyValueIfNotEqual(ref data, EditorGUILayout.ColorField(name, (Color)data)));
                }
                else if (data is Vector2)
                {
                    return(ApplyValueIfNotEqual(ref data, EditorGUILayout.Vector2Field(name, (Vector2)data)));
                }
                else if (data is Vector3)
                {
                    return(ApplyValueIfNotEqual(ref data, EditorGUILayout.Vector3Field(name, (Vector3)data)));
                }
                else if (data is Vector4)
                {
                    // TODO: Unity的Vector4Field实现是错误的,indentLevel 属性配合异常
                    return(ApplyValueIfNotEqual(ref data, EditorGUILayout.Vector4Field(name, (Vector4)data)));
                }
                else if (data is Bounds)
                {
                    // TODO: Unity的BoundsField实现是错误的,indentLevel 属性配合异常
                    return(ApplyValueIfNotEqual(ref data, EditorGUILayout.BoundsField(name, (Bounds)data)));
                }
                else if (data is AnimationCurve)
                {
                    return(ApplyValueIfNotEqual(ref data, EditorGUILayout.CurveField(name, (AnimationCurve)data)));
                }
                else if (data is Rect)
                {
                    return(ApplyValueIfNotEqual(ref data, EditorGUILayout.RectField(name, (Rect)data)));
                }
#endif
                throw new NotImplementedException(type.ToString());
            }
            else
            {
                if (data is Bounds || data is AnimationCurve || data is Rect)
                {
                    GUITools.LabelField(name, data.ToString());
                }
                else
                {
                    GUITools.LabelField(name);
                }
                return(false);
            }
        }
        public override bool InspectSelf(Inspector inspector, string name, ref object data, Type type)
        {
            if (data == null)
            {
                GUITools.LabelField("null");
                GUILayout.FlexibleSpace();
                return(false);
            }

            if (ShowSize())
            {
                GUITools.LabelField("Count: " + Size(data));
            }

            GUILayout.FlexibleSpace();
            return(false);
        }
        private static bool InspectProperty(Inspector inspector, string path, ref object data,
                                            PropertyInfo propertyInfo)
        {
            if (propertyInfo.CanRead && CanInspect(propertyInfo))
            {
                object value;
                try
                {
                    value = propertyInfo.GetValue(data, null);
                }
                catch (Exception)
                {
                    return(false);
                }

                return(inspector.Inspect(propertyInfo.Name, path + "." + propertyInfo.Name, value));
            }
            else
            {
                GUITools.LabelField(propertyInfo.Name, "unreadable");
                return(false);
            }
        }
        public override bool InspectChildren(Inspector inspector, string path, ref object data, Type type)
        {
            var time = (DateTime)data;

            GUITools.LabelField("Unix Time Stamp", ToUnixTimestampString(time));

            var ticks = GUITools.LongField("Ticks", time.Ticks);
            var kind  = (DateTimeKind)GUITools.EnumPopup("Kind", time.Kind);

            if (ticks != time.Ticks || kind != time.Kind)
            {
                try
                {
                    data = new DateTime(ticks, kind);
                    return(true);
                }
                catch (Exception)
                {
                }
            }

            return(false);
        }
        // Boolean, Byte, SByte, Int16, UInt16, Int32, UInt32, Int64, UInt64, IntPtr, UIntPtr, Char, Double, and Single.
        public override bool InspectSelf(Inspector inspector, string name, ref object data, Type type)
        {
            object result;

            if (data == null)
            {
                GUITools.LabelField(name, "null");
                result = null;
            }
            else if (data is bool)
            {
                result = (bool)GUITools.Toggle(name, (bool)data);
            }
            else if (data is byte)
            {
                result = (byte)GUITools.IntField(name, (byte)data);
            }
            else if (data is sbyte)
            {
                result = (sbyte)GUITools.IntField(name, (sbyte)data);
            }
            else if (data is short)
            {
                result = (short)GUITools.IntField(name, (short)data);
            }
            else if (data is ushort)
            {
                result = (ushort)GUITools.IntField(name, (ushort)data);
            }
            else if (data is int)
            {
                result = (int)GUITools.IntField(name, (int)data);
            }
            else if (data is uint)
            {
                result = (uint)GUITools.LongField(name, (uint)data);
            }
            else if (data is long)
            {
                result = (long)ParseLong(GUITools.TextField(name, data.ToString()), (long)data);
            }
            else if (data is ulong)
            {
                result = (ulong)ParseULong(GUITools.TextField(name, data.ToString()), (ulong)data);
            }
            else if (data is IntPtr)
            {
                GUITools.TextField(name, data.ToString());
                result = data;
            }
            else if (data is UIntPtr)
            {
                GUITools.TextField(name, data.ToString());
                result = data;
            }
            else if (data is char)
            {
                result = (char)ParseChar(GUITools.TextField(name, data.ToString()), (char)data);
            }
            else if (data is float)
            {
                result = (float)GUITools.FloatField(name, (float)data);
            }
            else if (data is double)
            {
                result = (double)GUITools.DoubleField(name, (double)data);
            }
            else
            {
                throw new NotImplementedException(type.Name);
            }

            return(ApplyValueIfNotEqual(ref data, result));
        }