示例#1
0
 public void ReserializeBound()
 {
     if (_subGraphInstance != null)
     {
         _boundSubGraphData  = _subGraphInstance.SerializeToBytes(DataFormat.Binary, ref _boundSubGraphReferences);
         _selfReferenceIndex = _boundSubGraphReferences.FindIndex(r => r == _subGraphInstance);
     }
 }
示例#2
0
        public void ReserializeBound()
        {
            if (_graphInstance != null)
            {
                //Debug.Log("Reserializing Graph Instance: "+_graphInstance);
                _graphInstance.GetNodesByType <SubGraphNode>().ForEach(n => n.ReserializeBound());

                _boundGraphData     = _graphInstance.SerializeToBytes(DataFormat.Binary, ref _boundGraphReferences);
                _selfReferenceIndex = _boundGraphReferences.FindIndex(r => r == _graphInstance);
            }
        }
示例#3
0
        public override void DrawInspector()
        {
            GUI.color = new Color(1, 0.75f, 0.5f);
            if (GUILayout.Button("Open Editor", GUILayout.Height(40)))
            {
                if (DashEditorCore.EditorConfig.editingController != null)
                {
                    DashEditorCore.EditController(DashEditorCore.EditorConfig.editingController,
                                                  GraphUtils.AddChildPath(DashEditorCore.EditorConfig.editingGraphPath, Model.id));
                }
                else
                {
                    DashEditorCore.EditGraph(DashEditorCore.EditorConfig.editingRootGraph,
                                             GraphUtils.AddChildPath(DashEditorCore.EditorConfig.editingGraphPath, Model.id));
                }
            }

            GUI.color = Color.white;

            if (!Model.useAsset)
            {
                if (GUILayout.Button("Save to Asset"))
                {
                    DashGraph graph = GraphUtils.CreateGraphAsAssetFile(SubGraph);
                    if (graph != null)
                    {
                        Model.useAsset   = true;
                        Model.graphAsset = graph;

                        _subGraphInstance   = null;
                        _selfReferenceIndex = -1;
                        _boundSubGraphData  = null;
                        _boundSubGraphReferences.Clear();
                    }
                }
            }
            else
            {
                if (GUILayout.Button("Bind Graph"))
                {
                    DashGraph graph = SubGraph.Clone();
                    _boundSubGraphData  = graph.SerializeToBytes(DataFormat.Binary, ref _boundSubGraphReferences);
                    _selfReferenceIndex = _boundSubGraphReferences.FindIndex(r => r == graph);

                    Model.useAsset   = false;
                    Model.graphAsset = null;
                }
            }

            GUI.color = Color.white;

            base.DrawInspector();
        }
示例#4
0
        public void BindGraph(DashGraph p_graph)
        {
            _assetGraph           = null;
            _graphInstance        = null;
            _selfReferenceIndex   = -1;
            _boundGraphData       = null;
            _boundGraphReferences = null;

            if (p_graph != null)
            {
                DashGraph graph = p_graph.Clone();
                _boundGraphData     = graph.SerializeToBytes(DataFormat.Binary, ref _boundGraphReferences);
                _selfReferenceIndex = _boundGraphReferences.FindIndex(r => r == graph);
            }
        }
示例#5
0
        public static void ExportJSON(DashGraph p_graph)
        {
            var path = EditorUtility.SaveFilePanel(
                "Export Graph JSON",
                Application.dataPath,
                "",
                "json");

            if (!path.IsNullOrWhitespace())
            {
                List <Object> references = new List <Object>();
                byte[]        bytes      = p_graph.SerializeToBytes(DataFormat.JSON, ref references);
                File.WriteAllBytes(path, bytes);
            }
        }