internal void ClearArrayElement() { if (TypeUtility.IsArrayOrList(ValueType)) { if (ValueType.IsArray) { Value = NativeDrawerUtility.CreateDefaultInstance(ValueType); } else { ((IList)Value).Clear(); } } }
internal void AddArrayElement() { if (TypeUtility.IsArrayOrList(ValueType)) { object element = NativeDrawerUtility.CreateDefaultInstance(TypeUtility.GetArrayOrListElementType(ValueType)); if (ValueType.IsArray) { Array array = (Array)Value; ArrayUtility.Add(ref array, element); Value = array; } else { ((IList)Value).Add(element); } } }
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(); } } }