internal static void DuplicateArrayElement(object userData) { SerializedProperty serializedProperty = (SerializedProperty)userData; serializedProperty.DuplicateCommand(); serializedProperty.serializedObject.ApplyModifiedProperties(); EditorUtility.ForceReloadInspectors(); }
internal static bool DuplicateArrayElement(object userData) { SerializedProperty property = (SerializedProperty)userData; bool result = property.DuplicateCommand(); property.serializedObject.ApplyModifiedProperties(); EditorUtility.ForceReloadInspectors(); return(result); }
private static void DoPropertyFieldKeyboardHandling(SerializedProperty property) { if (Event.current.type == EventType.ExecuteCommand || Event.current.type == EventType.ValidateCommand) { if (GUIUtility.keyboardControl == EditorGUIUtility.s_LastControlID && (Event.current.commandName == "Delete" || Event.current.commandName == "SoftDelete")) { if (Event.current.type == EventType.ExecuteCommand) EditorGUI.s_PendingPropertyDelete = property.Copy(); Event.current.Use(); } if (GUIUtility.keyboardControl == EditorGUIUtility.s_LastControlID && Event.current.commandName == "Duplicate") { if (Event.current.type == EventType.ExecuteCommand) property.DuplicateCommand(); Event.current.Use(); } } EditorGUI.s_PendingPropertyKeyboardHandling = (SerializedProperty) null; }
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; }