IEnumerator Initialize()
{
// Plugin must be initialized OnStart in order to properly
// get a valid surface
GameObject mainCameraGo = GameObject.FindWithTag("MainCamera");
if (mainCameraGo)
{
mainCameraGo.SetActive(false);
Debug.Log("Camera with MainCamera tag found.");
if (!disableInput)
{
Debug.Log("Will use translation and orientation from the MainCamera.");
transform.position = mainCameraGo.transform.position;
transform.rotation = mainCameraGo.transform.rotation;
}
Debug.Log("Disabling Camera with MainCamera tag");
}
GL.Clear(false, true, Color.black);
yield return StartCoroutine(plugin.Initialize());
InitializeCameras();
InitializeEyes();
InitializeOverlays();
if (settings.trackPosition)
{
plugin.SetTrackingMode(SvrPlugin.TrackingMode.kTrackingPosition);
}
else
{
plugin.SetTrackingMode(SvrPlugin.TrackingMode.kTrackingOrientation);
}
plugin.SetVSyncCount((int)settings.vSyncCount);
QualitySettings.vSyncCount = (int)settings.vSyncCount;
}首先在Initialize方法中首先是判断场景中是否存在Tag值为MainCamera的Camera物体,如果存在,隐藏该物体,并设置SvrManager脚本物体的初始位置为MainCamera物体初始位置。