public int GetCompCount() { if (conType == ConType.cInput) { if (IsConnected()) { return(inputCon.GetCompCount()); } else { int cc = 0; if (SF_Tools.CompCountOf(valueType, out cc)) { return(cc); } else { Debug.LogWarning("[Shader Forge] - invalid component count in [" + label + "] of " + node.name + ""); return(node.texture.CompCount); // This is super weird, shouldn't read from the max comp count, read from the connection type instead } } } OutChannel oc = outputChannel; if (oc == OutChannel.All) { int cc = 0; if (SF_Tools.CompCountOf(valueType, out cc)) { return(cc); } else { Debug.LogWarning("[Shader Forge] - invalid component count in [" + label + "] of " + node.name + ""); return(node.texture.CompCount); // This is super weird, shouldn't read from the max comp count, read from the connection type instead } } else if (oc == OutChannel.RGB) { return(3); } if (oc == OutChannel.RG) { return(2); } int custCount = SF_Tools.ComponentCountOf(customValueType); if (custCount != 0) { return(custCount); } return(1); }
public void DrawTypecastButton(Rect r, SF_NodeConnector con, bool isInput = false) { Rect closeRect = r.ClampWidth(0, (int)r.height); if (isInput) { GUI.color = new Color(1f, 0.7f, 0.7f, 1f); if (GUI.Button(closeRect, "-")) { RemoveConnector(con, undoRecord: true); return; } GUI.color = Color.white; r.xMin += closeRect.width; Rect dropdownRect = r; dropdownRect.xMax -= 50; r.xMin += dropdownRect.width; int cvtccBef = SF_Tools.ComponentCountOf(con.CustomValueType); //con.CustomValueType = (CustomValueType)EditorGUI.EnumPopup(dropdownRect, con.CustomValueType); con.CustomValueType = (CustomValueType)UndoableEnumPopup(dropdownRect, con.CustomValueType, "set input " + con.label + " value type"); if (cvtccBef != SF_Tools.ComponentCountOf(con.CustomValueType)) { con.Disconnect(); } string before = con.label; con.label = EditorGUI.TextField(r, con.label); if (con.label != before && con.label.Length > 0) { con.label = SF_ShaderProperty.FormatInternalName(con.label); UpdateExtraInputWidth(); OnUpdateNode(NodeUpdateType.Soft); } } else { int cvtccBef = SF_Tools.ComponentCountOf(con.CustomValueType); //con.CustomValueType = (CustomValueType)EditorGUI.EnumPopup(r, con.CustomValueType); con.CustomValueType = (CustomValueType)UndoableEnumPopup(r, con.CustomValueType, "set output value type"); if (cvtccBef != SF_Tools.ComponentCountOf(con.CustomValueType)) { con.Disconnect(); } } }
public override int GetEvaluatedComponentCount() { return(SF_Tools.ComponentCountOf(connectors[0].CustomValueType)); }