protected override void onGUI() { PortalExecution myTarget = (PortalExecution)target; EditorGUIExtension.SimpleBox("", 5, "", delegate() { // IS INPUT if (_outputPortals.Count > 0) { myTarget.IsInput = InputToggle(myTarget.IsInput); } else { EditorGUILayout.Toggle("Is Input", myTarget.IsInput); EditorGUILayout.HelpBox("You can't set this node to Input," + "You need at least one output execution portal in the graph", MessageType.Info); } // PORTAL NAME if (myTarget.IsInput) { if (_portalNames.Draw("Portal Name")) { // Set the connected portal. myTarget.OutputPortal = _outputPortals[_portalNames.Index]; } } else { myTarget.PortalName = PortalNameField(myTarget.PortalName); } }); }
void CollectPortalNames() { PortalExecution myTarget = (PortalExecution)target; // ... iterate through the portals, to get the names, and the current index. int index = -1; List <string> nameList = new List <string>(); for (int cnt = 0; cnt < _outputPortals.Count; cnt++) { var portal = _outputPortals[cnt]; if (portal == myTarget) { continue; } nameList.Add(portal.PortalName); if (myTarget.PortalName == portal.PortalName) { index = cnt; } } _portalNames = new SmartPopup(nameList.ToArray(), index); }
void OnEnable() { // Get all the portals from the graph. PortalExecution myTarget = (PortalExecution)target; _portals = myTarget.Root.Nodes.FindAll <PortalExecution>(); _outputPortals = _portals.FindAll(x => !x.IsInput); // If the current target is an input... if (myTarget.IsInput) { CollectPortalNames(); } }
bool InputToggle(bool wasInput) { bool isInput = EditorGUILayout.Toggle("Is Input", wasInput); if (isInput != wasInput) { // If the node will be input, recollect portal names. if (isInput) { CollectPortalNames(); } // If the node will be an output... else { // Set its portal name to unique. PortalExecution myTarget = (PortalExecution)target; myTarget.PortalName = UniquePortalName(myTarget.PortalName); } } return(isInput); }
public PortalExecutionLayout(PortalExecution node) : base(node) { headerColor = BuiltInColors.GetDark(typeof(ExecutableNode)); width = 150; }