public override async Task <bool> Load(string url, IDownloadProvider downloadProvider = null, IDeferAgent deferAgent = null, IMaterialGenerator materialGenerator = null) { var success = await base.Load(url, downloadProvider, deferAgent, materialGenerator); if (success) { var insta = new GameObjectBoundsInstantiator(transform); // Auto-Instantiate gLTFastInstance.InstantiateGltf(insta); var sceneBounds = insta.CalculateBounds(); if (sceneBounds.HasValue) { bounds = sceneBounds.Value; if (createBoxCollider) { #if UNITY_PHYSICS var boxCollider = gameObject.AddComponent <BoxCollider>(); boxCollider.center = bounds.center; boxCollider.size = bounds.size; #else Debug.LogError("GltfBoundsAsset requires the built-in Physics package to be enabled (in the Package Manager)"); #endif } } } return(success); }
void SetBounds(GameObjectBoundsInstantiator insta) { var sceneBounds = insta.sceneInstance != null?insta.CalculateBounds() : null; if (sceneBounds.HasValue) { bounds = sceneBounds.Value; if (createBoxCollider) { #if UNITY_PHYSICS var boxCollider = gameObject.AddComponent <BoxCollider>(); boxCollider.center = bounds.center; boxCollider.size = bounds.size; #else Debug.LogError("GltfBoundsAsset requires the built-in Physics package to be enabled (in the Package Manager)"); #endif } } }