internal static bool DefaultPropertyField(Rect position, SerializedProperty property, GUIContent label) { label = EditorGUI.BeginProperty(position, label, property); SerializedPropertyType propertyType = property.propertyType; bool flag = false; if (!EditorGUI.HasVisibleChildFields(property)) { switch (propertyType) { case SerializedPropertyType.Integer: { EditorGUI.BeginChangeCheck(); long longValue = EditorGUI.LongField(position, label, property.longValue); if (EditorGUI.EndChangeCheck()) { property.longValue = longValue; } break; } case SerializedPropertyType.Boolean: { EditorGUI.BeginChangeCheck(); bool boolValue = EditorGUI.Toggle(position, label, property.boolValue); if (EditorGUI.EndChangeCheck()) { property.boolValue = boolValue; } break; } case SerializedPropertyType.Float: { EditorGUI.BeginChangeCheck(); bool flag2 = property.type == "float"; double doubleValue = (!flag2) ? EditorGUI.DoubleField(position, label, property.doubleValue) : ((double)EditorGUI.FloatField(position, label, property.floatValue)); if (EditorGUI.EndChangeCheck()) { property.doubleValue = doubleValue; } break; } case SerializedPropertyType.String: { EditorGUI.BeginChangeCheck(); string stringValue = EditorGUI.TextField(position, label, property.stringValue); if (EditorGUI.EndChangeCheck()) { property.stringValue = stringValue; } break; } case SerializedPropertyType.Color: { EditorGUI.BeginChangeCheck(); Color colorValue = EditorGUI.ColorField(position, label, property.colorValue); if (EditorGUI.EndChangeCheck()) { property.colorValue = colorValue; } break; } case SerializedPropertyType.ObjectReference: EditorGUI.ObjectFieldInternal(position, property, null, label, EditorStyles.objectField); break; case SerializedPropertyType.LayerMask: EditorGUI.LayerMaskField(position, property, label); break; case SerializedPropertyType.Enum: EditorGUI.Popup(position, property, label); break; case SerializedPropertyType.Vector2: EditorGUI.Vector2Field(position, property, label); break; case SerializedPropertyType.Vector3: EditorGUI.Vector3Field(position, property, label); break; case SerializedPropertyType.Vector4: EditorGUI.Vector4Field(position, property, label); break; case SerializedPropertyType.Rect: EditorGUI.RectField(position, property, label); break; case SerializedPropertyType.ArraySize: { EditorGUI.BeginChangeCheck(); int intValue = EditorGUI.ArraySizeField(position, label, property.intValue, EditorStyles.numberField); if (EditorGUI.EndChangeCheck()) { property.intValue = intValue; } break; } case SerializedPropertyType.Character: { char[] value = new char[] { (char)property.intValue }; bool changed = GUI.changed; GUI.changed = false; string text = EditorGUI.TextField(position, label, new string(value)); if (GUI.changed) { if (text.Length == 1) { property.intValue = (int)text[0]; } else { GUI.changed = false; } } GUI.changed |= changed; break; } case SerializedPropertyType.AnimationCurve: { int controlID = GUIUtility.GetControlID(EditorGUI.s_CurveHash, EditorGUIUtility.native, position); EditorGUI.DoCurveField(EditorGUI.PrefixLabel(position, controlID, label), controlID, null, EditorGUI.kCurveColor, default(Rect), property); break; } case SerializedPropertyType.Bounds: EditorGUI.BoundsField(position, property, label); break; case SerializedPropertyType.Gradient: { int controlID2 = GUIUtility.GetControlID(EditorGUI.s_CurveHash, EditorGUIUtility.native, position); EditorGUI.DoGradientField(EditorGUI.PrefixLabel(position, controlID2, label), controlID2, null, property); break; } default: { int controlID3 = GUIUtility.GetControlID(EditorGUI.s_GenericField, FocusType.Keyboard, position); EditorGUI.PrefixLabel(position, controlID3, label); break; } } } else { Event @event = new Event(Event.current); flag = property.isExpanded; EditorGUI.BeginDisabledGroup(!property.editable); GUIStyle style = (DragAndDrop.activeControlID != -10) ? EditorStyles.foldout : EditorStyles.foldoutPreDrop; bool flag3 = EditorGUI.Foldout(position, flag, EditorGUI.s_PropertyFieldTempContent, true, style); EditorGUI.EndDisabledGroup(); if (flag3 != flag) { if (Event.current.alt) { EditorGUI.SetExpandedRecurse(property, flag3); } else { property.isExpanded = flag3; } } flag = flag3; int s_LastControlID = EditorGUIUtility.s_LastControlID; EventType type = @event.type; if (type != EventType.DragUpdated && type != EventType.DragPerform) { if (type == EventType.DragExited) { if (GUI.enabled) { HandleUtility.Repaint(); } } } else { if (position.Contains(@event.mousePosition) && GUI.enabled) { UnityEngine.Object[] objectReferences = DragAndDrop.objectReferences; UnityEngine.Object[] array = new UnityEngine.Object[1]; bool flag4 = false; UnityEngine.Object[] array2 = objectReferences; for (int i = 0; i < array2.Length; i++) { UnityEngine.Object @object = array2[i]; array[0] = @object; UnityEngine.Object object2 = EditorGUI.ValidateObjectFieldAssignment(array, null, property); if (object2 != null) { DragAndDrop.visualMode = DragAndDropVisualMode.Copy; if (@event.type == EventType.DragPerform) { property.AppendFoldoutPPtrValue(object2); flag4 = true; DragAndDrop.activeControlID = 0; } else { DragAndDrop.activeControlID = s_LastControlID; } } } if (flag4) { GUI.changed = true; DragAndDrop.AcceptDrag(); } } } } EditorGUI.EndProperty(); return flag; }
internal static bool DefaultPropertyField(Rect position, SerializedProperty property, GUIContent label) { label = EditorGUI.BeginProperty(position, label, property); SerializedPropertyType propertyType = property.propertyType; bool flag1 = false; if (!EditorGUI.HasVisibleChildFields(property)) { switch (propertyType) { case SerializedPropertyType.Integer: EditorGUI.BeginChangeCheck(); long num1 = EditorGUI.LongField(position, label, property.longValue); if (EditorGUI.EndChangeCheck()) { property.longValue = num1; break; } break; case SerializedPropertyType.Boolean: EditorGUI.BeginChangeCheck(); bool flag2 = EditorGUI.Toggle(position, label, property.boolValue); if (EditorGUI.EndChangeCheck()) { property.boolValue = flag2; break; } break; case SerializedPropertyType.Float: EditorGUI.BeginChangeCheck(); double num2 = !(property.type == "float") ? EditorGUI.DoubleField(position, label, property.doubleValue) : (double) EditorGUI.FloatField(position, label, property.floatValue); if (EditorGUI.EndChangeCheck()) { property.doubleValue = num2; break; } break; case SerializedPropertyType.String: EditorGUI.BeginChangeCheck(); string str1 = EditorGUI.TextField(position, label, property.stringValue); if (EditorGUI.EndChangeCheck()) { property.stringValue = str1; break; } break; case SerializedPropertyType.Color: EditorGUI.BeginChangeCheck(); Color color = EditorGUI.ColorField(position, label, property.colorValue); if (EditorGUI.EndChangeCheck()) { property.colorValue = color; break; } break; case SerializedPropertyType.ObjectReference: EditorGUI.ObjectFieldInternal(position, property, (System.Type) null, label, EditorStyles.objectField); break; case SerializedPropertyType.LayerMask: EditorGUI.LayerMaskField(position, property, label); break; case SerializedPropertyType.Enum: EditorGUI.Popup(position, property, label); break; case SerializedPropertyType.Vector2: EditorGUI.Vector2Field(position, property, label); break; case SerializedPropertyType.Vector3: EditorGUI.Vector3Field(position, property, label); break; case SerializedPropertyType.Vector4: EditorGUI.Vector4Field(position, property, label); break; case SerializedPropertyType.Rect: EditorGUI.RectField(position, property, label); break; case SerializedPropertyType.ArraySize: EditorGUI.BeginChangeCheck(); int num3 = EditorGUI.ArraySizeField(position, label, property.intValue, EditorStyles.numberField); if (EditorGUI.EndChangeCheck()) { property.intValue = num3; break; } break; case SerializedPropertyType.Character: char[] chArray = new char[1] { (char) property.intValue }; bool changed = GUI.changed; GUI.changed = false; string str2 = EditorGUI.TextField(position, label, new string(chArray)); if (GUI.changed) { if (str2.Length == 1) property.intValue = (int) str2[0]; else GUI.changed = false; } GUI.changed |= changed; break; case SerializedPropertyType.AnimationCurve: int controlId1 = GUIUtility.GetControlID(EditorGUI.s_CurveHash, EditorGUIUtility.native, position); EditorGUI.DoCurveField(EditorGUI.PrefixLabel(position, controlId1, label), controlId1, (AnimationCurve) null, EditorGUI.kCurveColor, new Rect(), property); break; case SerializedPropertyType.Bounds: EditorGUI.BoundsField(position, property, label); break; case SerializedPropertyType.Gradient: int controlId2 = GUIUtility.GetControlID(EditorGUI.s_CurveHash, EditorGUIUtility.native, position); EditorGUI.DoGradientField(EditorGUI.PrefixLabel(position, controlId2, label), controlId2, (Gradient) null, property); break; default: int controlId3 = GUIUtility.GetControlID(EditorGUI.s_GenericField, FocusType.Keyboard, position); EditorGUI.PrefixLabel(position, controlId3, label); break; } } else { Event @event = new Event(Event.current); bool isExpanded = property.isExpanded; EditorGUI.BeginDisabledGroup(!property.editable); GUIStyle style = DragAndDrop.activeControlID != -10 ? EditorStyles.foldout : EditorStyles.foldoutPreDrop; bool expanded = EditorGUI.Foldout(position, isExpanded, EditorGUI.s_PropertyFieldTempContent, true, style); EditorGUI.EndDisabledGroup(); if (expanded != isExpanded) { if (Event.current.alt) EditorGUI.SetExpandedRecurse(property, expanded); else property.isExpanded = expanded; } flag1 = expanded; int lastControlId = EditorGUIUtility.s_LastControlID; switch (@event.type) { case EventType.DragUpdated: case EventType.DragPerform: if (position.Contains(@event.mousePosition) && GUI.enabled) { UnityEngine.Object[] objectReferences = DragAndDrop.objectReferences; UnityEngine.Object[] references = new UnityEngine.Object[1]; bool flag3 = false; foreach (UnityEngine.Object object1 in objectReferences) { references[0] = object1; UnityEngine.Object object2 = EditorGUI.ValidateObjectFieldAssignment(references, (System.Type) null, property); if (object2 != (UnityEngine.Object) null) { DragAndDrop.visualMode = DragAndDropVisualMode.Copy; if (@event.type == EventType.DragPerform) { property.AppendFoldoutPPtrValue(object2); flag3 = true; DragAndDrop.activeControlID = 0; } else DragAndDrop.activeControlID = lastControlId; } } if (flag3) { GUI.changed = true; DragAndDrop.AcceptDrag(); break; } break; } break; case EventType.DragExited: if (GUI.enabled) { HandleUtility.Repaint(); break; } break; } } EditorGUI.EndProperty(); return flag1; }
public static bool SinglePropertyField(Rect position, SerializedProperty property, GUIContent label) { //PropertyDrawer drawer = PropertyDrawer.GetDrawer(property); //if (drawer != null) //{ // EditorLook look = EditorGUIUtility.look; // float labelWidth = EditorGUIUtility.labelWidth; // float fieldWidth = EditorGUI.kNumberW; // drawer.OnGUI(position, property.Copy(), label ?? EditorGUIUtility.TempContent(property.displayName)); // if (EditorGUIUtility.look != look) // { // if (look == EditorLook.LikeControls) // { // EditorGUIUtility.LookLikeControls(labelWidth, fieldWidth); // } // else // { // EditorGUIUtility.LookLikeInspector(); // } // } // EditorGUIUtility.labelWidth = labelWidth; // EditorGUI.kNumberW = fieldWidth; // return false; //} label = EditorGUI.BeginProperty(position, label, property); SerializedPropertyType propertyType = property.propertyType; bool flag = false; if (!HasVisibleChildFields(property)) { switch (propertyType) { case SerializedPropertyType.Integer: { EditorGUI.BeginChangeCheck(); int intValue = EditorGUI.IntField(position, label, property.intValue); if (EditorGUI.EndChangeCheck()) { property.intValue = intValue; } goto IL_326; } case SerializedPropertyType.Boolean: { EditorGUI.BeginChangeCheck(); bool boolValue = EditorGUI.Toggle(position, label, property.boolValue); if (EditorGUI.EndChangeCheck()) { property.boolValue = boolValue; } goto IL_326; } case SerializedPropertyType.Float: { EditorGUI.BeginChangeCheck(); float floatValue = EditorGUI.FloatField(position, label, property.floatValue); if (EditorGUI.EndChangeCheck()) { property.floatValue = floatValue; } goto IL_326; } case SerializedPropertyType.String: { EditorGUI.BeginChangeCheck(); string stringValue = EditorGUI.TextField(position, label, property.stringValue); if (EditorGUI.EndChangeCheck()) { property.stringValue = stringValue; } goto IL_326; } case SerializedPropertyType.Color: { EditorGUI.BeginChangeCheck(); Color colorValue = EditorGUI.ColorField(position, label, property.colorValue); if (EditorGUI.EndChangeCheck()) { property.colorValue = colorValue; } goto IL_326; } case SerializedPropertyType.ObjectReference: ObjectReferenceField(position, property, label); goto IL_326; case SerializedPropertyType.LayerMask: LayerMaskField(position, property, label); goto IL_326; case SerializedPropertyType.Enum: Popup(position, property, label); goto IL_326; case SerializedPropertyType.Vector3: Vector3Field(position, property, label); goto IL_326; case SerializedPropertyType.Rect: RectField(position, property, label); goto IL_326; case SerializedPropertyType.ArraySize: { EditorGUI.BeginChangeCheck(); int intValue2 = ArraySizeField(position, label, property.intValue, EditorStyles.numberField); if (EditorGUI.EndChangeCheck()) { property.intValue = intValue2; } goto IL_326; } case SerializedPropertyType.Character: { char[] value = new char[] { (char)property.intValue }; bool changed = GUI.changed; GUI.changed = false; string text = EditorGUI.TextField(position, label, new string(value)); if (GUI.changed) { if (text.Length == 1) { property.intValue = (int)text[0]; } else { GUI.changed = false; } } GUI.changed |= changed; goto IL_326; } case SerializedPropertyType.AnimationCurve: { int controlID = GetControlID(s_CurveHash, EditorGUIUtility.native, position); DoCurveField(EditorGUI.PrefixLabel(position, controlID, label), controlID, null, kCurveColor, default(Rect), property); goto IL_326; } case SerializedPropertyType.Bounds: BoundsField(position, property, label); goto IL_326; case SerializedPropertyType.Gradient: { int controlID2 = GetControlID(s_CurveHash, EditorGUIUtility.native, position); DoGradientField(EditorGUI.PrefixLabel(position, controlID2, label), controlID2, null, property); goto IL_326; } } int controlID3 = GetControlID(s_GenericField, FocusType.Keyboard, position); EditorGUI.PrefixLabel(position, controlID3, label); IL_326: ; } else { int controlID4 = GetControlID(s_FoldoutHash, FocusType.Passive, position); EventType type = Event.current.type; if (type != EventType.DragUpdated && type != EventType.DragPerform) { if (type == EventType.DragExited) { if (GUI.enabled) { HandleUtility.Repaint(); } } } else { if (position.Contains(Event.current.mousePosition) && GUI.enabled) { Object[] objectReferences = DragAndDrop.objectReferences; Object[] array = new Object[1]; bool flag2 = false; Object[] array2 = objectReferences; for (int i = 0; i < array2.Length; i++) { Object @object = array2[i]; array[0] = @object; Object object2 = ValidateObjectFieldAssignment(array, null, property); if (object2 != null) { DragAndDrop.visualMode = DragAndDropVisualMode.Copy; if (Event.current.type == EventType.DragPerform) { property.AppendFoldoutPPtrValue(object2); flag2 = true; DragAndDrop.activeControlID = 0; } else { DragAndDrop.activeControlID = controlID4; } } } if (flag2) { GUI.changed = true; DragAndDrop.AcceptDrag(); Event.current.Use(); } } } flag = property.isExpanded; if (lookLikeInspector) { int num = EditorStyles.foldout.padding.left - EditorStyles.label.padding.left; position.x -= (float)num; position.width += (float)num; } GUI.enabled &= property.editable; GUIStyle style = (DragAndDrop.activeControlID != -10) ? EditorStyles.foldout : EditorStyles.foldoutPreDrop; bool flag3 = EditorGUI.Foldout(position, flag, s_PropertyFieldTempContent, true, style); if (flag3 != flag) { if (Event.current.alt) { SetExpandedRecurse(property, flag3); } else { property.isExpanded = flag3; } } flag = flag3; } EditorGUI.EndProperty(); if (Event.current.type == EventType.ExecuteCommand || Event.current.type == EventType.ValidateCommand) { if (GUIUtility.keyboardControl == lastControlID && (Event.current.commandName == "Delete" || Event.current.commandName == "SoftDelete")) { if (Event.current.type == EventType.ExecuteCommand) { property.DeleteCommand(); } Event.current.Use(); } if (GUIUtility.keyboardControl == lastControlID && Event.current.commandName == "Duplicate") { if (Event.current.type == EventType.ExecuteCommand) { property.DuplicateCommand(); } Event.current.Use(); } } return flag; }