Skip to content

EditorVR camera better represents what is seen in the game view#431

Merged
mtschoen-unity merged 16 commits into
developmentfrom
improvements/dylanu/scene-camera-settings-copy
Dec 9, 2017
Merged

EditorVR camera better represents what is seen in the game view#431
mtschoen-unity merged 16 commits into
developmentfrom
improvements/dylanu/scene-camera-settings-copy

Conversation

@dunity

@dunity dunity commented Nov 27, 2017

Copy link
Copy Markdown
Contributor

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.

@AndrewTHEManeri AndrewTHEManeri left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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; }

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why this context settings class instead of individual settings items being exposed as interface members/requirements?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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).

@dunity

dunity commented Nov 29, 2017

Copy link
Copy Markdown
Contributor Author

@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
@dunity

dunity commented Nov 29, 2017

Copy link
Copy Markdown
Contributor Author

ContextSettings struct removed from IEditingContext & EditorVRContext. copySceneCameraSettings property added to IEditingContext. This is used in VRView OnEnable() when setting up the VRView camera.

@dunity

dunity commented Nov 29, 2017

Copy link
Copy Markdown
Contributor Author

@AndrewTHEManeri your suggested changes have been applied (as I understood them).

@dunity
dunity requested a review from stella3d November 29, 2017 23:43
…ings-copy

# Conflicts:
#	Scripts/Core/Contexts/EditingContextManager.cs
#	Scripts/Core/Contexts/EditorVR.asset
#	Tests/Editor/Unit/Core/EditingContextManagerTests.cs
@dunity
dunity removed the request for review from stella3d December 1, 2017 01:11

@mtschoen-unity mtschoen-unity left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Check out EditorUtility.CopySerialized. You should be able to just AddComponent, and then CopySerialized(source, target)

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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)

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why the null check?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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;

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Making all of this static is a little worrying to me, but I haven't found any issues in testing.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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
@dunity

dunity commented Dec 5, 2017

Copy link
Copy Markdown
Contributor Author

Suggested changes pushed. Please give it another look when you have the time @mtschoen-unity , thanks :-)

@mtschoen-unity

Copy link
Copy Markdown
Collaborator

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.

@jono-unity

Copy link
Copy Markdown
Contributor

@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

@mtschoen-unity

mtschoen-unity commented Dec 9, 2017

Copy link
Copy Markdown
Collaborator

@jono-unity --can confirm. Away it goes, then. I'll force HDR on like I did with the other settings that break things.

@mtschoen-unity

Copy link
Copy Markdown
Collaborator

@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. 👍

@mtschoen-unity

Copy link
Copy Markdown
Collaborator

Manual merge successful. Performing Github merge

@mtschoen-unity
mtschoen-unity merged commit e515e00 into development Dec 9, 2017
@mtschoen-unity
mtschoen-unity deleted the improvements/dylanu/scene-camera-settings-copy branch December 9, 2017 06:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants