I have created a canvas and aligned it to the viewport and have added UI buttons that I need to respond to the stylus by highlighting when hovered over or clicked.
I have enabled Mouse Emulation in the inspector.
They do not respond to the stylus at all currently.
I am using Unity 2017 with C# and the StylusObjectManiupulationSample script for grabbing and rotating objects.
The problem with mouse interaction you’re probably encountering is the UI canvas referencing the wrong camera to determine where the mouse is. When zCore initializes, it creates and draws from its own internally managed cameras not present in the scene inspector.
My best advice for that particular issue is to give your canvas a reference to zCore’s center camera on start.
canvas.worldCamera = zCore.GetCenterCamera();
UI+Stylus is a different matter. Currently, we’re leaving that up to developers to formulate their own solutions. The latest, and best approach I’ve seen involves extending Unity’s “StandardInputModule”. I’m looking into the possibility of us sharing one of those potential solutions and will report back here in that event that I get a green light. For now I’d recommend working under the assumption that you’ll have to kick up something from scratch.
zCore.GetCenterCamera(); isn’t an available function in the current 5.0 release of zcore. The alternative is a bit more complicated, so I’m sharing a script here that will facilitate a proper UI raycast camera.
Here are some instructions to get it working.
Add an extra camera to the scene.
Disable/uncheck the camera component. (since it doesn’t need to draw anything)
Add the script linked below to the gameobject of the new camera.
Assign the new camera to the “Event Camera” property of the UI’s canvas component through the inspector.
(When testing in the editor, resize zCore’s preview window to match the position and dimensions of the game view window.)
I also can’t get the stylus to work on Unity UI elements, and this script does not work for me. I am using Unity 2018.2 with StylusObjectManipulationSample.cs and have enabled mouse emulation.
The solution above is for the purpose of enabling interaction by mouse input. It only works for the stylus so long as mouse emulation is enabled on the zCore instance.
Besides mouse emulation, out-of-the-box stylus UI interaction isn’t available yet. The best solution at the moment is to write a custom version of Unity’s StandardInputModule to work with the stylus as an input device.
As soon as a pre-made solution does become available, I will be broadcasting that information to relevant posts on this forum, and to registered developer emails.