Пример #1
0
        private void SaveNodeToLibrary(Node node, string path)
        {
            try
            {
                if (!Directory.Exists(path))
                {
                    Directory.CreateDirectory(path);
                }
                //copy from library
                var source = node.FullFolderPath;
                if (Directory.Exists(source))
                {
                    SaverLoader.CopyFilesRecursively(new DirectoryInfo(source), new DirectoryInfo(path), true);
                }

                //delete paths.meta
                var pathMetaFile = Path.Combine(path, UserSettings.Instance.PathsMetaFileName);
                if (File.Exists(pathMetaFile))
                {
                    File.Delete(pathMetaFile);
                }

                Bus.LibraryChanged += true;
            }
            catch (Exception ex)
            {
                UIManager.ShowDialog(null, ex.Message, "Ok");
                UnityEngine.Debug.LogException(ex);
            }
        }
Пример #2
0
        public void RefreshNode()
        {
            Bus.ClosePopupMenu += true;
            AddKnobsFromSource(FullFolderPath);

            SaverLoader.Save(Graph.Instance, Graph.Instance.SceneFilePath);
            Bus.SceneChanged += true;
        }
Пример #3
0
 internal static void CloneNode(Graph graph, Node source)
 {
     using (var command = new StateCommand("Clone node"))
     {
         var node = GameObject.Instantiate(graph.NodePrefab, graph.NodesHolder.transform);
         node.Init();
         node.transform.position  = new Vector3(Screen.width / 2, Screen.height / 2);
         node.HeaderText          = source.HeaderText;
         node.SourceLibraryFolder = source.SourceLibraryFolder;
         node.RemoveKnobs();
         node.AddKnobsFromSource(source.FullFolderPath);
         SaverLoader.Save(Graph.Instance, Graph.Instance.SceneFilePath);
         SaverLoader.CopyFilesRecursively(new DirectoryInfo(source.FullFolderPath), new DirectoryInfo(node.FullFolderPath), true);
     }
     Bus.SceneChanged += true;
 }
Пример #4
0
        public void Dispose()
        {
            var buffer = new byte[0];

            using (var ms = new MemoryStream())
            {
                SaverLoader.SavePxw(Graph.Instance, ms);
                buffer = ms.ToArray();
            }

            redo = () =>
            {
                using (var ms = new MemoryStream(buffer))
                    SaverLoader.Load(Graph.Instance, ms, true);
                SaverLoader.Save(Graph.Instance, Graph.Instance.SceneFilePath);
                Bus.SceneChanged += true;
            };

            SaverLoader.Save(Graph.Instance, Graph.Instance.SceneFilePath);
            Bus.SceneChanged += true;
        }
Пример #5
0
        public StateCommand(string actionDesc)
        {
            ActionDescription = actionDesc;

            var buffer = new byte[0];

            using (var ms = new MemoryStream())
            {
                SaverLoader.SavePxw(Graph.Instance, ms);
                buffer = ms.ToArray();
            }

            undo = () =>
            {
                using (var ms = new MemoryStream(buffer))
                {
                    SaverLoader.Load(Graph.Instance, ms, true);
                }
                SaverLoader.Save(Graph.Instance, Graph.Instance.SceneFilePath);
                Bus.SceneChanged += true;
            };

            UndoRedoManager.Instance.Add(this);
        }
Пример #6
0
 public static void LoadGraph(string filePath)
 {
     SaverLoader.Load(graph, filePath, true);
     Bus.SceneFilePathChanged += true;
     UndoRedoManager.Instance.ClearHistory();
 }
Пример #7
0
 public static void SaveGraph(string filePath)
 {
     SaverLoader.Save(graph, filePath);
     Bus.SceneFilePathChanged += true;
 }