/// <summary>
 /// Record a new progress step.
 /// </summary>
 public void UpdateProgress(GltfImportStep importStep,
                            int numCompleted, int numTotal)
 {
     _progressSteps.Add(new ProgressStep
     {
         Step                = importStep,
         NumCompleted        = numCompleted,
         NumTotal            = numTotal,
         ElapsedMilliseconds = Stopwatch.ElapsedMilliseconds
     }
                        );
 }
        /// <summary>
        /// This method is invoked after each step/substep of the glTF import has
        /// completed, in order to update the progress log accordingly.
        /// </summary>
        public void OnImportProgress(GltfImportStep importStep, int numCompleted, int total)
        {
            UpdateProgress(importStep, numCompleted, total);
            string message = GetProgressMessage();

            // Update existing tail log line if we are still importing
            // the same type of glTF entity (e.g. textures), or
            // add a new line if we have started to import
            // a new type.

            if (IsNewImportStep())
            {
                AddLineCallback?.Invoke(message);
            }
            else
            {
                UpdateLineCallback?.Invoke(message);
            }
        }
        /// <summary>
        /// Return the total time in milliseconds for the
        /// current import step (e.g. textures, meshes).
        /// </summary>
        public long GetMillisecondsForCurrentImportStep()
        {
            ProgressStep   progressStep = _progressSteps[_progressSteps.Count - 1];
            GltfImportStep importStep   = progressStep.Step;

            long endTime   = progressStep.ElapsedMilliseconds;
            long startTime = 0;

            for (int i = _progressSteps.Count - 1; i >= 0; --i)
            {
                if (_progressSteps[i].Step != importStep)
                {
                    break;
                }

                startTime = _progressSteps[i].ElapsedMilliseconds;
            }

            return(endTime - startTime);
        }
 /// <summary>
 /// Callback that is invoked by the glTF import task
 /// to report intermediate progress.
 /// </summary>
 /// <param name="step">
 /// The current step of the glTF import process.  Each step imports
 /// a different type of glTF entity (e.g. textures, materials).
 /// </param>
 /// <param name="completed">
 /// The number of glTF entities (e.g. textures, materials) that have been
 /// successfully imported for the current import step.
 /// </param>
 /// <param name="total">
 /// The total number of glTF entities (e.g. textures, materials) that will
 /// be imported for the current import step.
 /// </param>
 private void OnProgress(GltfImportStep step, int completed, int total)
 {
     Debug.LogFormat("{0}: {1}/{2}", step, completed, total);
 }