private void DrawSockets(Action action, bool isAsset) { List<Action> actionList = new List<Action>(); if (isAsset) { actionList = windowData.targetAsset.actions; } else { actionList = windowData.target.actions; } int i = actionList.IndexOf (action); Event e = Event.current; if (action.numSockets == 0) { return; } if (!action.isDisplayed && (action is ActionCheck || action is ActionCheckMultiple || action is ActionParallel)) { action.DrawOutWires (actionList, i, 0); return; } int offset = 0; if (action is ActionCheck) { ActionCheck actionCheck = (ActionCheck) action; if (actionCheck.resultActionFail != ResultAction.RunCutscene) { Rect buttonRect = new Rect (action.nodeRect.x + action.nodeRect.width - 2, action.nodeRect.y - 22 + action.nodeRect.height, 16, 16); if (e.isMouse && actionChanging == null && e.type == EventType.MouseDown && action.isEnabled && buttonRect.Contains(e.mousePosition)) { offsetChanging = 10; resultType = false; actionChanging = action; } GUI.Button (buttonRect, "", nodeSkin.customStyles[10]); if (actionCheck.resultActionFail == ResultAction.Skip) { offset = 17; } } if (actionCheck.resultActionTrue != ResultAction.RunCutscene) { Rect buttonRect = new Rect (action.nodeRect.x + action.nodeRect.width - 2, action.nodeRect.y - 40 - offset + action.nodeRect.height, 16, 16); if (e.isMouse && actionChanging == null && e.type == EventType.MouseDown && action.isEnabled && buttonRect.Contains(e.mousePosition)) { offsetChanging = 30 + offset; resultType = true; actionChanging = action; } GUI.Button (buttonRect, "", nodeSkin.customStyles[10]); } } else if (action is ActionCheckMultiple) { ActionCheckMultiple actionCheckMultiple = (ActionCheckMultiple) action; int totalHeight = 20; for (int j = actionCheckMultiple.endings.Count-1; j>=0; j--) { ActionEnd ending = actionCheckMultiple.endings [j]; if (ending.resultAction != ResultAction.RunCutscene) { Rect buttonRect = new Rect (action.nodeRect.x + action.nodeRect.width - 2, action.nodeRect.y + action.nodeRect.height - totalHeight, 16, 16); if (e.isMouse && actionChanging == null && e.type == EventType.MouseDown && action.isEnabled && buttonRect.Contains(e.mousePosition)) { offsetChanging = totalHeight - 10; multipleResultType = actionCheckMultiple.endings.IndexOf (ending); actionChanging = action; } GUI.Button (buttonRect, "", nodeSkin.customStyles[10]); } if (ending.resultAction == ResultAction.Skip) { totalHeight += 44; } else { totalHeight += 26; } } } else if (action is ActionParallel) { ActionParallel ActionParallel = (ActionParallel) action; foreach (ActionEnd ending in ActionParallel.endings) { int j = ActionParallel.endings.IndexOf (ending); if (ending.resultAction != ResultAction.RunCutscene) { Rect buttonRect = new Rect (action.nodeRect.x + action.nodeRect.width - 2, action.nodeRect.y + (j * 43) - (ActionParallel.endings.Count * 43) + action.nodeRect.height, 16, 16); if (e.isMouse && actionChanging == null && e.type == EventType.MouseDown && action.isEnabled && buttonRect.Contains(e.mousePosition)) { offsetChanging = (ActionParallel.endings.Count - j) * 43 - 13; multipleResultType = ActionParallel.endings.IndexOf (ending); actionChanging = action; } GUI.Button (buttonRect, "", nodeSkin.customStyles[10]); } } } else { if (action.endAction != ResultAction.RunCutscene) { Rect buttonRect = new Rect (action.nodeRect.x + action.nodeRect.width / 2f - 8, action.nodeRect.y + action.nodeRect.height, 16, 16); if (e.isMouse && actionChanging == null && e.type == EventType.MouseDown && action.isEnabled && buttonRect.Contains(e.mousePosition)) { offsetChanging = 10; actionChanging = action; } GUI.Button (buttonRect, "", nodeSkin.customStyles[10]); } } action.DrawOutWires (actionList, i, offset); }
private void DrawSockets (Action action, bool isAsset) { List<Action> actionList = new List<Action>(); if (isAsset) { actionList = _targetAsset.actions; } else { actionList = _target.actions; } int i = actionList.IndexOf (action); Event e = Event.current; if (SocketIn (action).Contains (e.mousePosition) && actionChanging) { GUI.Label (SocketIn (action), socketOut, "Label"); } else { GUI.Label (SocketIn (action), socketIn, "Label"); } if (action.numSockets == 0) { return; } int offset = 0; if (action is ActionCheck) { ActionCheck actionCheck = (ActionCheck) action; if (actionCheck.resultActionFail != ResultAction.RunCutscene) { Rect buttonRect = new Rect (action.nodeRect.x + action.nodeRect.width, action.nodeRect.y - 22 + action.nodeRect.height, 20, 20); if (e.isMouse && actionChanging == null && e.type == EventType.MouseDown && action.isEnabled && buttonRect.Contains(e.mousePosition)) { offsetChanging = 10; resultType = false; actionChanging = action; } if (actionChanging == null && action.isEnabled && buttonRect.Contains (e.mousePosition)) { GUI.Button (buttonRect, socketIn, "Label"); } else { GUI.Button (buttonRect, socketOut, "Label"); } if (actionCheck.resultActionFail == ResultAction.Skip) { offset = 17; } } if (actionCheck.resultActionTrue != ResultAction.RunCutscene) { Rect buttonRect = new Rect (action.nodeRect.x + action.nodeRect.width, action.nodeRect.y - 40 - offset + action.nodeRect.height, 20, 20); if (e.isMouse && actionChanging == null && e.type == EventType.MouseDown && action.isEnabled && buttonRect.Contains(e.mousePosition)) { offsetChanging = 30 + offset; resultType = true; actionChanging = action; } if (actionChanging == null && action.isEnabled && buttonRect.Contains (e.mousePosition)) { GUI.Button (buttonRect, socketIn, "Label"); } else { GUI.Button (buttonRect, socketOut, "Label"); } } } else if (action is ActionCheckMultiple) { ActionCheckMultiple actionCheckMultiple = (ActionCheckMultiple) action; foreach (ActionEnd ending in actionCheckMultiple.endings) { int j = actionCheckMultiple.endings.IndexOf (ending); if (ending.resultAction != ResultAction.RunCutscene) { Rect buttonRect = new Rect (action.nodeRect.x + action.nodeRect.width, action.nodeRect.y + (j * 43) - (actionCheckMultiple.endings.Count * 43) + action.nodeRect.height, 20, 20); if (e.isMouse && actionChanging == null && e.type == EventType.MouseDown && action.isEnabled && buttonRect.Contains(e.mousePosition)) { offsetChanging = (actionCheckMultiple.endings.Count - j) * 43 - 13; multipleResultType = actionCheckMultiple.endings.IndexOf (ending); actionChanging = action; } if (actionChanging == null && action.isEnabled && buttonRect.Contains (e.mousePosition)) { GUI.Button (buttonRect, socketIn, "Label"); } else { GUI.Button (buttonRect, socketOut, "Label"); } } } } else { if (action.endAction != ResultAction.RunCutscene) { Rect buttonRect = new Rect (action.nodeRect.x + action.nodeRect.width, action.nodeRect.y - 22 + action.nodeRect.height, 20, 20); if (e.isMouse && actionChanging == null && e.type == EventType.MouseDown && action.isEnabled && buttonRect.Contains(e.mousePosition)) { offsetChanging = 10; actionChanging = action; } if (actionChanging == null && action.isEnabled && buttonRect.Contains (e.mousePosition)) { GUI.Button (buttonRect, socketIn, "Label"); } else { GUI.Button (buttonRect, socketOut, "Label"); } } } action.DrawOutWires (actionList, i, offset); }