public static IEnumerable <INode> ConvertNodes(UniGraph graph, UniGraphAsset graphAsset)
        {
            var nodes = graphAsset.nodes;

            foreach (var node in nodes)
            {
                if (node is UniBaseNode)
                {
                    continue;
                }

                var bufferNode = new GraphProcessorNode(graph, node);
                yield return(bufferNode);
            }
        }
예제 #2
0
        public virtual UniGraphAsset CreateAssetGraph(UniGraph uniGraph)
        {
            if (Application.isPlaying == false)
            {
                InitializeGraph(uniGraph);
            }

            _graphName = uniGraph.name;
            var graphAsset = uniGraph.useVariants
                ? CreateInstance <UniGraphAsset>()
                : uniGraph.serializedGraph;

            if (!graphAsset && Application.isPlaying == false)
            {
                graphAsset = CreateInstance <UniGraphAsset>();
                uniGraph.serializedGraph = graphAsset;
                graphAsset.SaveAssetAsNested(uniGraph.gameObject);
                uniGraph.gameObject.MarkDirty();
            }

            graphAsset.name = _graphName;

            if (AssetGraph && uniGraph.name == _graphName)
            {
                graphAsset.position = AssetGraph.position;
                graphAsset.scale    = AssetGraph.scale;
            }

            var sourceGraph = uniGraph;

            if (!uniGraph.useVariants)
            {
                var stage = PrefabStageUtility.GetPrefabStage(uniGraph.gameObject);
                if (Application.isPlaying == false && stage != null && !string.IsNullOrEmpty(stage.assetPath))
                {
                    var asset = AssetDatabase.LoadAssetAtPath <GameObject>(stage.assetPath);
                    sourceGraph = asset.GetComponent <UniGraph>();
                }
            }

            AssetGraph = graphAsset;
            AssetGraph.ConnectToGraph(sourceGraph);

            return(AssetGraph);
        }
예제 #3
0
        public UniExposedParameterFieldView(UniGraphAsset graphView, IUniExposedParameter param, Action <IUniExposedParameter> removeAction)
            : base(null, param.DisplayName, string.Empty)
        {
            this.graphView = graphView;
            _removeAction  = removeAction;
            parameter      = param;
            this.AddManipulator(new ContextualMenuManipulator(BuildContextualMenu));
            this.Q("icon").AddToClassList("parameter-" + param.Info);
            this.Q("icon").visible = true;

            (this.Q("textField") as TextField).RegisterValueChangedCallback((e) => {
                param.DisplayName = e.newValue;
                text = e.newValue;
            });

            var addButton = new Button(ApplyParameter);

            addButton.text = "+";
            Add(addButton);
        }
        protected override void Initialize(BaseGraphView graphView)
        {
            this.graphView  = graphView;
            this.graphAsset = graphView.graph as UniGraphAsset;

            base.title = title;
            scrollable = true;

            graphView.onExposedParameterListChanged += UpdateParameterList;
            graphView.initialized  += UpdateParameterList;
            Undo.undoRedoPerformed += UpdateParameterList;

            RegisterCallback <DragUpdatedEvent>(OnDragUpdatedEvent);
            RegisterCallback <DragPerformEvent>(OnDragPerformEvent);
            RegisterCallback <MouseDownEvent>(OnMouseDownEvent, TrickleDown.TrickleDown);

            UpdateParameterList();

            // Add exposed parameter button
            header.Add(new Button(OnAddClicked)
            {
                text = "+"
            });
        }
 private void OnEnable()
 {
     _asset = target as UniGraphAsset;
 }