//初期化 public NodeConnectionPoint(Node node, ConnectionPointType type, GUIStyle style, Action <NodeConnectionPoint> OnClickConnectionPoint, NextStateJudge judge = null) { this.node = node; //親 this.type = type; //タイプ this.style = style; //スタイル this.OnClickConnectionPoint = OnClickConnectionPoint; rect = new Rect(0, 0, 10f, 20f); //座標 if (judge != null) { myNextStateJudge = judge; } }
//コピーしたステートのペースト(ネクストステート含め) private void OnClickPasteNodeAll(Vector2 mousePosition) { //Undo処理 if (stateMonobehaviors.Length > 0) { Undo.RecordObject(stateMonobehaviors[nowStateMonoNuber], "StateUndo"); } if (copyNode == null) { return; } NomalState statePlus = new NomalState(); statePlus.execDelegate = new List <StateBase.ActionDelegate>(copyNode.myState.execDelegate); statePlus.stateName = copyNode.myState.stateName + "(Clone)"; statePlus.nextStateJudge = new List <NextStateJudge>(); statePlus.stateMode = copyNode.myState.stateMode; statePlus.stateBody = copyNode.myState.stateBody; for (int i = 0; i < copyNode.myState.nextStateJudge.Count; i++) { NextStateJudge next = new NextStateJudge(); next.nextID = new InstanceID(); next.nextID = copyNode.myState.nextStateJudge[i].nextID; next.nextState = copyNode.myState.nextStateJudge[i].nextState; next.nextStateName = copyNode.myState.nextStateJudge[i].nextStateName; next.priority = copyNode.myState.nextStateJudge[i].priority; next.comment = copyNode.myState.nextStateJudge[i].comment; next.judgeFunc = copyNode.myState.nextStateJudge[i].judgeFunc; next.judgeFuncName = copyNode.myState.nextStateJudge[i].judgeFuncName; next.judgeFuncInstance = copyNode.myState.nextStateJudge[i].judgeFuncInstance; statePlus.nextStateJudge.Add(next); } statePlus.playUpdateDelegate = new List <StateBase.ActionDelegate>(copyNode.myState.playUpdateDelegate); states.Add(statePlus); if (nodes == null) { nodes = new List <Node>(); } //マウスの場所に追加 nodes.Add(new Node(new Rect(mousePosition.x, mousePosition.y, 200, 50), inPointStyle, outPointStyle, OnClickInPoint, OnClickOutPoint, OnClickRemoveNode, " ", nowId, statePlus, gameObject, stateMonobehaviors[nowStateMonoNuber])); nowId++; initFlag = true; }
//戻り値booolのメソッドをポップアップで表示 private void PopupBoolMethod() { //boolメソッド欄表示 for (int i = 0; i < outPoints.Count; i++) { EditorGUILayout.BeginVertical(GUI.skin.box); EditorGUILayout.BeginHorizontal(); //オーバーフローしてたら0に if (outPoints[i].nowStringNumber >= nowMethodsBool.Count) { outPoints[i].nowStringNumber = 0; } //メソッドの同期 for (int j = 0; j < nowMethodsBool.Count; j++) { if (nowMethodsBool[j].nowMethod.Name == outPoints[i].stateJudge.judgeFuncName && nowMethodsBool[j].compornent == outPoints[i].stateJudge.judgeFuncInstance) { outPoints[i].nowStringNumber = j; } } //ポップアップでメソッド取得 outPoints[i].nowStringNumber = EditorGUILayout.Popup(outPoints[i].nowStringNumber, nowOptionsBool, GUILayout.Width(rect.width - 83)); if (GUILayout.Button("⇧", GUILayout.Height(15), GUILayout.Width(18))) { if (i > 0) { NextStateJudge actionDel = outPoints[i].stateJudge; myState.nextStateJudge[i] = myState.nextStateJudge[i - 1]; myState.nextStateJudge[i - 1] = actionDel; NodeBaseEditor.initFlag = true; } } if (GUILayout.Button("⇩", GUILayout.Height(15), GUILayout.Width(18))) { if (i < myState.nextStateJudge.Count - 1) { NextStateJudge actionDel = outPoints[i].stateJudge; myState.nextStateJudge[i] = myState.nextStateJudge[i + 1]; myState.nextStateJudge[i + 1] = actionDel; NodeBaseEditor.initFlag = true; } } if (GUILayout.Button("×", GUILayout.Height(15), GUILayout.Width(19))) { myState.nextStateJudge.Remove(outPoints[i].stateJudge); NodeBaseEditor.initFlag = true; } //現在のメソッドがあれば if (nowMethodsBool.Count > 0) { outPoints[i].stateJudge.judgeFuncInstance = nowMethodsBool[outPoints[i].nowStringNumber].compornent; outPoints[i].stateJudge.judgeFuncName = nowMethodsBool[outPoints[i].nowStringNumber].nowMethod.Name; //GetCompornentは同じクラスがあった場合にも対応 //outPoints[i].stateJudge.judgeFunc = (Func<bool>)nowMethodsBool[outPoints[i].nowStringNumber].nowMethod.CreateDelegate(typeof(Func<bool>), nowMethodsBool[outPoints[i].nowStringNumber].compornent); } EditorGUILayout.EndHorizontal(); if (outPoints.Count > i) { ParameterInfo[] parameters = { }; if (nowMethodsBool.Count > 0) { //引数があればそれに応じたフィールドの生成 parameters = nowMethodsBool[outPoints[i].nowStringNumber].nowMethod.GetParameters(); } //引数1 if (parameters.Length == 1) { EditorGUILayout.BeginHorizontal(); //引数のセットと表示 SetArgument(ref outPoints[i].stateJudge.arg1, ref outPoints[i].stateJudge.argType1, parameters, 0, 180); EditorGUILayout.EndHorizontal(); //引数が一つであることを渡す outPoints[i].stateJudge.argMode = JudgeFuncArgMode.Arg1; } else if (parameters.Length == 2) { EditorGUILayout.BeginHorizontal(); SetArgument(ref outPoints[i].stateJudge.arg1, ref outPoints[i].stateJudge.argType1, parameters, 0, 90); SetArgument(ref outPoints[i].stateJudge.arg2, ref outPoints[i].stateJudge.argType2, parameters, 1, 90); EditorGUILayout.EndHorizontal(); //引数が2つであることを渡す outPoints[i].stateJudge.argMode = JudgeFuncArgMode.Arg2; } //引数なし else if (parameters.Length == 0) { outPoints[i].stateJudge.argMode = JudgeFuncArgMode.NoArg; GUILayout.Label("引数なし"); } outPoints[i].stateJudge.comment = EditorGUILayout.TextField(outPoints[i].stateJudge.comment); } EditorGUILayout.EndVertical(); //高さのプラス rect.height += 44; rect.height += 18; } }