コード例 #1
0
        /// <summary>
        /// Updates this node based on the value of "selected".
        /// </summary>
        private void ChangeGraph()
        {
            if (selected < 0)
            {
                GraphGUID        = null;
                Inputs           = new List <NodeInput>();
                InputNames       = new List <string>();
                InputDefaultVals = new List <float>();
            }
            else
            {
                GraphGUID = guids[selected];

                Graph g = TryLoadGraph();
                if (g != null)
                {
                    if (convertParamsToInputs)
                    {
                        SetInputsFrom(new GraphParamCollection(g).FloatParams);
                    }
                    else
                    {
                        Inputs.Clear();
                        InputNames.Clear();
                        InputDefaultVals.Clear();
                    }
                }

                UpdateGraphPaths();
                selected = guids.IndexOf(GraphGUID);
            }
        }
コード例 #2
0
        protected override bool CustomGUI()
        {
            bool changed = false;

            {
                bool oldConverted = convertParamsToInputs;
                convertParamsToInputs = GUILayout.Toggle(convertParamsToInputs, "Convert params to inputs");
                if (oldConverted && !convertParamsToInputs)
                {
                    changed = true;
                    Inputs.Clear();
                    InputNames.Clear();
                    InputDefaultVals.Clear();
                }
                else if (!oldConverted && convertParamsToInputs)
                {
                    changed = true;
                    Graph g = TryLoadGraph();
                    if (g == null)
                    {
                        convertParamsToInputs = false;
                    }
                    else
                    {
                        SetInputsFrom(new GraphParamCollection(g).FloatParams);
                    }
                }
            }

            Vector2 textDims = GUI.skin.label.CalcSize(new GUIContent("Graph:"));

            EditorGUIUtility.labelWidth = textDims.x;
            int newIndex = EditorGUILayout.Popup("Graph:", selected, names, GUILayout.MinWidth(100.0f));

            if (selected != newIndex)
            {
                selected = newIndex;
                ChangeGraph();
                changed = true;
            }

            if (GUILayout.Button("Refresh graphs"))
            {
                changed = CheckOutGraphs(true) || changed;
            }

            return(changed);
        }