コード例 #1
0
        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();
            }
        }
コード例 #2
0
        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();
        }
コード例 #3
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();
        }
コード例 #4
0
 public override void OnInspectorGUI()
 {
     ObjectDrawerHelper.Draw(((ObjectView)this.target).Obj);
 }