コード例 #1
0
        public IEnumerator BuiltInFontHandleErrorProperly()
        {
            DecentralandEntity entity = TestHelpers.CreateSceneEntity(scene);

            TextShape textShape =
                TestHelpers.EntityComponentCreate <TextShape, TextShape.Model>(scene, entity, new TextShape.Model());

            yield return(textShape.routine);

            TMP_FontAsset defaultFont = textShape.GetComponentInChildren <TextMeshPro>().font;

            DCLFont font =
                TestHelpers.SharedComponentCreate <DCLFont, DCLFont.Model>(scene, CLASS_ID.FONT, new DCLFont.Model()
            {
                src = "no-valid-font"
            });

            yield return(font.routine);

            scene.EntityComponentUpdate(entity, CLASS_ID_COMPONENT.TEXT_SHAPE,
                                        JsonUtility.ToJson(new TextShape.Model {
                font = font.id
            }));
            yield return(textShape.routine);

            Assert.IsTrue(font.error, "Built-in font error has not araise properly");
            Assert.IsTrue(textShape.GetComponentInChildren <TextMeshPro>().font == defaultFont, "Built-in font didn't apply correctly");
        }
コード例 #2
0
ファイル: TextShapeTests.cs プロジェクト: menduz/explorer
        public IEnumerator TestCreate()
        {
            string entityId = "e1";

            TestHelpers.CreateSceneEntity(scene, entityId);

            yield return(null);

            var textShapeModel = new TextShape.Model()
            {
                value = "Hello world!",

                color      = Color.white,
                opacity    = 0.5f,
                fontSize   = 10,
                fontWeight = "",

                width         = 20,
                height        = 20,
                adaptHeight   = false,
                adaptWidth    = false,
                paddingTop    = 10,
                paddingRight  = 0,
                paddingBottom = 10,
                paddingLeft   = 0,

                shadowBlur    = 0,
                shadowOffsetX = 0,
                shadowOffsetY = 0,
                shadowColor   = Color.white
            };

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

            yield return(textShape.routine);

            TextMeshPro tmpro = textShape.GetComponentInChildren <TextMeshPro>();

            Assert.IsTrue(textShape != null, "Component creation fail!");
            Assert.IsTrue(tmpro != null, "TextMeshPro doesn't exists for TextShape!");
            Assert.IsTrue(textShape.text != null, "Unity Text component doesn't exists for TextShape!");

            yield return(null);

            TMProConsistencyAsserts(tmpro, textShapeModel);

            textShapeModel.paddingLeft  = 5;
            textShapeModel.paddingRight = 15;
            textShapeModel.value        = "Hello world again!";

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

            TMProConsistencyAsserts(tmpro, textShapeModel);

            yield return(null);
        }
コード例 #3
0
        public IEnumerator BuiltInFontAttachCorrectlyOnTextComponentUpdate()
        {
            DecentralandEntity entity = TestHelpers.CreateSceneEntity(scene);

            TextShape textShape =
                TestHelpers.EntityComponentCreate <TextShape, TextShape.Model>(scene, entity, new TextShape.Model());

            yield return(textShape.routine);

            DCLFont font =
                TestHelpers.SharedComponentCreate <DCLFont, DCLFont.Model>(scene, CLASS_ID.FONT, new DCLFont.Model()
            {
                src = TEST_BUILTIN_FONT_NAME
            });

            yield return(font.routine);

            scene.EntityComponentUpdate(entity, CLASS_ID_COMPONENT.TEXT_SHAPE,
                                        JsonUtility.ToJson(new TextShape.Model {
                font = font.id
            }));
            yield return(textShape.routine);

            Assert.IsTrue(font.loaded, "Built-in font didn't load");
            Assert.IsFalse(font.error, "Built-in font has error");

            TextMeshPro tmpro = textShape.GetComponentInChildren <TextMeshPro>();

            Assert.IsTrue(font.fontAsset == tmpro.font, "Built-in font didn't apply correctly");
        }
コード例 #4
0
        public IEnumerator BuiltInFontCreateAndLoadTest()
        {
            DCLFont font =
                TestHelpers.SharedComponentCreate <DCLFont, DCLFont.Model>(scene, CLASS_ID.FONT, new DCLFont.Model()
            {
                src = TEST_BUILTIN_FONT_NAME
            });

            yield return(font.routine);

            var entity = TestHelpers.CreateSceneEntity(scene);

            TextShape textShape =
                TestHelpers.EntityComponentCreate <TextShape, TextShape.Model>(scene, entity, new TextShape.Model()
            {
                font = font.id
            });

            yield return(textShape.routine);

            Assert.IsTrue(font.loaded, "Built-in font didn't load");
            Assert.IsFalse(font.error, "Built-in font has error");

            TextMeshPro tmpro = textShape.GetComponentInChildren <TextMeshPro>();

            Assert.IsTrue(font.fontAsset == tmpro.font, "Built-in font didn't apply correctly");
        }