public void Draw(object value, FieldInfo field = null)
        {
            this.type = value.GetType();
            this.name = field == null ? this.type.Name : field.Name;
            this.v    = (Delegate)value;
            this.fold = ObjectDrawerHelper.GetAndAddFold(value);
            this.fold = EditorGUILayout.Foldout(this.fold, this.name, true);
            ObjectDrawerHelper.SetAndAddFold(value, this.fold);
            if (!this.fold)
            {
                return;
            }

            var ds = this.v.GetInvocationList();

            this.len = ds.Length / 10 + 1;
            for (var i = 0; i < ds.Length; i++)
            {
                this.d = ds[i];
                EditorGUILayout.BeginHorizontal();
                ObjectDrawerHelper.Tab();
                EditorGUILayout.LabelField("Delegate:", GUILayout.Width(60));
                EditorGUILayout.LabelField($"{i}", GUILayout.Width(this.len * 5 + 15));
                EditorGUILayout.LabelField($"{this.d.Method.ReflectedType}.{this.d.Method.Name}");
                EditorGUILayout.EndHorizontal();
            }
        }
        public void Draw(object value, FieldInfo field = null)
        {
            this.type = value.GetType();
            this.name = field == null ? this.type.Name : field.Name;
            this.v    = (ICollection)value;
            this.fold = ObjectDrawerHelper.GetAndAddFold(value);
            this.fold = EditorGUILayout.Foldout(this.fold, this.name, true);
            ObjectDrawerHelper.SetAndAddFold(value, this.fold);
            if (!this.fold)
            {
                return;
            }

            EditorGUILayout.BeginHorizontal();
            EditorGUILayout.LabelField("数量:", GUILayout.Width(60));
            EditorGUILayout.LabelField(this.v.Count.ToString());
            EditorGUILayout.EndHorizontal();

            this.list.Clear();
            foreach (var item in this.v)
            {
                this.list.Add(item);
            }

            for (var i = 0; i < this.list.Count; i++)
            {
                EditorGUILayout.BeginHorizontal();
                ObjectDrawerHelper.Tab();
                EditorGUILayout.LabelField("Element:", GUILayout.Width(60));
                ObjectDrawerHelper.Draw(this.list[i]);
                EditorGUILayout.EndHorizontal();
            }
        }
        public void Draw(object value, FieldInfo field = null)
        {
            this.type = value.GetType();
            if (field != null)
            {
                EditorGUILayout.LabelField(field.Name);
            }

            EditorGUILayout.BeginHorizontal();
            EditorGUILayout.LabelField("Key:", GUILayout.Width(50));
            ObjectDrawerHelper.Draw(this.type.GetProperty("Key")?.GetValue(value));
            EditorGUILayout.EndHorizontal();
            EditorGUILayout.BeginHorizontal();
            EditorGUILayout.LabelField("Value:", GUILayout.Width(60));
            ObjectDrawerHelper.Draw(this.type.GetProperty("Value")?.GetValue(value));
            EditorGUILayout.EndHorizontal();
        }
예제 #4
0
        public void Draw(object value, FieldInfo field = null)
        {
            this.type = value.GetType();
            this.name = field == null ? this.type.Name : field.Name;
            this.fold = ObjectDrawerHelper.GetAndAddFold(value);
            this.fold = EditorGUILayout.Foldout(this.fold, this.name, true);
            ObjectDrawerHelper.SetAndAddFold(value, this.fold);
            if (!this.fold)
            {
                return;
            }

            EditorGUILayout.BeginHorizontal();
            ObjectDrawerHelper.Tab();

            this.fieldInfos = this.type.GetFields(bindingFlags);
            this.fs.Clear();
            for (var i = 0; i < this.fieldInfos.Length; i++)
            {
                this.f = this.fieldInfos[i];
                //剔除值为自己的字段
                if ((this.f.FieldType == this.type || this.type.IsSubclassOf(this.f.FieldType) || this.f.FieldType.IsSubclassOf(this.type)) && this.f.GetValue(value) == value)
                {
                    continue;
                }

                this.fs.Add(this.f);
            }

            EditorGUILayout.BeginVertical();
            if (this.fs.Count > 0)
            {
                for (var i = 0; i < this.fs.Count; i++)
                {
                    this.f = this.fs[i];
                    ObjectDrawerHelper.Draw(this.f.GetValue(value), this.f);
                }
            }

            EditorGUILayout.EndVertical();

            EditorGUILayout.EndHorizontal();
        }
 public override void OnInspectorGUI()
 {
     ObjectDrawerHelper.Draw(((ObjectView)this.target).Obj);
 }