Quantcast
Channel: Questions in topic: "gui"
Viewing all articles
Browse latest Browse all 125

How to make Fold Attribute by propertyDrawer?

$
0
0
I can make only one line but i want it stick with same fold name using System.Collections; using System.Collections.Generic; using System; using UnityEngine; using UnityEditor; public class FoldAttribute : PropertyAttribute { public string name; public FoldAttribute(string name) { this.name = name; } } [CustomPropertyDrawer(typeof(FoldAttribute))] public class FoldDrawer : PropertyDrawer { #region Overrides of Decorator Drawer /// public override void OnGUI(Rect position, SerializedProperty property, GUIContent label) { FoldAttribute foldAttribute = (FoldAttribute)attribute; var Title= property.name; //Debug.Log( Type.GetType(foldAttribute.name)); property.isExpanded = EditorGUI.BeginFoldoutHeaderGroup(position, property.isExpanded, foldAttribute.name, null, null, GUIStyle.none); EditorGUILayout.Space(); if (property.isExpanded) { EditorGUI.BeginProperty(position, label, property); EditorGUI.PropertyField(new Rect(position.x, position.y + 20, position.width, EditorGUIUtility.singleLineHeight), property, new GUIContent(property.name)); property.serializedObject.ApplyModifiedProperties(); EditorGUI.EndProperty(); } EditorGUI.EndFoldoutHeaderGroup(); } public override float GetPropertyHeight(SerializedProperty property, GUIContent label) { if (property.isExpanded) { return EditorGUIUtility.singleLineHeight + // the foldout //(property.serializedObject.) * // for each related obj: (EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing); } else { return EditorGUIUtility.singleLineHeight; } } #endregion }

Viewing all articles
Browse latest Browse all 125

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>