Ejemplo n.º 1
0
 private void LoadCustom_INTERNAL <T>(ResourceBase resource, System.Action <T> callback) where T : MonoBehaviour
 {
     if (resource is MonoResource)
     {
         this.StartCoroutine(resource.Load <T>(null, null, null, callback));
     }
 }
        private void LoadRefCounter_INTERNAL <T>(IResourceReference reference, ResourceBase resource, System.Action <T> callbackOnLoad, System.Action callbackOnFailed, bool async, string customResourcePath)       /*where T : Object*/
        {
            if (resource.IsLoadable() == true)
            {
                //Debug.Log("Check: " + resource.assetPath + ", typeof: " + typeof(T).ToString());
                Item item;
                if (this.IsLoaded <T>(reference, resource, out item, callbackOnLoad, callbackOnFailed) == false)
                {
                    //Debug.Log("Loading: " + resource.assetPath);
                    Coroutines.Run(resource.Load <T>(reference, customResourcePath, (data) => {
                        //Debug.Log("Loaded: " + resource.assetPath + " >> " + data);
                        if (data == null)
                        {
                            //Debug.LogWarning(string.Format("Failed to load resource in {0}", resource.assetPath));

                            item.loadingResult = false;
                            if (item.onObjectFailed != null)
                            {
                                item.onObjectFailed.Invoke(item);
                            }

                            item.onObjectLoaded = null;
                            item.onObjectFailed = null;
                            //if (callbackOnFailed != null) callbackOnFailed.Invoke();
                            //WindowSystemLogger.Error(image, string.Format("Error in ResourcesManager: Required resource can't loaded. Resource: {0}", image.GetResource().GetId()));
                            return;
                        }

                        item.loadingResult = true;
                        item.loadedObject  = data;
                        item.loaded        = true;

                        if (item.onObjectLoaded != null)
                        {
                            item.onObjectLoaded.Invoke(item);
                        }
                        item.onObjectLoaded = null;
                        item.onObjectFailed = null;

                        //callbackOnLoad(data);
                    }, async));
                }
            }
            else
            {
                if (callbackOnFailed != null)
                {
                    callbackOnFailed.Invoke();
                }
            }
        }