Пример #1
0
    //[MenuItem("Tools/Test Load All Stage Pictures")]
    public static async void TestLoadStagePictureAsync()
    {
        if (!Application.isPlaying)
        {
            Debug.LogError("Async only work in play mode");
            return;
        }
        testRunning = true;
        Debug.Log("Test started");
        var time       = DateTime.Now;
        int errorCount = 0;
        var service    = GameDatabase.GetDataServiceInEditMode();
        List <StageData> stageDatas = service.GetAllStageData().ToList();

        Debug.Log($"Testing {stageDatas.Count} stages");
        for (int i = 0; i < stageDatas.Count; i++)
        {
            if (stopTest)
            {
                stopTest = false;
                break;
            }
            Debug.Log($"Testing stage {stageDatas[i].id}");
            PictureData pictureData = service.GetPictureData(stageDatas[i].picture_name);
            if (pictureData == null)
            {
                Debug.LogError($"Picture data not found {stageDatas[i].id}");
                continue;
            }
            var picture = await AddressableImage.GetSpriteFromAtlasAsync(pictureData.name);

            if (picture == null)
            {
                Debug.LogError($"{pictureData.name} load failed");
                errorCount++;
            }
            var pictureSolution = await AddressableImage.GetSpriteFromAtlasAsync(StagePictureControl.GetPictureSolutionName(pictureData.name));

            if (pictureSolution == null)
            {
                Debug.LogError($"{StagePictureControl.GetPictureSolutionName(pictureData.name)} solution load failed");
                errorCount++;
            }

            //test load Gesture
            GestureLibrary gl = new GestureLibrary(pictureData.name, true, pictureData.use_v4);
        }
        TimeSpan timePassed = DateTime.Now - time;

        Debug.Log($"Test completed in {timePassed}, error count: {errorCount}");
        testRunning = false;
    }
Пример #2
0
    static IEnumerator CoTestLoadStagePicture()
    {
        testRunning = true;
        Debug.Log("Test started");
        var time = DateTime.Now;

        errorCount = 0;
        var service = GameDatabase.GetDataServiceInEditMode();
        List <StageData> stageDatas = service.GetAllStageData().ToList();

        Debug.Log($"Testing {stageDatas.Count} stages");
        for (int i = 0; i < stageDatas.Count; i++)
        {
            if (stopTest)
            {
                stopTest = false;
                break;
            }
            Debug.Log($"Testing stage {stageDatas[i].id}");
            PictureData pictureData = service.GetPictureData(stageDatas[i].picture_name);
            if (pictureData == null)
            {
                Debug.LogError($"Picture data not found {stageDatas[i].id}");
                continue;
            }

            yield return(tempMono.StartCoroutine(CoTestLoadPicture(pictureData.name)));

            yield return(tempMono.StartCoroutine(CoTestLoadPicture(StagePictureControl.GetPictureSolutionName(pictureData.name))));

            //test load Gesture
            GestureLibrary gl = new GestureLibrary(pictureData.name, true, pictureData.use_v4);
            if (errorCount > 0)
            {
                Debug.Log("Test aborted");
                break;
            }
        }
        TimeSpan timePassed = DateTime.Now - time;

        Debug.Log($"Test completed in {timePassed}, error count: {errorCount}");
        testRunning = false;
    }