Ver código fonte

getting clickable gui element

Pamela Wolf 4 anos atrás
pai
commit
d4a3fdbadb

+ 11 - 3
guiEditor/src/diagram/graphNode.ts

@@ -4,7 +4,7 @@ import { Nullable } from 'babylonjs/types';
 import { Observer } from 'babylonjs/Misc/observable';
 import { NodeMaterialConnectionPoint } from 'babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint';
 import { GraphCanvasComponent, FramePortData } from './graphCanvas';
-import { PropertyLedger } from './propertyLedger';
+import { PropertyGuiLedger, PropertyLedger } from './propertyLedger';
 import * as React from 'react';
 import { GenericPropertyComponent } from './properties/genericNodePropertyComponent';
 import { DisplayLedger } from './displayLedger';
@@ -374,12 +374,20 @@ export class GraphNode {
     }
 
     public renderProperties(): Nullable<JSX.Element> {
-        let control = PropertyLedger.RegisteredControls[this.block.getClassName()];
-
+        let className = this.guiNode ? this.guiNode.getClassName() : "";
+        let control = PropertyGuiLedger.RegisteredControls[className];
+        
         if (!control) {
             control = GenericPropertyComponent;
         }
 
+        if(this.guiNode) {
+            return React.createElement(control, {
+            globalState: this._globalState,
+            block: this.block,
+            guiBlock: this.guiNode
+            });
+        }
         return React.createElement(control, {
             globalState: this._globalState,
             block: this.block

+ 23 - 0
guiEditor/src/diagram/properties/buttonGuiPropertyComponent copy.tsx

@@ -0,0 +1,23 @@
+
+import * as React from "react";
+import { LineContainerComponent } from '../../sharedComponents/lineContainerComponent';
+import { IPropertyComponentProps } from './propertyComponentProps';
+import { CheckBoxLineComponent } from '../../sharedComponents/checkBoxLineComponent';
+import { TransformBlock } from 'babylonjs/Materials/Node/Blocks/transformBlock';
+import { GeneralPropertyTabComponent } from './genericNodePropertyComponent';
+
+export class ButtonPropertyTabComponent extends React.Component<IPropertyComponentProps> {
+    constructor(props: IPropertyComponentProps) {
+        super(props)
+    }
+
+    render() {
+        return (
+            <>                
+                <GeneralPropertyTabComponent globalState={this.props.globalState} block={this.props.block}/>
+                <LineContainerComponent title="PROPERTIES">
+                </LineContainerComponent>            
+            </>
+        );
+    }
+}

+ 1 - 0
guiEditor/src/diagram/properties/propertyComponentProps.ts

@@ -4,4 +4,5 @@ import { NodeMaterialBlock } from 'babylonjs/Materials/Node/nodeMaterialBlock';
 export interface IPropertyComponentProps {
     globalState: GlobalState;
     block: NodeMaterialBlock;
+    guiBlock?: BABYLON.GUI.Container;
 }

+ 9 - 1
guiEditor/src/diagram/propertyLedger.ts

@@ -7,11 +7,16 @@ import { LightPropertyTabComponent } from './properties/lightPropertyTabComponen
 import { LightInformationPropertyTabComponent } from './properties/lightInformationPropertyTabComponent';
 import { TexturePropertyTabComponent } from './properties/texturePropertyTabComponent';
 import { TrigonometryPropertyTabComponent } from './properties/trigonometryNodePropertyComponent';
+import { ButtonPropertyTabComponent } from './properties/buttonGuiPropertyComponent copy';
 
 export class PropertyLedger {
     public static RegisteredControls: {[key: string] : ComponentClass<IPropertyComponentProps>} = {};
 }
 
+export class PropertyGuiLedger {
+    public static RegisteredControls: {[key: string] : ComponentClass<IPropertyComponentProps>} = {};
+}
+
 PropertyLedger.RegisteredControls["TransformBlock"] = TransformPropertyTabComponent;
 PropertyLedger.RegisteredControls["InputBlock"] = InputPropertyTabComponent;
 PropertyLedger.RegisteredControls["GradientBlock"] = GradientPropertyTabComponent;
@@ -23,4 +28,7 @@ PropertyLedger.RegisteredControls["ReflectionBlock"] = TexturePropertyTabCompone
 PropertyLedger.RegisteredControls["RefractionBlock"] = TexturePropertyTabComponent;
 PropertyLedger.RegisteredControls["CurrentScreenBlock"] = TexturePropertyTabComponent;
 PropertyLedger.RegisteredControls["ParticleTextureBlock"] = TexturePropertyTabComponent;
-PropertyLedger.RegisteredControls["TrigonometryBlock"] = TrigonometryPropertyTabComponent;
+PropertyLedger.RegisteredControls["TrigonometryBlock"] = TrigonometryPropertyTabComponent;
+
+
+PropertyGuiLedger.RegisteredControls["Button"] = ButtonPropertyTabComponent;