Provide an easy way to update the default canvas raycasting camera for projects using uGUI. New users are not affected, because we're already prompting them when they create new canvases.
Currently the only easy way to do this is by using the scene configuration menu and re-adding the InputManager.
More advanced users can also manually call the update using FocusManager.Instance.UpdateCanvasEventSystems();
When devs open legacy projects, we should prompt them once if they wish to update their canvases default raycasting camera if the canvas' render mode is set to world space.
Currently older projects are automatically opted out to using the new UIRaycastCamera as the default raycaster, and devs need to manually assign the camera to each canvas who's render mode is set to world space.
Any/All
405bb16be62b5d1eb18f8e5f39d9d1fe9a962013
Is the MixedRealityCamera the UIRaycastCamera?
No, See #1442
One thing to note is that for multi-scene projects, there won't necessarily be a camera after the iniitial scene, so you will need to guide them to use the UpdateCanvasEventSystems call:
FocusManager.Instance.UpdateCanvasEventSystems()
I think the Keyboard prefab in the MRTK might need an update due to this. If you just drag and drop it into the scene it won't automatically work (ie - won't be detected by gaze/raycast). To fix it you just have to click the Canvas component Render Mode drop-down and re-select World Space (cause it was already selected). This triggers your little warning about "In order for the Input Manager to work properly with uGUI raycasting..." After that it works.
Just was scratching my head for a few minutes trying to figure out what the deal was. Hope to save someone having to remember this in the future.
Suggesting to add a checkbox to the FocusManager to call UpdateCanvasEventSystems on scene loading.
Suggesting to add a checkbox to the FocusManager to call UpdateCanvasEventSystems on scene loading.
No, That's not a good idea. It should be serialized in the scene before runtime.
Adding this referene is not possible with the new "Global" Singleton pattern, as the Input Manager is "DontDestroyOnLoad". When creating the "next scene" we do not have a reference in the scene to any of the "global managers" and by result the UIRaycastCamera.
This is really bad in many ways, but that discussion can be reserved for the new Singleton discussion.
@Strepto you can get the reference in the new scene via InputManager.Instance.UIRaycastCamera.
The Singleton pattern was adjusted to do exactly what you say it's preventing.
Ref earlier comment:
Suggesting to add a checkbox to the FocusManager to call UpdateCanvasEventSystems on scene loading.
No, That's not a good idea. It should be serializing the scene before you ever have to load a scene.
That would be writing a script that does exactly what is suggested above would it not?
Only for when you're in the editor, not during runtime.
The system already prompts you to use the UIRaycastCamera when you create a new canvas and change its render mode to world space. This is more for users who want to update and would like to do it without the manual work.
I think the issue is in remembering to add a new script in each new scene to call
FocusManager.Instance.UpdateCanvasEventSystems()
Ideally this script would live on the Camera object. It could have a delegate to
SceneManager.sceneLoaded
And thus would be responsible for rewiring the connection itself. At a minimum, the documentation could use a section calling out changes required for multi-scene projects.
Guys, I don't think you even know what this issue is really about.
I made a new system to do uGUI raycasting, and it depends on a UIRaycastingCamera.
That camera needs all the canvases (that use world space) in your projects scenes to use it so the InputSystem works correctly.
This data is _stored_ and _serialized_ in the scene on the canvas components themselves and shouldn't be changed at runtime.
The issues is about making an editor tool to easily update the old canvases that use world space to utilize this new system.
But I cannot add the UI Raycast Camera to the Unity Canvas, because I do not have a Input Manager (Which contains the Raycast Camera) in my "work-scene". The Input Manager Prefab is marked as DontDestroyOnLoad in my "Startup scene", and is thus removed from my Work-Scene for serialization. I still believe this is relevant to this discussion.

I like the solution you made for Raycasting Unity UI from multiple locations. But it has (in combination with the Singleton change) created issues when trying to update our (multi-scene) projects to the latest version of the MR-Toolkit. And i'm trying to to figure out how we should proceed.
Sorry if i'm still wrong here, but I still can't see how I should do this correctly.
Edit: Tried to make myself a bit more understandable.
Ahh, I think I understand now.
Essentially what you're going to want to do is have a component on each canvas that checks the render mode, and if it's set to world space, to set the UIRaycastCamera.
I'll be sure to address this with the PR