/// <summary> add new pin with base variable type</summary> public virtual void AddInputPin() { if (multiplePins && InPins.Count() < 16) { //ScriptableObject.Instantiate<InputPin>(); valInPins.Add(new ValueInputPin(this, valInPins[0].varType)); Resize(); } }
/// <summary> /// Resize the body of node. Necessary when number of pins changes or the width of text to be displayed changes. /// </summary> public virtual void Resize() { GUIStyle style = skin.label; float nameWidth = style.CalcSize(new GUIContent(LongestInName)).x + style.CalcSize(new GUIContent(LongestOutName)).x; float pinWidth = 50; float w = 2 * pinWidth + nameWidth + 30; body = new Rect(0, 0, Mathf.Max(w, Width), Top + NodePin.Top * MaxNodes + Bottom); // widen body based on disconnected, changeable inputs // for types with multiple inputs, this offset is based only on widest field Vector2 inputWidths = Vector2.zero; //foreach (NodePin pin in AllPins) { // if (!pin.isConnected) { // switch (pin.varType) { // case VarType.Bool: // checkbox // break; // case VarType.Integer: // int field // break; // case VarType.Float: // float field // break; // case VarType.String: // text field // break; // case VarType.Vector2: // 2 float fields // break; // case VarType.Vector3: // 3 float fields // break; // case VarType.Vector4: // 4 float fields // break; // case VarType.Color: // box showing color // break; // } // } //} body.size += inputWidths; // set pin visual information List <InputPin> inPins = InPins.ToList(); List <OutputPin> outPins = OutPins.ToList(); foreach (NodePin pin in AllPins) { float x = !pin.isInput ? body.width - NodePin.margin.x - NodePin.pinSize.x : NodePin.margin.x; float y = !pin.isInput ? outPins.IndexOf((OutputPin)pin) : inPins.IndexOf((InputPin)pin); //float x, y; x = y = 9; pin.bounds.position = new Vector2(x, Top + NodePin.margin.y + y * NodePin.Top); } }