Files
LNXSDK/leenkx/Sources/leenkx/logicnode/CanvasGetVisibleNode.hx

31 lines
759 B
Haxe
Raw Normal View History

2025-01-22 16:18:30 +01:00
package leenkx.logicnode;
import iron.Scene;
import leenkx.trait.internal.CanvasScript;
class CanvasGetVisibleNode extends LogicNode {
var canvas: CanvasScript;
public function new(tree: LogicTree) {
super(tree);
}
#if lnx_ui
override function get(from: Int): Dynamic { // Null<Bool>
var element: String = inputs[0].get();
if (canvas == null) canvas = Scene.active.getTrait(CanvasScript);
if (canvas == null) canvas = Scene.active.camera.getTrait(CanvasScript);
if (canvas == null || !canvas.ready) return null;
// This Try/Catch hacks around an issue where the handles are
// not created yet, even though canvas.ready is true.
try {
return canvas.getElement(element).visible;
}
catch (e: Dynamic) { return null; }
}
#end
}