示例#1
0
        public IEnumerator VisibleFalseIsProcessedCorrectly()
        {
            IDCLEntity entity             = TestHelpers.CreateSceneEntity(scene);
            TextShape  textShapeComponent = TestHelpers.EntityComponentCreate <TextShape, TextShape.Model>(scene, entity, new TextShape.Model {
                value = "Hello test", opacity = 0.3f, visible = false
            });

            yield return(textShapeComponent.routine);

            TextMeshPro tmpro = textShapeComponent.gameObject.GetComponentInChildren <TextMeshPro>();

            Assert.NotNull(tmpro);
            Assert.AreEqual(0.3f, textShapeComponent.GetModel().opacity);
            Assert.IsFalse(textShapeComponent.GetModel().visible);
            Assert.AreEqual(tmpro.color.a, 0f);
        }
示例#2
0
        public IEnumerator TestMissingValuesGetDefaultedOnUpdate()
        {
            string entityId = "1";

            TestHelpers.CreateSceneEntity(scene, entityId);

            // 1. Create component with non-default configs
            TextShape.Model textShapeModel = new TextShape.Model
            {
                color        = Color.green,
                width        = 0.25f,
                lineCount    = 3,
                fontAutoSize = true,
                shadowColor  = Color.red
            };

            TextShape textShapeComponent =
                TestHelpers.EntityComponentCreate <TextShape, TextShape.Model>(scene, scene.entities[entityId],
                                                                               textShapeModel);

            yield return(textShapeComponent.routine);

            // 2. Check configured values
            Assert.AreEqual(Color.green, textShapeComponent.GetModel().color);
            Assert.AreEqual(0.25f, textShapeComponent.GetModel().width);
            Assert.AreEqual(3, textShapeComponent.GetModel().lineCount);
            Assert.IsTrue(textShapeComponent.GetModel().fontAutoSize);
            Assert.AreEqual(Color.red, textShapeComponent.GetModel().shadowColor);

            // 3. Update component with missing values
            scene.EntityComponentUpdate(scene.entities[entityId], CLASS_ID_COMPONENT.TEXT_SHAPE,
                                        JsonUtility.ToJson(new TextShape.Model {
            }));

            yield return(textShapeComponent.routine);

            // 4. Check defaulted values
            Assert.AreEqual(Color.white, textShapeComponent.GetModel().color);
            Assert.AreEqual(1f, textShapeComponent.GetModel().width);
            Assert.AreEqual(0, textShapeComponent.GetModel().lineCount);
            Assert.IsFalse(textShapeComponent.GetModel().fontAutoSize);
            Assert.AreEqual(new Color(1, 1, 1), textShapeComponent.GetModel().shadowColor);
        }
示例#3
0
        public IEnumerator OpacityIsProcessedCorrectly(float opacity)
        {
            DecentralandEntity entity             = TestHelpers.CreateSceneEntity(scene);
            TextShape          textShapeComponent = TestHelpers.EntityComponentCreate <TextShape, TextShape.Model>(scene, entity, new TextShape.Model {
                value = "Hello test", opacity = opacity
            });

            yield return(textShapeComponent.routine);

            TextMeshPro tmpro = textShapeComponent.gameObject.GetComponentInChildren <TextMeshPro>();

            Assert.NotNull(tmpro);
            Assert.AreEqual(opacity, textShapeComponent.GetModel().opacity);
            Assert.AreEqual(tmpro.color.a, opacity);
        }