static public void OnAdd(PEExposedPropertiesEditor editor, int parentId = 0) { var lr = GUILayoutUtility.GetLastRect(); if (lr.min == Vector2.zero) { lr.center = Event.current.mousePosition; } lr.center = GUIUtility.GUIToScreenPoint(lr.center); var menu = new GenericMenu(); menu.AddItem(new GUIContent("Property"), false, () => { PEPropertyPickerWindow.OnPropertyPickerDelegate onChanged = property => { var newProperty = new ExposedProperty(); newProperty.Label = property.GetDisplayName(); newProperty.PropertyPath = property.propertyPath; newProperty.Target = property.serializedObject.targetObject; newProperty.ParentId = parentId; editor.targets[0].Properties.Add(newProperty); newProperty.Order = editor.targets[0].Properties.OrderedItems.Any() ? editor.targets[0].Properties.OrderedItems.Max(i => i.Order + 10) : 0; editor.Build(true); Event.current.Use(); Resources.FindObjectsOfTypeAll <Editor>()[0].Repaint(); GUIUtility.ExitGUI(); }; EditorApplication.delayCall += () => PEPropertyPickerWindow.Show(editor.targets[0].gameObject, onChanged, lr); }); menu.AddItem(new GUIContent("Group"), false, () => EditorApplication.delayCall += () => { editor.targets[0].Properties.Add(new ExposedPropertyGroup { Label = "Property Group", ParentId = parentId, Order = editor.targets[0].Properties.OrderedItems.Any() ? editor.targets[0].Properties.OrderedItems.Max(i => i.Order + 10) : 0 }); editor.Build(true); }); menu.ShowAsContext(); }
static public void OnEdit(PEExposedPropertiesEditor editor, ItemDrawer propertyToEdit) { var lr = GUILayoutUtility.GetLastRect(); if (lr.min == Vector2.zero) { lr.center = Event.current.mousePosition; } var p = propertyToEdit.ExposedData.First() as ExposedProperty; lr.center = GUIUtility.GUIToScreenPoint(lr.center); PEPropertyPickerWindow.OnPropertyPickerDelegate onChanged = property => { var newProperty = p; newProperty.Label = property.GetDisplayName(); newProperty.PropertyPath = property.propertyPath; newProperty.Target = property.serializedObject.targetObject; editor.Build(true); }; EditorApplication.delayCall += () => PEPropertyPickerWindow.Show(editor.targets[0].gameObject, onChanged, lr, null, propertyToEdit.Property); }