From d9b7224f8dad8f9d45dd4d45e5f62a8e46f36119 Mon Sep 17 00:00:00 2001 From: notwarp Date: Wed, 2 Sep 2020 19:06:21 +0200 Subject: [PATCH] Update UITrait.hx try missing working example ui_script3d --- ui_script3d/Sources/arm/UITrait.hx | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/ui_script3d/Sources/arm/UITrait.hx b/ui_script3d/Sources/arm/UITrait.hx index 0f52ff6..f26db9a 100644 --- a/ui_script3d/Sources/arm/UITrait.hx +++ b/ui_script3d/Sources/arm/UITrait.hx @@ -60,16 +60,16 @@ class UITrait extends iron.Trait { } function update() { - - // We need to figure out if user clicked on the UI plane // Get plane UV var mouse = Input.getMouse(); - var uv = iron.math.RayCaster.getPlaneUV(cast object, mouse.x, mouse.y, iron.Scene.active.camera); + var uv = iron.math.RayCaster.boxIntersect(cast object.transform, mouse.x, mouse.y, iron.Scene.active.camera); if (uv == null) return; // Pixel coords - var px = Std.int(uv.x * uiWidth); - var py = Std.int(uv.y * uiHeight); + var d1 = object.transform.dim; + var px = Std.int(((uv.x-(-d1.x/2)) / ((d1.x/2)-(-d1.x/2)) - object.transform.worldx()) * uiWidth); + var py = Std.int(((uv.z-(d1.z/2)) / ((d1.z/2)-(-d1.z/2)) - object.transform.worldz()) * -uiHeight) ; + // Send input events if (mouse.started()) ui.onMouseDown(0, px, py);