예제 #1
0
    public IEnumerator OBJShapeUpdate()
    {
        string entityId = "1";

        TestHelpers.CreateSceneEntity(scene, entityId);

        Material placeholderLoadingMaterial = Resources.Load <Material>("Materials/AssetLoading");

        yield return(null);

        Assert.IsTrue(scene.entities[entityId].meshRootGameObject == null,
                      "Since the shape hasn't been updated yet, the child mesh shouldn't exist");

        TestHelpers.CreateAndSetShape(scene, entityId, DCL.Models.CLASS_ID.OBJ_SHAPE, JsonConvert.SerializeObject(
                                          new
        {
            src = Utils.GetTestsAssetsPath() + "/OBJ/teapot.obj"
        }));

        LoadWrapper objShape = LoadableShape.GetLoaderForEntity(scene.entities[entityId]);

        yield return(new WaitUntil(() => objShape.alreadyLoaded));

        Assert.IsTrue(scene.entities[entityId].meshRootGameObject != null,
                      "Every entity with a shape should have the mandatory 'Mesh' object as a child");

        var childRenderer = scene.entities[entityId].meshRootGameObject.GetComponentInChildren <MeshRenderer>();

        Assert.IsTrue(childRenderer != null,
                      "Since the shape has already been updated, the child renderer should exist");
        Assert.AreNotSame(placeholderLoadingMaterial, childRenderer.sharedMaterial,
                          "Since the shape has already been updated, the child renderer found shouldn't have the 'AssetLoading' placeholder material");
    }
    public IEnumerator ShapeUpdate()
    {
        string entityId = "1";

        TestHelpers.CreateSceneEntity(scene, entityId);

        var entity = scene.entities[entityId];

        Assert.IsTrue(entity.meshRootGameObject == null, "entity mesh object should be null as the NFTShape hasn't been initialized yet");

        var componentModel = new NFTShape.Model()
        {
            src = "ethereum://0x06012c8cf97BEaD5deAe237070F9587f8E7A266d/558536"
        };

        NFTShape component = TestHelpers.SharedComponentCreate <NFTShape, NFTShape.Model>(scene, CLASS_ID.NFT_SHAPE, componentModel);

        yield return(component.routine);

        TestHelpers.SharedComponentAttach(component, entity);

        Assert.IsTrue(entity.meshRootGameObject != null, "entity mesh object should already exist as the NFTShape already initialized");

        var nftShape = LoadableShape.GetLoaderForEntity(entity) as LoadWrapper_NFT;

        var backgroundMaterial = nftShape.loaderController.backgroundMaterial;

        Assert.IsTrue(backgroundMaterial.GetColor("_BaseColor") == new Color(0.6404918f, 0.611472f, 0.8584906f), "The NFT frame background color should be the default one");

        // Update color and check if it changed
        componentModel.color = Color.yellow;
        yield return(TestHelpers.SharedComponentUpdate(component, componentModel));

        Assert.AreEqual(Color.yellow, backgroundMaterial.GetColor("_BaseColor"), "The NFT frame background color should be yellow");
    }
예제 #3
0
    IEnumerator InstantiateNFTShape(Vector3 position, int styleIndex)
    {
        var entity = TestHelpers.CreateSceneEntity(scene);

        TestHelpers.SetEntityTransform(scene, entity, new DCLTransform.Model {
            position = position
        });

        yield return(null);

        var componentModel = new NFTShape.Model()
        {
            src   = "ethereum://0x06012c8cf97BEaD5deAe237070F9587f8E7A266d/558536",
            color = Color.gray,
            style = styleIndex
        };

        NFTShape component = TestHelpers.SharedComponentCreate <NFTShape, NFTShape.Model>(scene, CLASS_ID.NFT_SHAPE, componentModel);

        yield return(component.routine);

        TestHelpers.SharedComponentAttach(component, entity);

        // Override texture with a local test one
        var nftShape = LoadableShape.GetLoaderForEntity(entity) as LoadWrapper_NFT;

        nftShape.loaderController.UpdateTexture(Resources.Load <Texture2D>("TestTexture"));
        nftShape.loaderController.transform.localScale = new Vector3(1.5f, 1.5f, 1f);
    }
예제 #4
0
        public void GetWaitingComponentsDebugInfo()
        {
            switch (state)
            {
            case State.WAITING_FOR_COMPONENTS:

                foreach (string componentId in disposableNotReady)
                {
                    if (disposableComponents.ContainsKey(componentId))
                    {
                        var component = disposableComponents[componentId];

                        Debug.Log($"Waiting for: {component.ToString()}");

                        foreach (var entity in component.attachedEntities)
                        {
                            var loader = LoadableShape.GetLoaderForEntity(entity);

                            string loadInfo = "No loader";

                            if (loader != null)
                            {
                                loadInfo = loader.ToString();
                            }

                            Debug.Log($"This shape is attached to {entity.entityId} entity. Click here for highlight it.\nLoading info: {loadInfo}", entity.gameObject);
                        }
                    }
                    else
                    {
                        Debug.Log($"Waiting for missing component? id: {componentId}");
                    }
                }

                break;

            default:
                Debug.Log("This scene is not waiting for any components. Its current state is " + state);
                break;
            }
        }
예제 #5
0
        public void EvaluateEntityPosition(DecentralandEntity entity)
        {
            if (entity == null || entity.scene == null)
            {
                return;
            }

            // Recursively evaluate entity children as well, we need to check this up front because this entity may not have meshes of its own, but the children may.
            if (entity.children.Count > 0)
            {
                using (var iterator = entity.children.GetEnumerator())
                {
                    while (iterator.MoveNext())
                    {
                        EvaluateEntityPosition(iterator.Current.Value);
                    }
                }
            }

            if (entity.meshRootGameObject == null || entity.meshesInfo.renderers == null || entity.meshesInfo.renderers.Length == 0)
            {
                return;
            }

            // If the mesh is being loaded we should skip the evaluation (it will be triggered again later when the loading finishes)
            if (entity.meshRootGameObject.GetComponent <MaterialTransitionController>()) // the object's MaterialTransitionController is destroyed when it finishes loading
            {
                return;
            }
            else
            {
                var loadWrapper = LoadableShape.GetLoaderForEntity(entity);

                if (loadWrapper != null && !loadWrapper.alreadyLoaded)
                {
                    return;
                }
            }

            EvaluateMeshBounds(entity);
        }