I would like some help on raycasting in a daydream app I am working on. The rays were pretty much perfect until I added some culling masks to the main camera. The idea is to have buttons only show when the touchpad is touched. I have all the other objects set to the default layer with the buttons and panel set to UI layer.
I declare:
private LayerMask dM;
private LayerMask uIM;
private bool touchedPad;
set (in Start):
dM = (1 << LayerMask.NameToLayer(“Default”));
uIM = (1 << LayerMask.NameToLayer(“UI”));
touchedPad = false;
in Update I have:
if (GvrController.IsTouching && !touchedPad) {
StartCoroutine (touchingPad (true));
} else if(!GvrController.IsTouching && touchedPad){
StartCoroutine (touchingPad (false));
}
All this works to get the buttons to show only when the touchpad is touched. If I point the controller at the buttons the selected color shows correctly and the buttons work fine when I press the touchpad.
The ray, with its reticle, is visible until the first time I touch the pad, then everything works but there is no ray to help in aiming. Can you suggest something, or at least suggest a place to look?
This is using the provided prefabs for the pointer and ray or something custom? My guess would be perhaps the ray isn’t on default? Because your bool starts with a value of false I don’t think that method gets executed for the culling masks until you touch for the first time. Have you tried letting everything render instead of setting your culling mask to default in your method.
Would it be possible to just disable the UI’s gameobject when button is not being pressed? This would reduce draw calls I believe being if using culling masks, the objects are still drawn by the GPU.
That’s probably an even better suggestion for you @tharding100 . Rather than mess with the culling masks simply disable/enable the canvas’s gameobject based on touching or not (or panel depending on what you actually want shown or not). In your original example though I have a feeling the ray wasn’t on the default layermask.