예제 #1
0
    async void LoadBatch(int quantity)
    {
        stopwatch.StartTime();

        Profiler.BeginSample("LoadBatch");
        var routines = new IEnumerator[quantity];

        for (int i = 0; i < quantity; i++)
        {
            Profiler.BeginSample("DecodeMesh");
            DracoMeshLoader dracoLoader = new DracoMeshLoader();
            dracoLoader.onMeshesLoaded += OnMeshesLoaded;
            routines[i] = dracoLoader.DecodeMesh(data);
            Profiler.EndSample();
        }
        Profiler.EndSample();

        while (true)
        {
            var stillWorking = false;
            foreach (var routine in routines)
            {
                stillWorking |= routine.MoveNext();
            }
            if (!stillWorking)
            {
                break;
            }
            await Task.Yield();
        }

        await Task.Yield();

        stopwatch.StopTime();
        Debug.Log($"Loaded {filePath} {quantity} times in {stopwatch.GetTextReport()}");
    }