Pamela Wolf 4 年之前
父节点
当前提交
1e12dabdd9
共有 2 个文件被更改,包括 10 次插入28 次删除
  1. 8 5
      guiEditor/src/diagram/graphCanvas.tsx
  2. 2 23
      guiEditor/src/graphEditor.tsx

+ 8 - 5
guiEditor/src/diagram/graphCanvas.tsx

@@ -620,7 +620,6 @@ export class GraphCanvasComponent extends React.Component<IGraphCanvasComponentP
     }
     }
 
 
     onUp(evt: React.PointerEvent) {
     onUp(evt: React.PointerEvent) {
-
         this._mouseStartPointX = null;
         this._mouseStartPointX = null;
         this._mouseStartPointY = null;
         this._mouseStartPointY = null;
         this._rootContainer.releasePointerCapture(evt.pointerId);   
         this._rootContainer.releasePointerCapture(evt.pointerId);   
@@ -953,13 +952,17 @@ export class GraphCanvasComponent extends React.Component<IGraphCanvasComponentP
         // GUI
         // GUI
         this._advancedTexture = BABYLON.GUI.AdvancedDynamicTexture.CreateFullscreenUI("UI");
         this._advancedTexture = BABYLON.GUI.AdvancedDynamicTexture.CreateFullscreenUI("UI");
         
         
-        this.addNewButton();
-        
         engine.runRenderLoop(() => {this.updateGUIs(); scene.render()});
         engine.runRenderLoop(() => {this.updateGUIs(); scene.render()});
     }
     }
+    
 
 
     public addNewButton()
     public addNewButton()
     {
     {
+        if(!this._advancedTexture)
+        {
+            this.createGUICanvas();
+        }
+
         var button1 = BABYLON.GUI.Button.CreateSimpleButton("but1", "Click Me");
         var button1 = BABYLON.GUI.Button.CreateSimpleButton("but1", "Click Me");
         button1.width = "150px"
         button1.width = "150px"
         button1.height = "40px";
         button1.height = "40px";
@@ -967,9 +970,8 @@ export class GraphCanvasComponent extends React.Component<IGraphCanvasComponentP
         button1.cornerRadius = 20;
         button1.cornerRadius = 20;
         button1.background = "green";
         button1.background = "green";
         button1.onPointerUpObservable.add(function() {
         button1.onPointerUpObservable.add(function() {
-            alert("you did it!");
         });
         });
-        this._guis.push(button1 );
+        this._guis.push(button1);
         this._advancedTexture.addControl(button1);    
         this._advancedTexture.addControl(button1);    
     }
     }
 
 
@@ -978,6 +980,7 @@ export class GraphCanvasComponent extends React.Component<IGraphCanvasComponentP
     updateGUIs()
     updateGUIs()
     {
     {
         this._guis.forEach(element => {
         this._guis.forEach(element => {
+            element.paddingLeft == 1;
             //should create a new component type that has the contrainer ias a property.
             //should create a new component type that has the contrainer ias a property.
             //with then have the update information.
             //with then have the update information.
             
             

+ 2 - 23
guiEditor/src/graphEditor.tsx

@@ -565,29 +565,8 @@ export class GraphEditor extends React.Component<IGraphEditorProps, IGraphEditor
         var data = event.dataTransfer.getData("babylonjs-material-node") as string;
         var data = event.dataTransfer.getData("babylonjs-material-node") as string;
         let newNode: GraphNode;
         let newNode: GraphNode;
         
         
-        if(data.indexOf("Custom") > -1) {
-            let storageData = localStorage.getItem(data);
-            if(storageData) {   
-                let frameData = JSON.parse(storageData);
-
-                //edit position before loading.
-                let newX = (event.clientX - event.currentTarget.offsetLeft - this._graphCanvas.x - this.NodeWidth) / this._graphCanvas.zoom;
-                let newY = (event.clientY - event.currentTarget.offsetTop - this._graphCanvas.y - 20) / this._graphCanvas.zoom;;
-                let oldX = frameData.editorData.frames[0].x;
-                let oldY = frameData.editorData.frames[0].y;
-                frameData.editorData.frames[0].x = newX;
-                frameData.editorData.frames[0].y = newY;
-                for (var location of frameData.editorData.locations) {
-                    location.x +=  newX - oldX;
-                    location.y +=  newY - oldY;       
-                }
-
-                SerializationTools.AddFrameToMaterial(frameData, this.props.globalState, this.props.globalState.nodeMaterial); 
-                this._graphCanvas.frames[this._graphCanvas.frames.length -1].cleanAccumulation();
-                this.forceUpdate();
-                return;
-            }
-        }
+        //new code for gui editor.
+        this._graphCanvas.addNewButton();
 
 
         if (data.indexOf("Block") === -1) {
         if (data.indexOf("Block") === -1) {
             newNode = this.addValueNode(data);
             newNode = this.addValueNode(data);