Beispiel #1
0
        public static void EnterableTextField(SF_Node n, Rect r, ref string str, GUIStyle style, bool update = true)
        {
            if (style == null)
            {
                style = EditorStyles.textField;
            }
            string field_name = n.GetType().ToString() + "_txt_" + n.id;


            GUI.SetNextControlName(field_name);
            EditorGUI.BeginChangeCheck();
            str = EditorGUI.TextField(r, str, style);

            bool pressedEnter = Event.current.keyCode == KeyCode.Return;

            if (update)
            {
                if (pressedEnter)
                {
                    if (GUI.GetNameOfFocusedControl() == field_name)
                    {
                        n.OnUpdateNode(NodeUpdateType.Hard);
                    }
                    EditorGUI.EndChangeCheck();
                }
                else if (EditorGUI.EndChangeCheck())
                {
                    n.OnUpdateNode(NodeUpdateType.Soft);
                }
            }
            else if (EditorGUI.EndChangeCheck())
            {
                n.editor.ShaderOutdated = UpToDateState.OutdatedSoft;
            }
        }
Beispiel #2
0
        public static void EnterableFloatField(SF_Node n, Rect r, ref float val, GUIStyle style)
        {
            if (style == null)
            {
                style = EditorStyles.textField;
            }
            string field_name = n.GetType().ToString() + "_" + n.id;


            GUI.SetNextControlName(field_name);
            EditorGUI.BeginChangeCheck();
            val = EditorGUI.FloatField(r, val, style);


            bool pressedEnter = Event.current.keyCode == KeyCode.Return && Event.current.type == EventType.KeyDown;

            if (pressedEnter)
            {
                EditorGUI.EndChangeCheck();
                //Debug.Log("Pressed enter with focus on " + GUI.GetNameOfFocusedControl() + ", should have been " + field_name);
                if (GUI.GetNameOfFocusedControl() == field_name)
                {
                    //Debug.Log("Pressed enter!");
                    n.OnUpdateNode(NodeUpdateType.Hard);
                }
            }
            else if (EditorGUI.EndChangeCheck())
            {
                n.OnUpdateNode(NodeUpdateType.Soft);
            }
        }
Beispiel #3
0
        public void Disconnect(bool force = false, bool callback = true, bool reconnection = false)
        {
            //Debug.Log( "Attempt to disconnect: " + node.name + "[" + label + "]" );

            if (!IsConnected())
            {
                //Debug.Log( "Aborted " + node.name + "[" + label + "]" );
                return;
            }


            if (conType == ConType.cInput)
            {
                //Debug.Log( "Input disconnecting " + node.name + "[" + label + "]" );
                ResetValueType();
                if (inputCon != null)
                {
                    inputCon.outputCons.Remove(this);
                    if (!reconnection)
                    {
                        SetVisChildVisible(false);                         // Don't hide the child if this was disconnected by reconnection
                    }
                    //Debug.Log( "Disconnecting " + label + "<--" + inputCon.label );
                }
                inputCon = null;
                if (callback && !SF_Parser.quickLoad)
                {
                    node.OnUpdateNode();
                }
            }
            else
            {
                //Debug.Log( "Output disconnecting " + node.name + "[" + label + "]" );
                SF_NodeConnector[] outputsArr = outputCons.ToArray();
                for (int i = 0; i < outputsArr.Length; i++)
                {
                    //Debug.Log( "Disconnecting " + outputsArr[i].label + "<--" + label );
                    outputsArr[i].Disconnect(true, callback);
                }
                outputCons.Clear();
            }

            //		AceMatEditor.instance.CheckForBrokenConnections();

            //		node = null; // What?
        }