public override void SceneHandle(MonoComponentInspector inspector, FieldInspector fieldInspector) { if (fieldInspector.Field.FieldType == typeof(Bounds)) { Bounds value = (Bounds)fieldInspector.Field.GetValue(inspector.target); BoundsHandle.center = value.center; BoundsHandle.size = value.size; using (new Handles.DrawingScope(fieldInspector.UseColor)) { EditorGUI.BeginChangeCheck(); BoundsHandle.DrawHandle(); if (EditorGUI.EndChangeCheck()) { Undo.RecordObject(inspector.target, "Bounds Handler"); value.center = BoundsHandle.center; value.size = BoundsHandle.size; fieldInspector.Field.SetValue(inspector.target, value); inspector.HasChanged(); } if (BAttribute.Display != null) { Handles.Label(BoundsHandle.center, BAttribute.Display); } } } }
public override void SceneHandle(MonoComponentInspector inspector, FieldInspector fieldInspector) { if (fieldInspector.Field.FieldType == typeof(Vector3)) { Vector3 value = (Vector3)fieldInspector.Field.GetValue(inspector.target); if (value != Vector3.zero) { using (new Handles.DrawingScope(fieldInspector.UseColor)) { ExternalSize = GetExternalSize(inspector.target); InternalSize = GetInternalSize(inspector.target); Handles.CircleHandleCap(0, Position, Quaternion.FromToRotation(Vector3.forward, value), ExternalSize, EventType.Repaint); Handles.CircleHandleCap(0, Position, Quaternion.FromToRotation(Vector3.forward, value), InternalSize, EventType.Repaint); Handles.Slider(Position, value); } } } else if (fieldInspector.Field.FieldType == typeof(Vector2)) { Vector2 value = (Vector2)fieldInspector.Field.GetValue(inspector.target); if (value != Vector2.zero) { using (new Handles.DrawingScope(fieldInspector.UseColor)) { ExternalSize = GetExternalSize(inspector.target); InternalSize = GetInternalSize(inspector.target); Handles.CircleHandleCap(0, Position, Quaternion.FromToRotation(Vector3.forward, value), ExternalSize, EventType.Repaint); Handles.CircleHandleCap(0, Position, Quaternion.FromToRotation(Vector3.forward, value), InternalSize, EventType.Repaint); Handles.Slider(Position, value); } } } }
public override void Draw(MonoComponentInspector inspector, FieldInspector fieldInspector) { if (fieldInspector.Field.FieldType == typeof(string)) { string value = (string)fieldInspector.Field.GetValue(inspector.target); if (value == null) { value = ""; } GUILayout.BeginHorizontal(); EditorGUI.BeginChangeCheck(); string newValue = EditorGUILayout.PasswordField(fieldInspector.Label, value); if (EditorGUI.EndChangeCheck()) { Undo.RecordObject(inspector.target, "Password"); fieldInspector.Field.SetValue(inspector.target, newValue); inspector.HasChanged(); } GUILayout.EndHorizontal(); } else { GUILayout.BeginHorizontal(); EditorGUILayout.HelpBox("[" + fieldInspector.Field.Name + "] can't used Password! because the types don't match!", MessageType.Error); GUILayout.EndHorizontal(); } }
public void GenerateList(FieldInspector fieldInspector) { List = new UReorderableList(fieldInspector.Property.serializedObject, fieldInspector.Property, true, true, true, true); List.drawHeaderCallback = (Rect rect) => { EditorGUI.LabelField(rect, string.Format("{0}: {1}", fieldInspector.Label, fieldInspector.Property.arraySize), EditorStyles.boldLabel); }; List.drawElementCallback = (Rect rect, int index, bool isActive, bool isFocused) => { SerializedProperty element = fieldInspector.Property.GetArrayElementAtIndex(index); rect.x += 10; rect.y += 2; rect.width -= 10; EditorGUI.PropertyField(rect, element, true); }; List.drawElementBackgroundCallback = (Rect rect, int index, bool isActive, bool isFocused) => { if (UnityEngine.Event.current.type == EventType.Repaint) { GUIStyle gUIStyle = (index % 2 != 0) ? "CN EntryBackEven" : "CN EntryBackodd"; gUIStyle = (!isActive && !isFocused) ? gUIStyle : "RL Element"; rect.x += 2; rect.width -= 6; gUIStyle.Draw(rect, false, isActive, isActive, isFocused); } }; List.elementHeightCallback = (int index) => { return(EditorGUI.GetPropertyHeight(fieldInspector.Property.GetArrayElementAtIndex(index)) + 6); }; }
public override void Draw(MonoComponentInspector inspector, FieldInspector fieldInspector) { if (DAttribute.ValueType == fieldInspector.Field.FieldType) { object value = fieldInspector.Field.GetValue(inspector.target); int selectIndex = Array.IndexOf(DAttribute.Values, value); if (selectIndex < 0) { selectIndex = 0; } GUILayout.BeginHorizontal(); EditorGUI.BeginChangeCheck(); int newIndex = EditorGUILayout.Popup(fieldInspector.Label, selectIndex, DAttribute.DisplayOptions); if (EditorGUI.EndChangeCheck()) { Undo.RecordObject(inspector.target, "Dropdown"); fieldInspector.Field.SetValue(inspector.target, DAttribute.Values[newIndex]); inspector.HasChanged(); } GUILayout.EndHorizontal(); } else { GUILayout.BeginHorizontal(); EditorGUILayout.HelpBox("[" + fieldInspector.Field.Name + "] used a mismatched Dropdown!", MessageType.Error); GUILayout.EndHorizontal(); } }
public override void Draw(MonoComponentInspector inspector, FieldInspector fieldInspector) { if (fieldInspector.Field.FieldType == typeof(string)) { string value = (string)fieldInspector.Field.GetValue(inspector.target); int layer = LayerMask.NameToLayer(value); if (layer < 0) { layer = 0; } if (layer > 31) { layer = 31; } GUILayout.BeginHorizontal(); EditorGUI.BeginChangeCheck(); int newLayer = EditorGUILayout.LayerField(fieldInspector.Label, layer); if (EditorGUI.EndChangeCheck()) { Undo.RecordObject(inspector.target, "Layer"); fieldInspector.Field.SetValue(inspector.target, LayerMask.LayerToName(newLayer)); inspector.HasChanged(); } GUILayout.EndHorizontal(); } else if (fieldInspector.Field.FieldType == typeof(int)) { int layer = (int)fieldInspector.Field.GetValue(inspector.target); if (layer < 0) { layer = 0; } if (layer > 31) { layer = 31; } GUILayout.BeginHorizontal(); EditorGUI.BeginChangeCheck(); int newLayer = EditorGUILayout.LayerField(fieldInspector.Label, layer); if (EditorGUI.EndChangeCheck()) { Undo.RecordObject(inspector.target, "Layer"); fieldInspector.Field.SetValue(inspector.target, newLayer); inspector.HasChanged(); } GUILayout.EndHorizontal(); } else { GUILayout.BeginHorizontal(); EditorGUILayout.HelpBox("[" + fieldInspector.Field.Name + "] can't used Layer! because the types don't match!", MessageType.Error); GUILayout.EndHorizontal(); } }
public override void SceneHandle(MonoComponentInspector inspector, FieldInspector fieldInspector) { if (fieldInspector.Field.FieldType == typeof(float)) { Component component = inspector.target as Component; Vector3 center = component != null ? component.transform.position : Vector3.zero; float value = (float)fieldInspector.Field.GetValue(inspector.target); using (new Handles.DrawingScope(fieldInspector.UseColor)) { EditorGUI.BeginChangeCheck(); float newValue = Handles.RadiusHandle(Quaternion.identity, center, value); if (EditorGUI.EndChangeCheck()) { Undo.RecordObject(inspector.target, "Radius Handler"); fieldInspector.Field.SetValue(inspector.target, newValue); inspector.HasChanged(); } if (RAttribute.Display != null) { Handles.Label(center, RAttribute.Display); } } } else if (fieldInspector.Field.FieldType == typeof(int)) { Component component = inspector.target as Component; Vector3 center = component != null ? component.transform.position : Vector3.zero; int value = (int)fieldInspector.Field.GetValue(inspector.target); using (new Handles.DrawingScope(fieldInspector.UseColor)) { EditorGUI.BeginChangeCheck(); int newValue = (int)Handles.RadiusHandle(Quaternion.identity, center, value); if (EditorGUI.EndChangeCheck()) { Undo.RecordObject(inspector.target, "Radius Handler"); fieldInspector.Field.SetValue(inspector.target, newValue); inspector.HasChanged(); } if (RAttribute.Display != null) { Handles.Label(center, RAttribute.Display); } } } }
public override void SceneHandle(MonoComponentInspector inspector, FieldInspector fieldInspector) { if (fieldInspector.Field.FieldType == typeof(float)) { float value = (float)fieldInspector.Field.GetValue(inspector.target); using (new Handles.DrawingScope(fieldInspector.UseColor)) { Position = GetPosition(inspector.target); Size = GetSize(inspector.target, value); Handles.CircleHandleCap(0, Position, Rotation, Size, EventType.Repaint); if (Target) { Handles.Slider(Position, Target.forward); } } } }
public override void Draw(MonoComponentInspector inspector, FieldInspector fieldInspector) { if (fieldInspector.Property.isArray) { if (List == null) { GenerateList(fieldInspector); } List.DoLayoutList(); } else { GUILayout.BeginHorizontal(); EditorGUILayout.HelpBox("[" + fieldInspector.Field.Name + "] can't use the ReorderableList!", MessageType.Error); GUILayout.EndHorizontal(); } }
public override void SceneHandle(MonoComponentInspector inspector, FieldInspector fieldInspector) { if (fieldInspector.Field.FieldType == typeof(Vector3)) { Vector3 value = (Vector3)fieldInspector.Field.GetValue(inspector.target); using (new Handles.DrawingScope(fieldInspector.UseColor)) { EditorGUI.BeginChangeCheck(); Vector3 newValue = Handles.PositionHandle(value, Quaternion.identity); if (EditorGUI.EndChangeCheck()) { Undo.RecordObject(inspector.target, "Move Handler"); fieldInspector.Field.SetValue(inspector.target, newValue); inspector.HasChanged(); } if (MAttribute.Display != null) { Handles.Label(newValue, MAttribute.Display); } } } else if (fieldInspector.Field.FieldType == typeof(Vector2)) { Vector2 value = (Vector2)fieldInspector.Field.GetValue(inspector.target); using (new Handles.DrawingScope(fieldInspector.UseColor)) { EditorGUI.BeginChangeCheck(); Vector2 newValue = Handles.PositionHandle(value, Quaternion.identity); if (EditorGUI.EndChangeCheck()) { Undo.RecordObject(inspector.target, "Move Handler"); fieldInspector.Field.SetValue(inspector.target, newValue); inspector.HasChanged(); } if (MAttribute.Display != null) { Handles.Label(newValue, MAttribute.Display); } } } }
public override void Draw(MonoComponentInspector inspector, FieldInspector fieldInspector) { if (fieldInspector.Field.FieldType == typeof(string)) { GUILayout.BeginHorizontal(); bool isClick = (bool)LinkLabel.Invoke(null, Parameter); if (isClick) { Application.OpenURL((string)fieldInspector.Field.GetValue(inspector.target)); } GUILayout.EndHorizontal(); } else { GUILayout.BeginHorizontal(); EditorGUILayout.HelpBox("[" + fieldInspector.Field.Name + "] can't used Hyperlink! because the types don't match!", MessageType.Error); GUILayout.EndHorizontal(); } }
public override void Draw(MonoComponentInspector inspector, FieldInspector fieldInspector) { if (fieldInspector.Field.FieldType == typeof(string)) { string value = (string)fieldInspector.Field.GetValue(inspector.target); if (value == null) { value = ""; } GUILayout.BeginHorizontal(); EditorGUI.BeginChangeCheck(); string newValue = EditorGUILayout.TextField(fieldInspector.Label, value); if (EditorGUI.EndChangeCheck()) { Undo.RecordObject(inspector.target, "FolderPath"); fieldInspector.Field.SetValue(inspector.target, newValue); inspector.HasChanged(); } if (GUILayout.Button(OpenGC, "IconButton", GUILayout.Width(20), GUILayout.Height(EditorGUIUtility.singleLineHeight))) { string path = EditorUtility.OpenFolderPanel("Select Folder", Application.dataPath, ""); if (path.Length != 0) { Undo.RecordObject(inspector.target, "FolderPath"); fieldInspector.Field.SetValue(inspector.target, "Assets" + path.Replace(Application.dataPath, "")); inspector.HasChanged(); } } GUILayout.EndHorizontal(); } else { GUILayout.BeginHorizontal(); EditorGUILayout.HelpBox("[" + fieldInspector.Field.Name + "] can't used FolderPath! because the types don't match!", MessageType.Error); GUILayout.EndHorizontal(); } }
public abstract void SceneHandle(MonoComponentInspector inspector, FieldInspector fieldInspector);
public abstract void Draw(MonoComponentInspector inspector, FieldInspector fieldInspector);