/// <summary> /// Set gif asset for the player /// </summary> /// <param name="asset">gif asset</param> public void SetGif(Asset_Gif asset) { gifAsset = asset; if (isPlaying && IsValidAsset()) { if (currentFrameIdx >= asset.frames.Length) { currentFrameIdx = 0; } SetFrame(currentFrameIdx); } }
private static IEnumerator Create(string contentType, string url, Asset_Gif.MaxSize maxTextureSize, Action <ITexture, AssetPromise_Texture> OnSuccess, Action OnFail = null) { if (contentType != "image/gif") { AssetPromise_Texture texturePromise = new AssetPromise_Texture(url, storeTexAsNonReadable: false); texturePromise.OnSuccessEvent += texture => { OnSuccess?.Invoke(texture, texturePromise); }; texturePromise.OnFailEvent += (x) => OnFail?.Invoke(); AssetPromiseKeeper_Texture.i.Keep(texturePromise); yield return(texturePromise); yield break; } var gif = new Asset_Gif(url, maxTextureSize, OnSuccess); yield return(gif.Load()); }
public GifPlayer(Asset_Gif asset) { SetGif(asset); }