public override void OnClickNode(DragNode targetNode) { currNode = ( BTNode )targetNode; var allActions = XReflectionUtils.FindUnitySubClass(typeof(BTAction)).ToList(); var allVariables = XReflectionUtils.FindUnitySubClass(typeof(BTVariable)).ToList(); GenericMenu gm = new GenericMenu(); gm.AddItem(new GUIContent("New Fsm Event"), false, ClickNode, ( object )"NewEvent"); gm.AddItem(new GUIContent("Open State Script"), false, ClickNode, "OpenScript"); gm.AddItem(new GUIContent("Delet State"), false, ClickNode, ( object )"DeleteState"); gm.AddItem(new GUIContent("Copy State"), false, ClickNode, "CopyState"); for (int i = 0; i < allActions.Count; i++) { var allObject = allActions[i].GetCustomAttributes(typeof(ActionTitleAttribute), true); if (allObject.Length > 0) { gm.AddItem(new GUIContent("Add Action/" + (( ActionTitleAttribute )allObject[0]).title), false, ClickNode, ( object )allActions[i].AssemblyQualifiedName); } } gm.ShowAsContext(); }
public override void OnClickNone(BTFsm targetNode) { currFsm = targetNode; GenericMenu gm = new GenericMenu(); gm.AddItem(new GUIContent("New Fsm Event"), false, ClickNone, "NewGlobalEvent"); gm.AddItem(new GUIContent("New Fsm State"), false, ClickNone, "NewState"); gm.AddItem(new GUIContent("Cancel Edit Fsm"), false, ClickNone, "CancelEditFsm"); if (copyState != null) { gm.AddItem(new GUIContent("Paste State"), false, ClickNone, "PasteState"); } var allState = XReflectionUtils.FindUnitySubClass(typeof(BTState)).ToList(); for (int i = 0; i < allState.Count; i++) { var allObject = allState[i].GetCustomAttributes(typeof(StateTitleAttribute), true); if (allObject.Length > 0) { gm.AddItem(new GUIContent("Add Custom State/" + (( StateTitleAttribute )allObject[0]).title), false, AddCustomState, ( object )allState[i].AssemblyQualifiedName); } } var allVariables = XReflectionUtils.FindUnitySubClass(typeof(BTVariable)).ToList(); for (int i = 0; i < allVariables.Count; i++) { var allObject = allVariables[i].GetCustomAttributes(typeof(ActionTitleAttribute), true); if (allObject.Length > 0) { gm.AddItem(new GUIContent("Add Variable/" + (( ActionTitleAttribute )allObject[0]).title), false, ClickNone, ( object )allVariables[i].AssemblyQualifiedName); } } gm.ShowAsContext(); }