armory/Sources/armory/logicnode/CanvasGetInputTextNode.hx

29 lines
700 B
Haxe
Raw Normal View History

2019-09-29 15:39:19 +02:00
package armory.logicnode;
import iron.Scene;
import armory.trait.internal.CanvasScript;
class CanvasGetInputTextNode extends LogicNode {
2019-12-19 23:54:08 +01:00
var canvas: CanvasScript;
2019-09-29 15:39:19 +02:00
2019-12-19 23:54:08 +01:00
public function new(tree: LogicTree) {
2019-09-29 15:39:19 +02:00
super(tree);
}
#if arm_ui
2019-12-19 23:54:08 +01:00
override function get(from: Int) {
2019-09-29 15:39:19 +02:00
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.getHandle(inputs[0].get()).text;
2019-12-19 23:54:08 +01:00
}
catch (e: Dynamic) { return null; }
2019-09-29 15:39:19 +02:00
}
#end
}