浏览代码

bug fixing

msDestiny14 4 年之前
父节点
当前提交
190849d85c
共有 2 个文件被更改,包括 15 次插入9 次删除
  1. 1 2
      guiEditor/src/diagram/workbench.tsx
  2. 14 7
      guiEditor/src/guiEditor.ts

+ 1 - 2
guiEditor/src/diagram/workbench.tsx

@@ -60,7 +60,7 @@ export class WorkbenchComponent extends React.Component<IWorkbenchComponentProps
     public _frameIsMoving = false;
     public _isLoading = false;
     public isOverGUINode = false;
-
+    
     public get gridSize() {
         return this._gridSize;
     }
@@ -139,7 +139,6 @@ export class WorkbenchComponent extends React.Component<IWorkbenchComponentProps
 
     constructor(props: IWorkbenchComponentProps) {
         super(props);
-
         props.globalState.onSelectionChangedObservable.add(selection => {  
             console.log(selection);
             this.selectedGuiNodes.forEach(element => {

+ 14 - 7
guiEditor/src/guiEditor.ts

@@ -4,7 +4,6 @@ import { GlobalState } from "./globalState";
 import { WorkbenchEditor } from "./workbenchEditor";
 import { Popup } from "./sharedUiComponents/lines/popup";
 import { Observable } from "babylonjs/Misc/observable";
-import { WorkbenchComponent } from "./diagram/workbench";
 
 /**
  * Interface used to specify creation options for the gui editor
@@ -32,6 +31,14 @@ export class GUIEditor {
             if (popupWindow) {
                 popupWindow.close();
             }
+            if(options.currentSnippetToken) {
+                try {
+                    this._CurrentState.workbench.loadFromSnippet(options.currentSnippetToken);
+                } catch (error) {
+                    //swallow and continue
+                }
+            }
+            return;
         }
 
         let hostElement = options.hostElement;
@@ -45,7 +52,7 @@ export class GUIEditor {
         globalState.hostDocument = hostElement.ownerDocument!;
         globalState.customSave = options.customSave;
         globalState.hostWindow = hostElement.ownerDocument!.defaultView!;
-        
+
         const graphEditor = React.createElement(WorkbenchEditor, {
             globalState: globalState,
         });
@@ -54,18 +61,18 @@ export class GUIEditor {
         // create the middle workbench canvas
         if (!globalState.guiTexture) {
             globalState.workbench.createGUICanvas();
-            try {
-                if(options.currentSnippetToken) {
+            if(options.currentSnippetToken) {
+                try {
                     globalState.workbench.loadFromSnippet(options.currentSnippetToken);
+                
+                } catch (error) {
+                    //swallow and continue
                 }
-            } catch (error) {
-                console.log(error);
             }
         }
 
         if (options.customLoadObservable) {
             options.customLoadObservable.add((data) => {
-                //TODO: Add deserilization here.
                 globalState.onResetRequiredObservable.notifyObservers();
                 globalState.onBuiltObservable.notifyObservers();
             });