@@ -1,9 +1,11 @@
|
|||||||
import { Control } from "godot"
|
import { Control } from "godot"
|
||||||
|
import { Renderer } from "react-godot-renderer"
|
||||||
|
import { TestUi2Component } from "./TestUi2Component"
|
||||||
|
|
||||||
|
|
||||||
export default class TestUi2 extends Control {
|
export default class TestUi2 extends Control {
|
||||||
// Called when the node enters the scene tree for the first time.
|
// Called when the node enters the scene tree for the first time.
|
||||||
_ready(): void {
|
_ready(): void {
|
||||||
|
Renderer.renderComponent(this, TestUi2Component)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
33
packages/example/src/TestUi2Component.tsx
Normal file
33
packages/example/src/TestUi2Component.tsx
Normal file
@@ -0,0 +1,33 @@
|
|||||||
|
import Godot from "godot"
|
||||||
|
import { useState } from "react"
|
||||||
|
import { Component } from "react-godot-renderer"
|
||||||
|
|
||||||
|
|
||||||
|
const HFlowContainer = Component.make(Godot.HFlowContainer)
|
||||||
|
const VFlowContainer = Component.make(Godot.VFlowContainer)
|
||||||
|
const Label = Component.make(Godot.Label)
|
||||||
|
const CheckBox = Component.make(Godot.CheckBox)
|
||||||
|
|
||||||
|
export function TestUi2Component() {
|
||||||
|
const [show, setShow] = useState(false)
|
||||||
|
|
||||||
|
const checkBoxRef = CheckBox.useRef()
|
||||||
|
Component.useSignal(checkBoxRef, "toggled", setShow)
|
||||||
|
|
||||||
|
|
||||||
|
return (
|
||||||
|
<VFlowContainer>
|
||||||
|
<HFlowContainer>
|
||||||
|
<Label text="Show" />
|
||||||
|
<CheckBox
|
||||||
|
ref={checkBoxRef}
|
||||||
|
button_pressed={show}
|
||||||
|
/>
|
||||||
|
</HFlowContainer>
|
||||||
|
|
||||||
|
{show &&
|
||||||
|
<Label text="Shown" />
|
||||||
|
}
|
||||||
|
</VFlowContainer>
|
||||||
|
)
|
||||||
|
}
|
||||||
@@ -160,9 +160,9 @@ export const make = () => {
|
|||||||
// getInstanceFromScope(_scopeInstance) {
|
// getInstanceFromScope(_scopeInstance) {
|
||||||
// throw new Error("Function not implemented.")
|
// throw new Error("Function not implemented.")
|
||||||
// },
|
// },
|
||||||
// detachDeletedInstance(_node) {
|
detachDeletedInstance(node) {
|
||||||
// throw new Error("Function not implemented.")
|
node.queue_free()
|
||||||
// },
|
},
|
||||||
|
|
||||||
// supportsHydration: false,
|
// supportsHydration: false,
|
||||||
// NotPendingTransition: undefined,
|
// NotPendingTransition: undefined,
|
||||||
|
|||||||
Reference in New Issue
Block a user