public IImageComponent SetMovieTexture(AutoResourceItem resource, System.Action onDataLoaded, System.Action onComplete = null) { this.Stop(); this.SetImage(resource, onDataLoaded, onComplete); return this; }
public IImageComponent SetImage(AutoResourceItem resource, System.Action onDataLoaded = null, System.Action onComplete = null) { var oldResource = this.imageResource; var newResource = resource; this.imageResource = resource; //Debug.Log("Loading resource: " + newResource.GetId()); WindowSystemResources.Load(this, onDataLoaded: onDataLoaded, onComplete: () => { //Debug.Log("Resource loaded: " + newResource.GetId()); if (newResource.GetId() != oldResource.GetId()) { //Debug.Log("Unloading: " + newResource.GetId() + " != " + oldResource.GetId()); WindowSystemResources.Unload(this, oldResource, resetController: false); } if (onComplete != null) onComplete.Invoke(); }); return this; }