private void Awake() { Debug.Assert(mrtkStandardMaterial); objectManipulator = gameObject.GetComponent <ObjectManipulator>(); boundsControl = gameObject.GetComponent <BoundsControl>(); gltfAsset = gameObject.GetComponent <GltfAsset>(); gltfAsset.onLoadComplete += OnLoadComplete; }
public void LoadUrl(string url) { #if !NO_GLTFAST if (gltf1 != null) { gltf1.onLoadComplete -= GLTFast_onLoadComplete; gltf1 = null; } #endif #if UNITY_GLTF if (gltf2 != null) { gltf2.onLoadComplete -= UnityGltf_OnLoadComplete; gltf2 = null; } #endif if (go1 != null) { Destroy(go1); } if (go2 != null) { Destroy(go2); } Debug.Log("loading " + url); startTime = Time.realtimeSinceStartup; #if !NO_GLTFAST time1Update(-1); #endif #if UNITY_GLTF time2Update(-1); #endif go1 = new GameObject(); go2 = new GameObject(); #if !NO_GLTFAST gltf1 = url.EndsWith(".gltf", System.StringComparison.OrdinalIgnoreCase) ? go1.AddComponent <GLTFast.GltfAsset>() : go1.AddComponent <GLTFast.GlbAsset>(); gltf1.url = url; gltf1.onLoadComplete += GLTFast_onLoadComplete; #endif #if UNITY_GLTF go2.transform.rotation = Quaternion.Euler(0, 180, 0); gltf2 = go2.AddComponent <UnityGLTFLoader>(); gltf2.GLTFUri = url; gltf2.onLoadComplete += UnityGltf_OnLoadComplete; #endif urlChanged(url); }
public async void Init(LayoutRouting layoutRouting, string url, System.Action <bool> callback = null) { this.layoutRouting = layoutRouting; _transform = transform; onLoadCallback = callback; if (gltfAsset == null) { gltfAsset = gameObject.AddComponent <GLTFast.GltfAsset>(); } gltfAsset.loadOnStartup = false; gltfAsset.url = url; var deferAgent = gameObject.AddComponent <WebGLDeferAgent>(); var loadResult = await gltfAsset.Load(gltfAsset.url, null, deferAgent); OnGltfLoaded(loadResult); }
void Awake() { gltfAsset = gameObject.AddComponent <GltfAsset>(); }