private void DrawElementGroup() { if (elementGroup_prop.objectReferenceValue == null) { if (GUILayout.Button("create new element group")) { var group = ScriptableObject.CreateInstance <ElementGroup>(); ProjectWindowUtil.CreateAsset(group, "new element_group.asset"); ActionGUIUtil.DelyAcceptObject(group, item => { elementGroup_prop = new SerializedObject(target).FindProperty("elementGroup"); elementGroup_prop.objectReferenceValue = item; elementGroup_prop.serializedObject.ApplyModifiedProperties(); }); } } else { if (elementGroupDrawer == null) { Editor editor = null; Editor.CreateCachedEditor(elementGroup_prop.objectReferenceValue, typeof(ElementGroupDrawer), ref editor); elementGroupDrawer = editor as ElementGroupDrawer; elementGroupDrawer.showScript = false; } elementGroupDrawer.OnInspectorGUI(); } }
protected override void OnDrawProperty(SerializedProperty property) { if (property.propertyPath == "rule") { using (var hor = new EditorGUILayout.HorizontalScope()) { EditorGUILayout.PropertyField(rule_prop, new GUIContent("规 则")); if (GUILayout.Button("new", EditorStyles.miniButtonRight, GUILayout.Width(40))) { var options = Array.ConvertAll(supportRules, x => new GUIContent(x.FullName)); var rect = new Rect(Event.current.mousePosition, Vector2.zero); EditorUtility.DisplayCustomMenu(rect, options, -1, (x, y, id) => { var type = supportRules[id]; var instence = ScriptableObject.CreateInstance(type); ProjectWindowUtil.CreateAsset(instence, string.Format("new {0}.asset", type.Name)); ActionGUIUtil.DelyAcceptObject(instence, (prefab) => { rule_prop = new SerializedObject(target).FindProperty("rule"); rule_prop.objectReferenceValue = prefab; rule_prop.serializedObject.ApplyModifiedProperties(); }); }, null); } } } else { base.OnDrawProperty(property); } }
private void OnAddElement(ReorderableList list) { var element = ScriptableObject.CreateInstance <ActionCommand>(); element.ControllerType = typeof(InteractSystem.Graph.AcionGraphCtrl).FullName; ProjectWindowUtil.CreateAsset(element, "new command.asset"); var path = property.propertyPath; var obj = property.serializedObject.targetObject; ActionGUIUtil.DelyAcceptObject(element, (item) => { property = new SerializedObject(obj).FindProperty(path); var prop = property.AddItem(); var commandName_prop = prop.FindPropertyRelative("commandName"); var command_prop = prop.FindPropertyRelative("command"); command_prop.objectReferenceValue = item; commandName_prop.stringValue = item.name; property.serializedObject.ApplyModifiedProperties(); }); }
private void OnAddElement(ReorderableList list) { var propertyPath = property.propertyPath; var obj = property.serializedObject.targetObject; ActionGUIUtil.DrawScriptablesMenu(supportTypes, (hook) => { ActionGUIUtil.DelyAcceptObject(hook, (item) => { try { property = new SerializedObject(obj).FindProperty(propertyPath); var prop = property.AddItem(); prop.objectReferenceValue = item; property.serializedObject.ApplyModifiedProperties(); } catch (Exception e) { throw e; } }); }); }