IEnumerator LoadScene(int SceneIndex) { foreach (Transform child in transform) { GameObject.Destroy(child.gameObject); } yield return(loader.Load(SceneIndex)); }
IEnumerator Start() { var loader = new GLTFSceneImporter( Url, gameObject.transform ); yield return(loader.Load(-1, Multithreaded)); IntegrationTest.Pass(); }
IEnumerator Start() { var loader = new GLTFSceneImporter( Url, gameObject.transform ); loader.SetShaderForMaterialType(GLTFSceneImporter.MaterialType.PbrMetallicRoughness, GLTFStandard); yield return(loader.Load(-1, Multithreaded)); //IntegrationTest.Pass(); }
private IEnumerator LoadSourceControllerModel(InteractionSource source) { byte[] fileBytes; GameObject controllerModelGameObject; if (GLTFMaterial == null) { Debug.Log("If using glTF, please specify a material on " + name + "."); yield break; } #if !UNITY_EDITOR // This API returns the appropriate glTF file according to the motion controller you're currently using, if supported. IAsyncOperation <IRandomAccessStreamWithContentType> modelTask = source.TryGetRenderableModelAsync(); if (modelTask == null) { Debug.Log("Model task is null; loading alternate."); LoadAlternateControllerModel(source); yield break; } while (modelTask.Status == AsyncStatus.Started) { yield return(null); } IRandomAccessStreamWithContentType modelStream = modelTask.GetResults(); if (modelStream == null) { Debug.Log("Model stream is null; loading alternate."); LoadAlternateControllerModel(source); yield break; } if (modelStream.Size == 0) { Debug.Log("Model stream is empty; loading alternate."); LoadAlternateControllerModel(source); yield break; } fileBytes = new byte[modelStream.Size]; using (DataReader reader = new DataReader(modelStream)) { DataReaderLoadOperation loadModelOp = reader.LoadAsync((uint)modelStream.Size); while (loadModelOp.Status == AsyncStatus.Started) { yield return(null); } reader.ReadBytes(fileBytes); } #else IntPtr controllerModel = new IntPtr(); uint outputSize = 0; if (TryGetMotionControllerModel(source.id, out outputSize, out controllerModel)) { fileBytes = new byte[Convert.ToInt32(outputSize)]; Marshal.Copy(controllerModel, fileBytes, 0, Convert.ToInt32(outputSize)); } else { Debug.Log("Unable to load controller models; loading alternate."); LoadAlternateControllerModel(source); yield break; } #endif controllerModelGameObject = new GameObject { name = "glTFController" }; controllerModelGameObject.transform.Rotate(0, 180, 0); var sceneImporter = new GLTFSceneImporter( "", new MemoryStream(fileBytes, 0, fileBytes.Length, false, true), controllerModelGameObject.transform ); sceneImporter.SetShaderForMaterialType(GLTFSceneImporter.MaterialType.PbrMetallicRoughness, GLTFMaterial.shader); sceneImporter.SetShaderForMaterialType(GLTFSceneImporter.MaterialType.KHR_materials_pbrSpecularGlossiness, GLTFMaterial.shader); sceneImporter.SetShaderForMaterialType(GLTFSceneImporter.MaterialType.CommonConstant, GLTFMaterial.shader); yield return(sceneImporter.Load()); FinishControllerSetup(controllerModelGameObject, source.handedness, GenerateKey(source)); }