public static void UnloadResource_INTERNAL(IResourceReference resourceController, ResourceBase resource) { var item = WindowSystemResources.instance.loaded.FirstOrDefault(x => x.id == resource.GetId()); if (WindowSystemResources.Remove(item, resourceController, resource) == true) { MovieSystem.Unload(resourceController as IImageComponent, resource); } }
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); } } } }