Exemplo n.º 1
0
        private void Unload_INTERNAL(ILoadableResource resourceController, ResourceBase resource, bool resetController = true)
        {
            if (resource.loaded == false)
            {
                return;
            }

            //Debug.LogWarning("Unload: " + resource.GetId(), resourceController as MonoBehaviour);
            var item = this.loaded.FirstOrDefault(x => x.id == resource.GetId());

            if (item != null)
            {
                if (item.references.Remove(resourceController as WindowComponent) == true)
                {
                    this.loaded.RemoveAll(x => {
                        if (x.id == resource.GetId() && x.references.Count == 0)
                        {
                            if (x.loadedObjectId < 0)
                            {
                                Object.Destroy(x.loadedObject);
                            }
                            return(true);
                        }

                        return(false);
                    });
                }
            }

            if (resetController == true)
            {
                var image  = resourceController as IImageComponent;
                var source = image.GetImageSource();
                if (source != null)
                {
                    image.ResetImage();
                    resource.Unload(source.sprite);
                }
                else
                {
                    var sourceRaw = image.GetRawImageSource();
                    if (sourceRaw != null)
                    {
                        image.ResetImage();
                        resource.Unload(sourceRaw.texture);
                    }
                }
            }
        }
Exemplo n.º 2
0
            public void Dispose(ResourceBase resource)
            {
                resource.Unload();

                //if (this.loaded == true && this.loadedObjectId < 0 && this.loadedObject != null) Object.Destroy(this.loadedObject);
                this.loadedObject   = null;
                this.onObjectLoaded = null;
                this.references     = null;

                this.id     = 0;
                this.loaded = false;

                                #if UNITY_EDITOR
                this.referencesCount = 0;
                                #endif
            }
Exemplo n.º 3
0
 public static void Unload(ResourceBase resource, Object source)
 {
     resource.Unload(source);
 }
        private void Unload_INTERNAL(ILoadableResource resourceController, ResourceBase resource, bool resetController = true)
        {
            /*
             * if (resource.loaded == false) {
             *
             *
             *      return;
             *
             * }*/

            //Debug.LogWarning("Unload: " + resource.GetId() + " :: " + resource.GetStreamPath(), resourceController as MonoBehaviour);

            var item = this.loaded.FirstOrDefault(x => x.id == resource.GetId());

            if (WindowSystemResources.Remove(item, resourceController as WindowComponent, forced: true) == true)
            {
                //Debug.LogWarning("Unload movie: " + resource.GetId(), resourceController as MonoBehaviour);

                MovieSystem.Unload(resourceController as IImageComponent, resource);
            }

            /*if (item != null) {
             *
             *      if (item.references.Remove(resourceController as WindowComponent) == true) {
             *
             *              this.loaded.RemoveAll(x => {
             *
             *                      if (x.id == resource.GetId() && x.references.Count == 0) {
             *
             *                              if (x.loadedObjectId < 0) Object.Destroy(x.loadedObject);
             *                              return true;
             *
             *                      }
             *
             *                      return false;
             *
             *              });
             *
             *      }
             *
             * }*/

            if (resetController == true)
            {
                var image  = resourceController as IImageComponent;
                var source = image.GetImageSource();
                if (source != null)
                {
                    image.ResetImage();
                    resource.Unload(source.sprite);
                }
                else
                {
                    var sourceRaw = image.GetRawImageSource();
                    if (sourceRaw != null)
                    {
                        image.ResetImage();
                        resource.Unload(sourceRaw.texture);
                    }
                }
            }
        }