StateGraphEditor.cs 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using XNodeEditor;
  4. using ChivaVR.State;
  5. using XNode;
  6. namespace ChivaVREditor
  7. {
  8. [CustomNodeGraphEditor(typeof(StateGraph))]
  9. public class StateGraphEditor : NodeGraphEditor
  10. {
  11. public override void OnOpen()
  12. {
  13. base.OnOpen();
  14. if (serializedObject.FindProperty("enter").objectReferenceValue == null)
  15. {
  16. Node node= CreateNode(typeof(EnterStateNode), new UnityEngine.Vector2(0, 0));
  17. serializedObject.Update();
  18. serializedObject.FindProperty("enter").objectReferenceValue = node;
  19. serializedObject.ApplyModifiedProperties();
  20. }
  21. if (serializedObject.FindProperty("exit").objectReferenceValue == null)
  22. {
  23. Node node = CreateNode(typeof(ExitStateNode), new UnityEngine.Vector2(0, 100));
  24. serializedObject.Update();
  25. serializedObject.FindProperty("exit").objectReferenceValue = node;
  26. serializedObject.ApplyModifiedProperties();
  27. }
  28. }
  29. public override string GetNodeMenuName(System.Type type)
  30. {
  31. if (type.Namespace == "ChivaVR.State")
  32. {
  33. return base.GetNodeMenuName(type).Replace("Chiva VR/State/", "");
  34. }
  35. else return null;
  36. }
  37. }
  38. }