Exemplo n.º 1
0
 public Document(string path)
 {
     try {
         Path              = path;
         Format            = ResolveFormat(path);
         RootNodeUnwrapped = Node.CreateFromAssetBundle(path, yuzu: TangerineYuzu.Instance.Value);
         if (Format == DocumentFormat.Fbx)
         {
             Path = defaultPath;
         }
         RootNode = RootNodeUnwrapped;
         SetModificationTimeToNow();
         if (RootNode is Node3D)
         {
             RootNode = WrapNodeWithViewport3D(RootNode);
         }
         Decorate(RootNode);
         Container = RootNode;
         if (Format == DocumentFormat.Scene || Format == DocumentFormat.Tan)
         {
             Preview = DocumentPreview.ReadAsBase64(Project.Current.GetSystemPath(path, GetFileExtension(Format)));
         }
         History.PerformingOperation += Document_PerformingOperation;
     } catch (System.Exception e) {
         throw new System.InvalidOperationException($"Can't open '{path}': {e.Message}");
     }
 }
Exemplo n.º 2
0
 public void SaveAs(string path)
 {
     Project.RaiseDocumetSaving(this);
     Saving?.Invoke(this);
     History.AddSavePoint();
     Path = path;
     WriteNodeToFile(path, Format, RootNodeUnwrapped);
     if (Format == DocumentFormat.Scene || Format == DocumentFormat.Tan)
     {
         DocumentPreview.AppendToFile(Project.Current.GetSystemPath(path, GetFileExtension(Format)), Preview);
     }
     SetModificationTimeToNow();
     Project.Current.AddRecentDocument(Path);
 }