示例#1
0
    protected override async void MassLoadRoutine(SampleSet sampleSet)
    {
        stopWatch.StartTime();

        GLTFast.IDeferAgent deferAgent;
        if (strategy == Strategy.Fast)
        {
            deferAgent = new GLTFast.UninterruptedDeferAgent();
        }
        else
        {
            deferAgent = gameObject.AddComponent <GLTFast.TimeBudgetPerFrameDeferAgent>();
        }

        var loadTasks = new List <Task>(sampleSet.itemCount);

        if (local)
        {
            foreach (var item in sampleSet.GetItemsPrefixed())
            {
                var loadTask = LoadIt(
#if LOCAL_LOADING
                    string.Format("file://{0}", item.path)
#else
                    item.path
#endif
                    , deferAgent
                    );
                loadTasks.Add(loadTask);
                await deferAgent.BreakPoint();
            }
        }
        else
        {
            foreach (var item in sampleSet.GetItemsPrefixed(false))
            {
                var loadTask = LoadIt(item.path, deferAgent);
                loadTasks.Add(loadTask);
                await deferAgent.BreakPoint();
            }
        }

        await Task.WhenAll(loadTasks);

        stopWatch.StopTime();
        Debug.LogFormat("Finished loading {1} glTFs in {0} milliseconds!", stopWatch.lastDuration, sampleSet.itemCount);

        var selectSet = GetComponent <SampleSetSelectGui>();

        selectSet.enabled = true;
    }
示例#2
0
 void OnDisable()
 {
     GltfImport.UnsetDefaultDeferAgent(m_DeferAgent);
     m_DeferAgent = null;
 }
示例#3
0
 void OnEnable()
 {
     m_DeferAgent = new UninterruptedDeferAgent();
     GltfImport.SetDefaultDeferAgent(m_DeferAgent);
 }