void CollectPortalNames() { PortalVariable myTarget = (PortalVariable)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 < _inputPortals.Count; cnt++) { var portal = _inputPortals[cnt]; if (portal == myTarget) { continue; } nameList.Add(portal.PortalName); if (myTarget.PortalName == portal.PortalName) { index = cnt; } } _portalNames = new SmartPopup(nameList.ToArray(), index); }
protected override void onGUI() { PortalVariable myTarget = (PortalVariable)target; EditorGUIExtension.SimpleBox("", 5, "", delegate() { // IS INPUT if (_inputPortals.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.PortalName = _inputPortals[_portalNames.Index].PortalName; myTarget.InputPortal = _inputPortals[_portalNames.Index]; } } else { myTarget.PortalName = PortalNameField(myTarget.PortalName); } }); }
void OnEnable() { // Get all the portals from the graph. PortalVariable myTarget = (PortalVariable)target; _portals = myTarget.Root.Nodes.FindAll <PortalVariable>(); _inputPortals = _portals.FindAll(x => x.IsInput); // If the current target is an output... 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. PortalVariable myTarget = (PortalVariable)target; myTarget.PortalName = UniquePortalName(myTarget.PortalName); } } return(isInput); }
public PortalVariableLayout(PortalVariable node) : base(node) { headerColor = BuiltInColors.GetDark(_node.Type); width = 150; }