EditorVR camera better represents what is seen in the game view#431
Conversation
… a scene MainCamera exists).
…used for latter re-setting in OnDisable
… OnCameraSetupStarted()
AndrewTHEManeri
left a comment
There was a problem hiding this comment.
Not on hardware so I can't test this out - what happens if you have a main camera that has more exotic settings - like set to deferred rendering?
|
|
||
| namespace UnityEditor.Experimental.EditorVR.Core | ||
| { | ||
| public struct ContextSettings |
There was a problem hiding this comment.
This should be in a separate file so that IEditingContext is not dependent on EditorVRContext
| /// <summary> | ||
| /// Settings denoting that the scene camera's (component_ values should be cloned on the XR runtime camera | ||
| /// </summary> | ||
| ContextSettings contextSettings { get; } |
There was a problem hiding this comment.
Why this context settings class instead of individual settings items being exposed as interface members/requirements?
There was a problem hiding this comment.
I was initially trying to avoid adding the copySceneCameraSettings param to IEditingContext. The initial number of settings were more numerous when accounting for PostFX settings (coming in a latter PR). Though after I minimized the implementation, it now makes sense to merge it back into IEditingContext, and remove the ContextSettings struct (for now).
|
@AndrewTHEManeri These changes intentionally allow for copying of any camera settings that aren't replaced by those that are defined in VRView OnEnable(), including forward/deferred/etc. VRView still sets/replaces values for CameraType/OcclusionCulling/ClipPlanes. Ideally, we could also support an EVR "CameraCopy" component, that users could set on their desired camera. Such a component would have toggles allowing for individual copying of specific params, etc. On personal projects, I'm needing such camera settings copying. |
… include copySceneCameraSettings property in IEditingContext; this is used in VRView OnEnable() when setting up the VRView camera
|
ContextSettings struct removed from IEditingContext & EditorVRContext. copySceneCameraSettings property added to IEditingContext. This is used in VRView OnEnable() when setting up the VRView camera. |
|
@AndrewTHEManeri your suggested changes have been applied (as I understood them). |
…ings-copy # Conflicts: # Scripts/Core/Contexts/EditingContextManager.cs # Scripts/Core/Contexts/EditorVR.asset # Tests/Editor/Unit/Core/EditingContextManagerTests.cs
…ntextManager post-dev-merge
mtschoen-unity
left a comment
There was a problem hiding this comment.
Just one change request, which is to use EditorUtility.CopySerialized in your CopyComponent method.
| return component; | ||
| } | ||
|
|
||
| public static T CopyComponent<T>(T sourceComponent, GameObject targetGameObject) where T : Component |
There was a problem hiding this comment.
Check out EditorUtility.CopySerialized. You should be able to just AddComponent, and then CopySerialized(source, target)
There was a problem hiding this comment.
good call; I'm refactoring the method now
| m_Instance.Shutdown(); // Give a chance for dependent systems (e.g. serialization) to shut-down before destroying | ||
| ObjectUtils.Destroy(m_Instance.gameObject); | ||
| m_Instance = null; | ||
| if (m_Instance) |
There was a problem hiding this comment.
Why the null check?
There was a problem hiding this comment.
I ran into a case that produced an exception when calling Dispose() before the EXR instance is created in IEditingContext's Setup() function. I've just pushed an alternate fix that validates that an instance has been created, via the instanceExists bool prop in IEditingContext, before attempting to dispose in EditingContextManager's SetEditingContext() function.
|
|
||
| List<IEditingContext> m_AvailableContexts; | ||
| string[] m_ContextNames = null; | ||
| string[] m_ContextNames; |
There was a problem hiding this comment.
Making all of this static is a little worrying to me, but I haven't found any issues in testing.
There was a problem hiding this comment.
There's a need to access some context data before instantiation occurs. I ran a ton of tests too, and couldn't find any issues. If anyone wants to suggest, or craft a better solution, I'm open to any input/changes.
…ool prop in IEditingContext, before attempting to dispose in EditingContextManager's SetEditingContext() function
…ty.CopySerialized instead of custom logic
|
Suggested changes pushed. Please give it another look when you have the time @mtschoen-unity , thanks :-) |
…ditorVR into improvements/dylanu/scene-camera-settings-copy
Fix issue where camera settings copy doesn't happen the first time you launch EXR after a domain reload
|
Forgot to mention in my commit message that the last one also fixes an issue with the Editing Context popup in VRView if there is >1 context available. It was broken since the GUILaout->GUI refactor. @AndrewTHEManeri I'm done making changes and this should be good to go. Still waiting on your approval. |
|
@dunity here's some funky behavior: it looks like if 'Allow HDR' is false on a camera, the presentation camera gets squished. I'm seeing this in an empty (just camera and light) scene and in the Poly Pirates main scene, and not on dev. In this vid, I'm toggling 'presentation camera': https://youtu.be/Zpk_kMgKGCU |
|
@jono-unity --can confirm. Away it goes, then. I'll force HDR on like I did with the other settings that break things. |
|
@stella3d this feature is a perfect example for your AI monkey script. It could run EXR with all permutations of camera settings and record failures. 👍 |
|
Manual merge successful. Performing Github merge |
Purpose of this PR
This improvement allows for the EditorVR VRView camera to better represent what is seen in the game view.
Add support for copying the scene's MainCamera settings (clear flags, background, etc), if one exists, and the (EditorVR)context's m_CopySceneCameraSettings inspector bool/toggle is enabled.
Testing status
Tested in various scenes and camera settings scenarios. Tested with and without a MainCamera in the scene.
Technical risk
Medium - The majority of the changes are relegated to EditorVRContext, EditingContextManager, and VRView. These are core EVR elements; some of their fields/properties have been made static, in order to allow for this functionality to occur as/when needed. Care has been taken to avoid conflicting with the previous AddComponent approach. Disabling the m_CopySceneCameraSettings bool on the EditorVR context will disable this functionality, and create the camera in the manner that was previously occurring.
Notes
I've also added initial support for the Unity PostProcessing(v2) stack in the following branch: "improvements/dylanu/scene-camera-fx-settings". There is more work to be done in that branch before PR. This branch/PR acts as the foundation for that work.