Example #1
0
        protected override VisualElement CreateSettingsView()
        {
            var sv = base.CreateSettingsView();

            OutputDimension currentDim = nodeTarget.rtSettings.dimension;

            settingsView.RegisterChangedCallback(() => {
                // Reflect the changes on the graph output texture but not on the asset to avoid stalls.
                graph.UpdateOutputTextures();
                RefreshOutputPortSettings();

                // When the dimension is updated, we need to update all the node ports in the graph
                var newDim = nodeTarget.rtSettings.dimension;
                if (currentDim != newDim)
                {
                    // We delay the port refresh to let the settings finish it's update
                    schedule.Execute(() => {
                        owner.ProcessGraph();
                        // Refresh ports on all the nodes in the graph
                        foreach (var nodeView in owner.nodeViews)
                        {
                            nodeView.nodeTarget.UpdateAllPortsLocal();
                            nodeView.RefreshPorts();
                        }
                    }).ExecuteLater(1);
                    currentDim = newDim;
                    NodeProvider.LoadGraph(graph);
                }
                else
                {
                    schedule.Execute(() => {
                        owner.ProcessGraph();
                    }).ExecuteLater(1);
                }
            });

            return(sv);
        }