public override void OnGUI(Rect position, SerializedProperty property, GUIContent label) { var prefabProperty = property.FindPropertyRelative("prefab"); var parentProperty = property.FindPropertyRelative("parent"); EditorGUI.BeginProperty(position, label, property); position = EditorGUI.PrefixLabel(position, GUIUtility.GetControlID(FocusType.Passive), label); var indent = EditorGUI.indentLevel; EditorGUI.indentLevel = 0; var px = position.x; var py = position.y; var originLabelWidth = EditorLayoutTools.SetLabelWidth(50f); //====== Prefab ====== EditorGUI.BeginChangeCheck(); var prefabRect = new Rect(px, py, position.width, position.height * 0.5f); var prefab = (GameObject)EditorGUI.ObjectField(prefabRect, "Prefab", prefabProperty.objectReferenceValue, typeof(GameObject), false); if (EditorGUI.EndChangeCheck()) { prefabProperty.objectReferenceValue = prefab; property.serializedObject.ApplyModifiedProperties(); } //====== Parent ====== EditorGUI.BeginChangeCheck(); var parentRect = new Rect(px, py + position.height * 0.5f, position.width, position.height * 0.5f); var parent = (GameObject)EditorGUI.ObjectField(parentRect, "Parent", parentProperty.objectReferenceValue, typeof(GameObject), true); if (EditorGUI.EndChangeCheck()) { parentProperty.objectReferenceValue = parent; property.serializedObject.ApplyModifiedProperties(); } EditorGUI.indentLevel = indent; EditorLayoutTools.SetLabelWidth(originLabelWidth); EditorGUI.EndProperty(); }
protected override void CloseScope() { EditorLayoutTools.EndContents(); }
//----- params ----- //----- field ----- //----- property ----- //----- method ----- public ContentsScope() { EditorLayoutTools.BeginContents(); }