-
Notifications
You must be signed in to change notification settings - Fork 126
Refactors WebVRCamera.cs into smaller scripts #215
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
looking good, let me know when you have some updates for me to test in the headset.
also, when you get a chance, could you comment either in this PR or in the issues assigned to you in the v1.2.0
milestone (remaining Unity milestone issues: https://github.com/mozilla/unity-webvr-export/milestone/3) which issues you've fixed already in this PR (or plan to in separate PRs)?
thanks! great work 👍
Assets/WebGLTemplates/WebVR/webvr.js
Outdated
@@ -87,7 +87,7 @@ | |||
return vrDisplay.requestPresent([{source: canvas}]).then(function () { | |||
// Start stereo rendering in Unity. | |||
console.log('Entered VR mode'); | |||
gameInstance.SendMessage('WebVRCameraSet', 'Begin'); | |||
gameInstance.SendMessage('WebVRCameraSet', 'EnterVR'); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Assets/WebGLTemplates/WebVR/webvr.js
Outdated
@@ -100,7 +100,7 @@ | |||
} | |||
function done () { | |||
// End stereo rendering in Unity. | |||
gameInstance.SendMessage('WebVRCameraSet', 'End'); | |||
gameInstance.SendMessage('WebVRCameraSet', 'ExitVR'); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@@ -0,0 +1,34 @@ | |||
using UnityEngine; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: can you sort these lines?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@cvan what's the conversion here? alphabetical?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
went alphabetical
gameObject.transform.position = sitStand.MultiplyPoint(controller.position); | ||
} | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can you add a newline at the EOF?
} | ||
|
||
[System.Serializable] | ||
private class WVRData |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yup, have integrated that work. Class names are a bit different, but we can fix the consistency.
if (wvrData.sitStand.Length > 0) | ||
sitStand = numbersToMatrix (wvrData.sitStand); | ||
|
||
if (OnHeadsetUpdate != null) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
curly braces
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I figured it was still essentially one line with props separated out, so I left them out.
Assets/WebVR/Scripts/WebVRCamera.cs
Outdated
#endif | ||
} | ||
|
||
private void handleVrChange() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
you can call this onVRChange
Assets/WebVR/Scripts/WebVRCamera.cs
Outdated
WebVRManager.OnVrChange += handleVrChange; | ||
WebVRManager.OnHeadsetUpdate += handleHeadsetUpdate; | ||
cameraMain = GameObject.Find("CameraMain").GetComponent<Camera>(); | ||
cameraL = GameObject.Find("CameraL").GetComponent<Camera>(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can this be cameraMain.Find("CameraL").GetComponent<Camera>()
?
Assets/WebVR/Scripts/WebVRCamera.cs
Outdated
|
||
void Start() | ||
{ | ||
WebVRManager.OnVrChange += handleVrChange; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
what's +=
do here? method concatenation? I'm not super familiar with Objective-C
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Adds the function to the delegate. Basically subscribing to an event. When triggered, handeVrChange()
gets run.
Assets/WebVR/Scripts/WebVRCamera.cs
Outdated
|
||
private IEnumerator endOfFrame() | ||
{ | ||
// wait until end of frame to report back to WebVR browser to submit frame. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: capitalise Wait
@caseyyee I tested this, and it works well. nice work! 👍 can you just rebase this one more time? thanks! |
Assets/WebGLTemplates/WebVR/webvr.js
Outdated
@@ -100,7 +100,7 @@ | |||
return vrDisplay.requestPresent([{source: canvas}]).then(function () { | |||
// Start stereo rendering in Unity. | |||
console.log('Entered VR mode'); | |||
gameInstance.SendMessage('WebVRCameraSet', 'OnStartVR'); | |||
gameInstance.SendMessage('WebVRCameraSet', 'EnterVR'); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not blocking but, per consistency, all the events in Unity are of the form On...
. Do you mind if we stick to that convention?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yup! Start and End make more sense anyways.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think he means add the On
prefix
tested in Vive and Windows MR (Dell Visor), looks good. ship it! 👍 |
Basic overview:
WebVRManager
WebVRControllerManager
WebVRCamera
WebVRController