コード例 #1
0
    public IEnumerator GetMissingChar3RelayoutAsync()
    {
        var box = AsyncBoxElement.GO(
            null,// bg画像
            () =>
        {
            Debug.Log("ルートがタップされた");
        },
            AsyncTextElement.GO("aaaaaaaaaaaaabbbbbbbbb💚🎮✨✨cccccccccccccccccccccccccccccccddddddddddddddddddddd")
            );

        // レイアウトに使うクラスを生成する
        var layouter = new BasicAsyncLayouter();

        // コンテンツのサイズをセットする
        var size = new Vector2(600, 100);

        var missingDetected = false;
        var cache           = InternalCachePool.Get <BasicMissingSpriteCache>();

        cache.Debug_OnMissingCharacter(
            () =>
        {
            missingDetected = true;
        }
            );

        // レイアウトを行う

        yield return(LayouTaro.LayoutAsync <BasicMissingSpriteCache>(
                         canvas.transform,
                         size,
                         box,
                         layouter
                         ));

        var rectTrans = box.gameObject.GetComponent <RectTransform>();

        rectTrans.anchoredPosition3D = Vector3.zero;
        rectTrans.localScale         = Vector3.one;

        Assert.True(missingDetected);

        yield return(LayouTaro.RelayoutWithUpdateAsync <BasicMissingSpriteCache>(
                         size,
                         box,
                         new Dictionary <LTElementType, object>()
        {
            { LTElementType.AsyncText, "aaaaaaaaaaaaabbbbbbbbb💚🎮✨✨cccccccccccccccccccccccccccccccddddddddddddddddddddd" }
        },
                         layouter
                         ));

        yield return(null);

        ScreenCapture.CaptureScreenshot("./images/" + methodName);
        yield break;
    }
コード例 #2
0
ファイル: FrameTests.cs プロジェクト: Josephtamhk/LayouTaro
    public IEnumerator DetectMissingEmojiContinuesFrames()
    {
        // generate your own data structure with parameters for UI.
        var box = AsyncBoxElement.GO(
            null,// UI bg with image
            () =>
        {
            Debug.Log("root box element is tapped.");
        },
            AsyncTextElement.GO("\U0001F60A\U0001F60A\U0001F60A\U0001F60A\U0001F60A\U0001F60A\U0001F60A\U0001F60A\U0001F60A\U0001F60A\U0001F60A\U0001F60A\U0001F60A\U0001F60A\U0001F60A\U0001F60A\U0001F60A\U0001F60A\U0001F60A\U0001F60A\U0001F60A\U0001F60A\U0001F60A"), // mark is missing by default.
            AsyncImageElement.GO(null),                                                                                                                                                                                                                                    // image.
            AsyncButtonElement.GO(null, () => { Debug.Log("button is tapped."); })
            );

        // generate the layouter which you want to use for layout.
        var layouter = new BasicAsyncLayouter();

        // set the default size of content.
        var size = new Vector2(600, 100);


        var runner = new GameObject().AddComponent <DebugRunner>();

        var cached       = false;
        var currentCache = InternalCachePool.Get <BasicMissingSpriteCache>();

        // https://dummyimage.com/21.76744x41.39648/129393
        currentCache.LoadMissingEmojiOrMark(
            "",
            0f,
            21.76744f,
            41.39648f,
            129393,
            iEnum =>
        {
            runner.StartCoroutine(iEnum);
        },
            tex =>
        {
            cached = true;
        },
            () =>
        {
            Debug.LogError("取得失敗!");
        }
            );

        while (!cached)
        {
            yield return(null);
        }

        var before = Time.frameCount;

        yield return(LayouTaro.LayoutAsync <BasicMissingSpriteCache>(
                         canvas.transform,
                         size,
                         box,
                         layouter
                         ));

        var rectTrans = box.gameObject.GetComponent <RectTransform>();

        rectTrans.anchoredPosition3D = Vector3.zero;
        rectTrans.localScale         = Vector3.one;

        var after = Time.frameCount;

        Assert.True(before + 1 == after, "not match. before:" + before + " after:" + after);


        yield return(null);

        ScreenCapture.CaptureScreenshot("./images/" + methodName);
        while (false)
        {
            yield return(null);
        }

        yield break;
    }