The problem of UIPointer ray penetration on VRTK overlapping Canvas (Unity VR)
Problem inquiry
The solution goes straight to the end“ resolvent ”Section.
2020 supplement: the problem has been solved, please move to this article: https://www.azimiao.com/7509.html
void Start(){ if(this.GetComponentInChildren<Button>()){ this. GetComponentInChildren<Button>().onClick. AddListener(this.onBtnClick); } } void onBtnClick(){ Debug. Log("it's" + this.name); }
//VRTK_VRInputModule.cs protected virtual List<RaycastResult> CheckRaycasts(VRTK_UIPointer pointer) { RaycastResult raycastResult = new RaycastResult(); raycastResult.worldPosition = pointer. GetOriginPosition(); raycastResult.worldNormal = pointer. GetOriginForward(); pointer.pointerEventData.pointerCurrentRaycast = raycastResult; List<RaycastResult> raycasts = new List<RaycastResult>(); eventSystem. RaycastAll(pointer.pointerEventData, raycasts); return raycasts; }
Debug. Log ("I hit the UI!, a total of"+raycasts. Count); for (int i = 0; i < raycasts.Count; i++) { Debug. Log(raycasts[i].gameObject.name,raycasts[i].gameObject); }
resolvent
-
20201216 Supplement: This problem has been solved. Please refer to the following articles:
VRTK solves the problem of multi Canvas ray penetration (WorldSpace)
-
Probabilistic solution
Attach these overlapping Canvas Graphic Raycaster Component Blocking Objects Change to All
This is a probabilistic solution to penetration. Some panels work, while others are not.
When it is changed to All, it is also invalid. After running, close and open the rear panel, which can basically solve the problem. The reason is unknown, which may be related to the internal sorting logic. -
cut the weeds and dig up the roots
Avoid overlapping Canvas at the same time in the design phase. If you have to appear, please pray for yourself. -
await one's doom
Waiting for Unity to explain.