public override void OnInspectorGUI() { EGUILayout.DrawScript(target); EditorGUILayout.Space(); EGUI.BeginGUIColor(Color.grey); { EditorGUILayout.BeginVertical(EditorStyles.helpBox); { EGUILayout.DrawBoxHeader("Native Drawer Setting", GUILayout.ExpandWidth(true)); EGUI.BeginIndent(); { NativeDrawerSetting.IsShowHelp = EditorGUILayout.Toggle("Is Show Help", NativeDrawerSetting.IsShowHelp); } EGUI.EndIndent(); } EditorGUILayout.EndVertical(); } EGUI.EndGUIColor(); EditorGUILayout.Space(); EGUI.BeginLabelWidth(GetLabelWidth()); { drawerObject.OnGUILayout(); } EGUI.EndLableWidth(); }
internal void OnGUILayout() { bool isVisible = IsVisible(); foreach (var drawer in layoutDrawers) { drawer.OnGUILayout(); } if (isVisible) { foreach (var drawer in decoratorDrawers) { drawer.OnGUILayout(); } foreach (var drawer in verificationDrawers) { drawer.OnGUILayout(); } foreach (var drawer in propertyControlDrawers) { drawer.OnStartGUILayout(); } string label = GetFieldLabel(); if (!string.IsNullOrEmpty(label)) { label = UnityEditor.ObjectNames.NicifyVariableName(label); } if (propertyDrawers.Count == 0) { if (typeDrawer != null) { typeDrawer.OnGUILayout(label); } else if (drawerObject != null) { if (!IsArrayElement) { UnityEditor.EditorGUILayout.LabelField(label); UnityEditor.EditorGUI.indentLevel++; { drawerObject.OnGUILayout(); } UnityEditor.EditorGUI.indentLevel--; } else { UnityEditor.EditorGUILayout.BeginHorizontal(); { UnityEditor.EditorGUILayout.LabelField(label, UnityEngine.GUILayout.Width(25)); UnityEditor.EditorGUILayout.BeginVertical(); { drawerObject.OnGUILayout(); } UnityEditor.EditorGUILayout.EndVertical(); } UnityEditor.EditorGUILayout.EndHorizontal(); } } else if (drawerObject == null) { if (!NativeDrawerUtility.IsTypeSupported(ValueType)) { EGUI.BeginGUIColor(UnityEngine.Color.red); { UnityEditor.EditorGUILayout.LabelField(string.IsNullOrEmpty(label) ? "" : label, $"The type isn't supported.type = {ValueType}"); } EGUI.EndGUIColor(); } else if (Value == null) { UnityEditor.EditorGUILayout.BeginHorizontal(); { UnityEditor.EditorGUILayout.PrefixLabel(label); if (UnityEngine.GUILayout.Button("Create")) { Value = NativeDrawerUtility.CreateDefaultInstance(ValueType); InitDrawer(); } } UnityEditor.EditorGUILayout.EndHorizontal(); } else { EGUI.BeginGUIColor(UnityEngine.Color.red); { UnityEditor.EditorGUILayout.LabelField(string.IsNullOrEmpty(label) ? "" : label, "Unknown Drawer"); } EGUI.EndGUIColor(); } } } else { foreach (var drawer in propertyDrawers) { drawer.OnGUILayout(label); } } foreach (var drawer in propertyControlDrawers) { drawer.OnEndGUILayout(); } } }