IEnumerator Start() { yield return(InitScene()); string entityId = "1"; var entity = TestHelpers.CreateSceneEntity(scene, entityId); string shapeId = TestHelpers.CreateAndSetShape(scene, entityId, DCL.Models.CLASS_ID.GLTF_SHAPE, JsonConvert.SerializeObject(new { src = DCL.Helpers.Utils.GetTestsAssetsPath() + "/GLB/Lantern/Lantern.glb" })); LoadWrapper_GLTF gltfShape = GLTFShape.GetLoaderForEntity(entity) as LoadWrapper_GLTF; yield return(new DCL.WaitUntil(() => gltfShape.alreadyLoaded, 7f)); TestHelpers.SetEntityTransform(scene, entity, new Vector3(8, -1, 8), Quaternion.identity, new Vector3(0.5f, 0.5f, 0.5f)); var onClickComponentModel = new OnClick.Model() { type = OnClick.NAME, uuid = "pointerevent-1", button = this.button.ToString() }; var onClickComponent = TestHelpers.EntityComponentCreate <OnClick, OnClick.Model>(scene, entity, onClickComponentModel, CLASS_ID_COMPONENT.UUID_CALLBACK); scene.sceneLifecycleHandler.SetInitMessagesDone(); OnPointerEvent.enableInteractionHoverFeedback = true; }
public IEnumerator UnloadWhenEntityDestroyedBeforeFinishing() { GameObject meshRootGameObject = new GameObject(); string url = TestAssetsUtils.GetPath() + "/GLB/Trunk/Trunk.glb"; IDCLEntity entity = Substitute.For <IDCLEntity>(); entity.meshRootGameObject.Returns(meshRootGameObject); LoadWrapper_GLTF wrapper = Substitute.ForPartsOf <LoadWrapper_GLTF>(); wrapper.entity = entity; wrapper.customContentProvider = new ContentProvider(); bool loaded = false; bool failed = false; bool unloaded = false; wrapper.WhenForAnyArgs(x => x.Unload()).Do((info) => unloaded = true); wrapper.Load(url, loadWrapper => loaded = true, loadWrapper => failed = true); entity.OnCleanupEvent?.Invoke(entity); yield return(new WaitUntil(() => loaded || failed || unloaded)); Object.Destroy(meshRootGameObject); Assert.IsTrue(unloaded, "Unload should be called if entity is cleaned up while loading mesh"); }
public void CustomContentProvider() { string entityId = "1"; TestHelpers.CreateSceneEntity(scene, entityId); string mockupAssetId = "cdd5a4ea94388dd21babdecd26dd560f739dce2fbb8c99cc10a45bb8306b6076"; string mockupKey = "key"; string mockupValue = "Value"; SceneAssetPack sceneAssetPack = new SceneAssetPack(); sceneAssetPack.assets = new System.Collections.Generic.List <SceneObject>(); sceneAssetPack.id = "mockupId"; SceneObject sceneObject = new SceneObject(); sceneObject.id = mockupAssetId; sceneObject.contents = new System.Collections.Generic.Dictionary <string, string>(); sceneObject.contents.Add(mockupKey, mockupValue); sceneAssetPack.assets.Add(sceneObject); AssetCatalogBridge.AddSceneAssetPackToCatalog(sceneAssetPack); TestHelpers.CreateAndSetShape(scene, entityId, DCL.Models.CLASS_ID.GLTF_SHAPE, JsonConvert.SerializeObject( new { assetId = mockupAssetId, src = Utils.GetTestsAssetsPath() + "/GLB/Lantern/Lantern.glb" })); LoadWrapper gltfShape = GLTFShape.GetLoaderForEntity(scene.entities[entityId]); if (!(gltfShape is LoadWrapper_GLTF)) { Assert.Fail(); } LoadWrapper_GLTF gltfWrapper = (LoadWrapper_GLTF)gltfShape; ContentProvider customContentProvider = AssetCatalogBridge.GetContentProviderForAssetIdInSceneObjectCatalog(mockupAssetId); Assert.AreEqual(customContentProvider.baseUrl, gltfWrapper.customContentProvider.baseUrl); Assert.AreEqual(mockupKey, gltfWrapper.customContentProvider.contents[0].file); Assert.AreEqual(mockupValue, gltfWrapper.customContentProvider.contents[0].hash); }
public static IEnumerator WaitForGLTFLoad(DecentralandEntity entity) { LoadWrapper_GLTF wrapper = GLTFShape.GetLoaderForEntity(entity) as LoadWrapper_GLTF; return(new WaitUntil(() => wrapper.alreadyLoaded)); }