Example #1
0
 protected virtual void OnLoaded(GameObject model, VRMMetaObject meta = null)
 {
     Debug.Log(model + "has been loaded");
     OnModelLoaded?.Invoke(model);
     if (meta != null)
     {
         OnMetaDataLoaded?.Invoke(meta);
     }
 }
        private IModel InternalLoad(string modelName, bool throwOnFailure)
        {
            if (_models.TryGetValue(modelName, out var model))
            {
                return(model);
            }

            model = LoadModel(modelName);

            if (model != null)
            {
                _models.Add(modelName, model);

                OnModelLoaded?.Invoke(model);
            }
            else
            {
                if (FallbackModel == null)
                {
                    if (throwOnFailure)
                    {
                        throw new InvalidOperationException($"Couldn't load model {modelName}; no fallback model loaded");
                    }

                    //Used by fallback model loading
                    return(null);
                }

                model = FallbackModel;

                //Insert it anyway to avoid constant load attempts
                _models.Add(modelName, model);
            }

            return(model);
        }
Example #3
0
#pragma warning disable CS1998 // Async method lacks 'await' operators and will run synchronously
        public async Task __ModelLoaded__()
        {
            OnModelLoaded?.Invoke();
        }
Example #4
0
 public void __ModelLoaded__()
 {
     OnModelLoaded?.Invoke();
 }
        private void AddModel(string modelName, IModel model)
        {
            _models.Add(modelName, model);

            OnModelLoaded?.Invoke(model);
        }