/// <summary>Checks if the given hit was on a WorldUI. If it was, it runs the click and returns true.</summary> /// <param name="hit">The successful raycast hit.</param> public static HitResult HandleWorldUIHit(RaycastHit hit){ HitResult result=new HitResult(); Transform transform=hit.transform; if(WorldInputMode==InputMode.Physics){ // If we're in Physics mode, we're looking for MeshColliders on batches with the following name. if(transform.name=="PowerUI-CMesh"){ // We got one! Which WorldUI is it? if(result.FindWorldUI(hit.transform.parent)){ // Got the WorldUI in the result now. result.FindElement(hit); } return result; } }else if(WorldInputMode==InputMode.Screen){ // If we're in Screen mode, we're looking for a box collider with the following name. if(transform.name=="PowerUI-BatchBox"){ // We got one! Which WorldUI is it? if(result.FindWorldUI(transform.parent)){ // Got the WorldUI in the result now. result.ScreenMode=true; // Next, we need to map the location on the front of the box to our 2D point. // First, whats the point relative to the box? Vector3 point=transform.InverseTransformPoint(hit.point); // Great - we now have a relative point from +-0.5 in x and y. result.SetRelativePoint(point.x,point.y); } return result; } } return result; }
/// <summary>Checks if the given hit was on a WorldUI. If it was, it runs the click and returns true.</summary> /// <param name="hit">The successful raycast hit.</param> public static HitResult HandleUIHit(RaycastHit hit){ HitResult result=new HitResult(); Transform transform=hit.transform; // Only occurs in physics mode - we're looking for a transform with the following name: if(transform.name=="PowerUI-CMesh"){ // Great! Hit the main UI. // Which element did it come from? result.FindElement(hit); } return result; }