protected override void OnDrawColumnItem(Rect rect, int columnIndex, GridViewData columnItemData) { LogData logData = columnItemData.Userdata as LogData; Color textColor = Color.white; if (m_LogColorDic.TryGetValue(logData.Level, out textColor)) { } EGUI.BeginGUIColor(textColor); { if (columnIndex == 0) { GUI.Label(rect, logData.Level.ToString()); } else if (columnIndex == 1) { GUI.Label(rect, new DateTime(logData.Time).ToString()); } else if (columnIndex == 2) { GUI.Label(rect, logData.Tag); } else if (columnIndex == 3) { GUI.Label(rect, logData.Message); } else if (columnIndex == 4) { GUI.Label(rect, logData.StackTrace); } } EGUI.EndGUIColor(); }
public override void OnGUILayout() { var attr = GetAttr <ButtonAttribute>(); if (string.IsNullOrEmpty(attr.MethodName)) { EGUI.BeginGUIColor(Color.red); { EditorGUILayout.LabelField("The name of the method can't be empty."); } EGUI.EndGUIColor(); } else { string btnContentStr = string.IsNullOrEmpty(attr.Label) ? attr.MethodName : attr.Label; float height = EGUIUtility.singleLineHeight; if (attr.Size == ButtonSize.Big) { height *= 2; } else if (attr.Size == ButtonSize.Normal) { height *= 1.5f; } if (GUILayout.Button(btnContentStr, GUILayout.Height(height))) { MethodInfo methodInfo = Property.TargetType.GetMethod(attr.MethodName, BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance); if (methodInfo != null) { methodInfo.Invoke(Property.Target, null); } } } }
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(); }
protected virtual void OnDrawInvalidProperty(string label) { EGUI.BeginGUIColor(Color.red); { EditorGUILayout.LabelField(string.IsNullOrEmpty(label) ? "" : label, "Invalid"); } EGUI.EndGUIColor(); }
protected virtual void DrawInvalidContent() { EGUI.BeginGUIColor(Color.red); { EditorGUILayout.LabelField(ItemDrawer.Label, "Invalid"); } EGUI.EndGUIColor(); }
public override void OnGUILayout() { EGUI.BeginGUIColor(Color.red); { EditorGUILayout.LabelField(Label, $"The \"{TargetType.Name}\" is not supported!"); } EGUI.EndGUIColor(); }
internal static void OnDrawSetting() { EGUILayout.DrawHorizontalSpace(8); EGUI.BeginGUIColor(Color.grey); { EditorGUILayout.BeginVertical(EditorStyles.helpBox); { EGUILayout.DrawBoxHeader("Native Drawer Setting", GUILayout.ExpandWidth(true)); EGUI.BeginIndent(); { IsShowHelp = EditorGUILayout.Toggle("Is Show Help", IsShowHelp); } EGUI.EndIndent(); } EditorGUILayout.EndVertical(); } EGUI.EndGUIColor(); EGUILayout.DrawHorizontalSpace(8); }
public override void OnGUILayout() { if (!GetVisible()) { return; } if (isNeedRefresh) { RefreshDrawer(); isNeedRefresh = false; } foreach (var drawer in layoutAttrDrawers) { if (drawer.Occasion == LayoutOccasion.Before) { drawer.OnGUILayout(); } } foreach (var drawer in decoratorAttrDrawers) { drawer.OnGUILayout(); } object value = Value; if (value == null) { EditorGUILayout.BeginHorizontal(); { EditorGUILayout.LabelField(Label, GUILayout.Width(EditorGUIUtility.labelWidth)); if (GUILayout.Button("Create")) { Value = DrawerUtility.GetTypeInstance(ValueType); RefreshDrawer(); } } EditorGUILayout.EndHorizontal(); } else if (innerDrawer != null) { innerDrawer.OnGUILayout(); } else { EGUI.BeginGUIColor(Color.red); { EditorGUILayout.LabelField(Label, $"The drawer of {ValueType} is not found"); } EGUI.EndGUIColor(); } foreach (var drawer in layoutAttrDrawers) { if (drawer.Occasion == LayoutOccasion.After) { drawer.OnGUILayout(); } } }
internal void OnGUILayout() { foreach (var drawer in layoutDrawers) { LayoutAttribute attr = drawer.GetAttr <LayoutAttribute>(); if (attr.Occasion == LayoutOccasion.Before) { drawer.OnGUILayout(); } } bool isVisible = IsVisible(); if (isVisible) { foreach (var drawer in controlDrawers) { drawer.OnStartGUILayout(); } foreach (var drawer in decoratorDrawers) { drawer.OnGUILayout(); } foreach (var drawer in verificationDrawers) { drawer.OnGUILayout(); } string label = FieldName; if (labelDrawer != null) { label = labelDrawer.GetLabel(); } if (!string.IsNullOrEmpty(label)) { label = UnityEditor.ObjectNames.NicifyVariableName(label); } if (contentDrawer != null) { contentDrawer.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 (!DrawerUtility.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 = DrawerUtility.CreateInstance(ValueType); if (DrawerUtility.IsTypeSupported(ValueType)) { if (ValueType.IsStructOrClassType() && Value != null) { drawerObject = new DrawerObject(Value); } } } } UnityEditor.EditorGUILayout.EndHorizontal(); } else { EGUI.BeginGUIColor(UnityEngine.Color.red); { UnityEditor.EditorGUILayout.LabelField(string.IsNullOrEmpty(label) ? "" : label, "Unknown Drawer"); } EGUI.EndGUIColor(); } } foreach (var drawer in controlDrawers) { drawer.OnEndGUILayout(); } } foreach (var drawer in layoutDrawers) { LayoutAttribute attr = drawer.GetAttr <LayoutAttribute>(); if (attr.Occasion == LayoutOccasion.After) { drawer.OnGUILayout(); } } }
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(); } } }