// Update is called once per frame void Update() { if (webCamTexture.width > 100) { if (init == false) { Init(); init = true; } try { smallTex = TextureScaler.scaled(webCamTexture, width, height); for (int i = 0; i < texArray.depth - 1; i++) { texArray.SetPixels32(texArray.GetPixels32(i + 1), i); } texArray.SetPixels32(smallTex.GetPixels32(), texArray.depth - 1); texArray.Apply(); Destroy(smallTex); } catch (System.Exception e) { } } }
private IEnumerator refreshTargetIcon(float DelayTime) { // check wether download needed if (ImageDownload == null) { ImageDownload = _api.LoadTargetImage(); } yield return(new WaitForSeconds(DelayTime)); if (DelayTime > 0) { this.refreshTargetIcon(); } // check wether download finished if (ImageDownload != null && !TargetImageApplied) { if (ProfileImageTexture != null) // already loaded, apply now { TargetIcon.sprite.texture.LoadImage(ProfileImageTexture.EncodeToJPG(), false); } else if (ImageDownload.texture != null) // scale now and apply { ProfileImageTexture = TextureScaler.scaled(ImageDownload.texture, 1024, 1024, FilterMode.Trilinear); TargetIcon.sprite.texture.LoadImage(ProfileImageTexture.EncodeToPNG(), false); this.TargetImageApplied = true; } } }
// public float highOffset; // public float lowOffset; public static List <Texture2D> Open() { //string path = EditorUtility.OpenFilePanel("Open a image", "", "png;*jpg;*jpeg;*"); List <Texture2D> textures = new List <Texture2D>(); ExtensionFilter[] extensions = new [] { new ExtensionFilter("Image Files", "png", "jpg", "jpeg"), }; string[] paths = StandaloneFileBrowser.OpenFilePanel("Open a image", "", extensions, true); foreach (string path in paths) { Texture2D texture; var fileContent = File.ReadAllBytes(path); texture = new Texture2D(0, 0); texture.LoadImage(fileContent); texture = Clean(texture); TextureScaler.scale(texture, 100, 100, 0); texture.Apply(); textures.Add(texture); } return(textures); }
public static void AddTexture(string CacheId, Texture2D CacheContents, string WalletAddress = "", string WalletName = "") { if (!String.IsNullOrEmpty(WalletAddress)) { CacheId = CacheId + "." + WalletAddress; } string filePath = GetFilePath(CacheId, FileType.PNG); var imageSizeLimit = 256; if (CacheContents.width > imageSizeLimit) { TextureScaler.scale(CacheContents, imageSizeLimit, (int)((double)imageSizeLimit / CacheContents.width * CacheContents.height)); } else if (CacheContents.height > imageSizeLimit) { TextureScaler.scale(CacheContents, (int)((double)imageSizeLimit / CacheContents.height * CacheContents.width), imageSizeLimit); } byte[] bytes = CacheContents.EncodeToPNG(); File.WriteAllBytes(filePath, bytes); UpdateRegistry(CacheId, DateTime.Now, bytes.Length, WalletName); }
static int QPYX_scale_YXQP(IntPtr L_YXQP) { try { int QPYX_count_YXQP = LuaDLL.lua_gettop(L_YXQP); if (QPYX_count_YXQP == 3) { UnityEngine.Texture2D QPYX_arg0_YXQP = (UnityEngine.Texture2D)ToLua.CheckObject(L_YXQP, 1, typeof(UnityEngine.Texture2D)); int QPYX_arg1_YXQP = (int)LuaDLL.luaL_checknumber(L_YXQP, 2); int QPYX_arg2_YXQP = (int)LuaDLL.luaL_checknumber(L_YXQP, 3); TextureScaler.scale(QPYX_arg0_YXQP, QPYX_arg1_YXQP, QPYX_arg2_YXQP); return(0); } else if (QPYX_count_YXQP == 4) { UnityEngine.Texture2D QPYX_arg0_YXQP = (UnityEngine.Texture2D)ToLua.CheckObject(L_YXQP, 1, typeof(UnityEngine.Texture2D)); int QPYX_arg1_YXQP = (int)LuaDLL.luaL_checknumber(L_YXQP, 2); int QPYX_arg2_YXQP = (int)LuaDLL.luaL_checknumber(L_YXQP, 3); int QPYX_arg3_YXQP = (int)LuaDLL.luaL_checknumber(L_YXQP, 4); TextureScaler.scale(QPYX_arg0_YXQP, QPYX_arg1_YXQP, QPYX_arg2_YXQP, QPYX_arg3_YXQP); return(0); } else { return(LuaDLL.luaL_throw(L_YXQP, "invalid arguments to method: TextureScaler.scale")); } } catch (Exception e_YXQP) { return(LuaDLL.toluaL_exception(L_YXQP, e_YXQP)); } }
private void LoadHeightmap(Texture2D texture, TerrainData data) { texture = TextureScaler.scaled(texture, data.heightmapResolution - 1, data.heightmapResolution - 1, FilterMode.Trilinear); //Debug.Log (texture.height); Color[] colors = texture.GetPixels(); float[,] m_heightValues = new float[texture.width, texture.height]; //Debug.Log ("The length of the heightmap is: " + colors.Length); //data.heightmapResolution = (int)Mathf.Sqrt (colors.Length) + 1; // Run through array and read height values. int index = 0; for (int z = 0; z < Mathf.Sqrt(colors.Length); z++) { for (int x = 0; x < Mathf.Sqrt(colors.Length); x++) { m_heightValues [z, x] = colors [index].r; index++; } } //SplatPrototype[] splats = new SplatPrototype[1]; //SplatPrototype splat = new SplatPrototype (); //splats [0] = splat; //splat.texture = texture; //splat.tileSize = new Vector2 (10, 10); //splat.normalMap = testnormalmap; //data.splatPrototypes = splats; // Now set terrain heights. data.size = new Vector3(texture.width, 5, texture.height); data.SetHeights(0, 0, m_heightValues); }
private void LoadHeightmap(Texture2D texture, TerrainData data, int premadeindex, float[,] map) { if (heightmapslow [premadeindex][0, 0] == 0) { TextureScaler.scaled(texture, data.heightmapWidth, data.heightmapHeight, FilterMode.Trilinear); Color[] colors = texture.GetPixels(); float[,] m_heightValues = new float[(int)Mathf.Sqrt(colors.Length), (int)Mathf.Sqrt(colors.Length)]; //Debug.Log ("The length of the heightmap is: " + colors.Length); data.heightmapResolution = (int)Mathf.Sqrt(colors.Length) + 1; // Run through array and read height values. int index = 0; for (int z = 0; z < Mathf.Sqrt(colors.Length); z++) { for (int x = 0; x < Mathf.Sqrt(colors.Length); x++) { m_heightValues [z, x] = colors [index].r; index++; } } // Now set terrain heights. data.size = new Vector3((int)Mathf.Sqrt(colors.Length), 5, (int)Mathf.Sqrt(colors.Length)); map = m_heightValues; } SetHightMap(premadeindex, data, map); }
static int scale(IntPtr L) { try { int count = LuaDLL.lua_gettop(L); if (count == 3) { UnityEngine.Texture2D arg0 = (UnityEngine.Texture2D)ToLua.CheckObject(L, 1, typeof(UnityEngine.Texture2D)); int arg1 = (int)LuaDLL.luaL_checknumber(L, 2); int arg2 = (int)LuaDLL.luaL_checknumber(L, 3); TextureScaler.scale(arg0, arg1, arg2); return(0); } else if (count == 4) { UnityEngine.Texture2D arg0 = (UnityEngine.Texture2D)ToLua.CheckObject(L, 1, typeof(UnityEngine.Texture2D)); int arg1 = (int)LuaDLL.luaL_checknumber(L, 2); int arg2 = (int)LuaDLL.luaL_checknumber(L, 3); int arg3 = (int)LuaDLL.luaL_checknumber(L, 4); TextureScaler.scale(arg0, arg1, arg2, arg3); return(0); } else { return(LuaDLL.luaL_throw(L, "invalid arguments to method: TextureScaler.scale")); } } catch (Exception e) { return(LuaDLL.toluaL_exception(L, e)); } }
private void InitializePenSize() //Pen texture rescaling depending on the images resolution { pencil = penTexture.GetPixels(); eraser = new Texture2D(penTexture.width, penTexture.height, TextureFormat.ARGB32, false); eraser.SetPixels(pencil); TextureScaler.Bilinear(eraser, (int)(eraser.width / (960f / imageWidth)), (int)(eraser.height / (960f / imageHeight))); pencil = null; pencil = eraser.GetPixels(); }
/// <summary> /// Redraws the map based on zoom or pan, but NOT from resizing the editor window /// </summary> void ZoomDrawMap() { CheckOffsetBoundaries(); MapDisplay = TextureScaler.scaled(MapTexture, MapWindowWidth, MapWindowHeight, ZoomFactor, PanOffset.x, PanOffset.y); // Isolate the portion of the map being used based on scale 2.0 scale = 2 pixels per 1 actual pixel MapDisplay.Apply(); bNeedsRedraw = true; }
public override void OnInspectorGUI() { if (GUILayout.Button("Update Material Scale")) { TextureScaler scaler = serializedObject.targetObject as TextureScaler; scaler.UpdateMaterial(); } serializedObject.ApplyModifiedProperties(); }
//Captures the screen and sends it as a texture through ASL private void SendScreenCapture() { Texture2D texture2D = ScreenCapture.CaptureScreenshotAsTexture(); TextureScaler.scale(texture2D, ImageWidth, ImageHeight); aslObject.SendAndSetTexture2D(texture2D, OnFrameDelivered, false); Destroy(texture2D); }
public void ReadImageFromImageFileToCurrentCardImage(string directory) { byte[] fileData = System.IO.File.ReadAllBytes(directory); Texture2D texture = new Texture2D(2, 2); texture.LoadImage(fileData); TextureScaler.Bilinear(texture, (int)CardBeingEditedImage.preferredWidth, (int)CardBeingEditedImage.preferredHeight); Sprite sprite = new Sprite(); sprite = Sprite.Create(texture, new Rect(0, 0, texture.width, texture.height), new Vector2(0, 0)); CardBeingEditedImage.overrideSprite = sprite; }
void Start() { var dev = SelectCameraDevice(); camTexture = new WebCamTexture(dev); camTexture.Play(); nn = new NNHandler(modelFile); yolo = new YOLOHandler(nn); textureScaler = new TextureScaler(nn.model.inputs[0].shape[1], nn.model.inputs[0].shape[2]); InitializeColorArray(); StartCoroutine(WebCamTextureInitialize()); }
/// <summary> /// Imports a raster texture /// </summary> /// <param name="file">The file to import from</param> /// <param name="size">The size of the texture</param> /// <returns>The raster texture imported as a Sprite</returns> public static Sprite ImportRaster(FileInfo file, int size) { // WWW is obsolete, needs replaced eventually WWW www = new WWW(file.FullName); Texture2D tex = www.texture; //tex.alphaIsTransparency = true; Texture2D newTex = MonoBehaviour.Instantiate(tex); TextureScaler.Bilinear(newTex, size, size); Sprite sprite = Sprite.Create(newTex, new Rect(Vector2.zero, new Vector2(size, size)), new Vector2(0.5f, 0.5f), size * 2); return(sprite); }
private IEnumerator SaveTexture(Texture2D _tex, string _name) { float ratio = (float)_tex.width / _tex.height; int width = 700; int height = Mathf.RoundToInt(width / ratio); _tex = TextureScaler.ResizeTexture(_tex, TextureScaler.ImageFilterMode.Bilinear, width, height); byte[] bytes = _tex.EncodeToPNG(); GameObject.Destroy(_tex); controller.fileWriter.Write(_name, bytes); yield return(null); }
void Start() { var dev = SelectCameraDevice(); camTexture = new WebCamTexture(dev); camTexture.Play(); nn = new NNHandler(modelFile); yolo = new YOLOHandler(nn); textureScaler = new TextureScaler(nn.model.inputs[0].shape[1], nn.model.inputs[0].shape[2]); relativeDrawer = GetComponent <OnGUICanvasRelativeDrawer>(); relativeDrawer.relativeObject = imageRenderer.GetComponent <RectTransform>(); classesNames = classesFile.text.Split(','); }
private void SetupStyleTransfer() { setStyle = StyleImage; if (input != null) { input.Dispose(); } if (styleInput != null) { styleInput.Dispose(); } if (styleOutput != null) { styleOutput.Release(); } styleImageSrgb = new Texture2D(StyleImage.width, StyleImage.height, TextureFormat.RGBA32, false, false); Color[] original = StyleImage.GetPixels(); Color[] modifiedColors = new Color[original.Length]; for (int i = 0; i < original.Length; i++) { modifiedColors[i] = original[i].linear; } styleImageSrgb.SetPixels(modifiedColors); styleImageSrgb.Apply(); TextureScaler.Bilinear(styleImageSrgb, styleInsetSize - styleInsetBorderWidth * 2, styleInsetSize - styleInsetBorderWidth * 2); ComputeInfo.channelsOrder = ComputeInfo.ChannelsOrder.NCHW; PrepareStylePrediction(); PatchRuntimeWorkerWithStylePrediction(); whiteBorder = new Texture2D(styleInsetSize, styleInsetSize); Color[] colors = new Color[styleInsetSize * styleInsetSize]; for (int i = 0; i < colors.Length; i++) { colors[i] = Color.white; } whiteBorder.SetPixels(colors); whiteBorder.Apply(); styleOutput = new RenderTexture(setBidirWidth, setBidirHeight, 0, RenderTextureFormat.ARGB32); styleOutput.wrapMode = TextureWrapMode.Clamp; styleOutput.filterMode = FilterMode.Bilinear; }
public static IEnumerator SaveTexture(Texture2D _tex, string _name) { float ratio = ( float )_tex.width / _tex.height; int width = 0, height = 0; // 如果比例大于阈值,则使用Fix width方案 // 反之使用Fix Height方案 if (ratio > FIX_HEIGHT_THRESHOLD) { width = FIX_WIDTH; height = Mathf.RoundToInt(width / ratio); } else { height = FIX_HEIGHT; width = Mathf.RoundToInt(height * ratio); // 如果使用Fix Height方案后,宽度还是超标 // 则再转位Fix Width方案 if (width > FIX_WIDTH) { width = FIX_WIDTH; height = Mathf.RoundToInt(width / ratio); } } Debug.Log("Saved Texture Sizes: " + width + ", " + height); _tex = TextureScaler.ResizeTexture(_tex, width, height); byte[] bytes = _tex.EncodeToPNG(); string path = TGPaths.FullScreenshotPath(_name); Debug.Log("截图路径: " + path); // 写入文件 LMFileWriter.Write(path, bytes); // 写到Dicionary里,好之后写入ret.txt TGData.SaveScreenshot(_name); yield return(null); }
void setBrush() { if (selectBrushIndex >= brushTexture.Length) { selectBrushIndex = selectBrushIndex % brushTexture.Length; } if (selectBrushIndex < 0) { selectBrushIndex = 0; } selectedBrush.SetPixels(((Texture2D)brushTexture[selectBrushIndex]).GetPixels()); selectedBrush = new Texture2D(brushTexture[0].width, brushTexture[0].height); int w = (int)(brushTexture[selectBrushIndex].width * selectBrushSize); int h = (int)(brushTexture[selectBrushIndex].height * selectBrushSize); selectedBrush = TextureScaler.scaled((Texture2D)brushTexture[selectBrushIndex], w, h); TextureScaler.scale(selectedBrush, w, h); }
private static IEnumerator <Texture2D> RenderHighwayShield(DynamicSpriteFont defaultFont, HighwayShieldDescriptor descriptor, AdrHighwayParameters parameters) { if (defaultFont is null) { defaultFont = FontServer.instance[WTSEtcData.Instance.FontSettings.GetTargetFont(FontClass.HighwayShields)]; } UITextureAtlas.SpriteInfo spriteInfo = descriptor.BackgroundImageParameter.GetCurrentSpriteInfo(null); if (spriteInfo is null) { LogUtils.DoWarnLog("HW: Background info is invalid for hw shield descriptor " + descriptor.SaveName); yield break; } else { int shieldHeight = WTSAtlasLoadingUtils.MAX_SIZE_IMAGE_IMPORT; int shieldWidth = WTSAtlasLoadingUtils.MAX_SIZE_IMAGE_IMPORT; var shieldTexture = new Texture2D(spriteInfo.texture.width, spriteInfo.texture.height); var targetColor = descriptor.BackgroundColorIsFromHighway && parameters.hwColor != default ? parameters.hwColor : descriptor.BackgroundColor; shieldTexture.SetPixels(spriteInfo.texture.GetPixels().Select(x => x.MultiplyChannelsButAlpha(targetColor)).ToArray()); TextureScaler.scale(shieldTexture, shieldWidth, shieldHeight); Color[] formTexturePixels = shieldTexture.GetPixels(); foreach (var textDescriptor in descriptor.TextDescriptors) { if (!textDescriptor.GetTargetText(parameters, out string text)) { continue; } Texture2D overlayTexture; if (text is null && textDescriptor.m_textType == TextType.GameSprite) { var spriteTexture = textDescriptor.m_spriteParam?.GetCurrentSpriteInfo(null)?.texture; if (spriteTexture is null) { continue; } overlayTexture = new Texture2D(spriteTexture.width, spriteTexture.height); overlayTexture.SetPixels(spriteTexture.GetPixels()); overlayTexture.Apply(); }
static int QPYX__CreateTextureScaler_YXQP(IntPtr L_YXQP) { try { int QPYX_count_YXQP = LuaDLL.lua_gettop(L_YXQP); if (QPYX_count_YXQP == 0) { TextureScaler QPYX_obj_YXQP = new TextureScaler(); ToLua.PushObject(L_YXQP, QPYX_obj_YXQP); return(1); } else { return(LuaDLL.luaL_throw(L_YXQP, "invalid arguments to ctor method: TextureScaler.New")); } } catch (Exception e_YXQP) { return(LuaDLL.toluaL_exception(L_YXQP, e_YXQP)); } }
private IEnumerator LoadAvatar(string id, string avatarID) { UnityWebRequest avatarURL = UnityWebRequestTexture.GetTexture($"https://cdn.discordapp.com/avatars/{id}/{avatarID}.png"); yield return(avatarURL.SendWebRequest()); avatar = ((DownloadHandlerTexture)avatarURL.downloadHandler).texture; if (avatar == null || avatar.height < 128) { UnityWebRequest standardAvatarURL = UnityWebRequestTexture.GetTexture("https://discordapp.com/assets/6debd47ed13483642cf09e832ed0bc1b.png"); yield return(standardAvatarURL.SendWebRequest()); avatar = ((DownloadHandlerTexture)standardAvatarURL.downloadHandler).texture; } TextureScaler.Scale(avatar, 64, 64); yield return(null); }
private IEnumerator RefreshTargetIcon() { yield return(0); // check wether download needed if (ImageDownload == null && ProfileImageTexture == null) { // Start download if (StomtConfig.TargetImageUrl != null) { WWW www = new WWW(StomtConfig.TargetImageUrl); while (!www.isDone) { // wait until the download is done } ImageDownload = www; } } // check wether download finished if (ImageDownload != null && !TargetImageApplied && ProfileImageTexture == null) { if (ImageDownload.texture != null) // scale now and apply { if (ImageDownload.texture.width != 128 || ImageDownload.texture.height != 128) { ProfileImageTexture = TextureScaler.scaled(ImageDownload.texture, 128, 128, FilterMode.Trilinear); } TargetIcon.sprite.texture.LoadImage(ProfileImageTexture.EncodeToPNG()); this.TargetImageApplied = true; } } else { // already loaded, apply now ApplyProfileImageTextureIfAvailable(); } UpdateDynamicText(); }
private IEnumerator LoadAvatar(string id, string avatar_id) { WWW avatarURL = new WWW("https://cdn.discordapp.com/avatars/" + id + "/" + avatar_id + ".png"); yield return(avatarURL); if (avatarURL.texture != null && avatarURL.texture.height >= 128) { avatar = avatarURL.texture; } else { WWW standardAvatarURL = new WWW("https://discordapp.com/assets/6debd47ed13483642cf09e832ed0bc1b.png"); yield return(standardAvatarURL); avatar = standardAvatarURL.texture; } TextureScaler.Scale(avatar, 64, 64); yield return(null); }
public void ExportFlowMap() { Texture2D tex = new Texture2D((int)Mathf.Sqrt(vertPoints.Count), (int)Mathf.Sqrt(vertPoints.Count)); tex.SetPixels(pointColors); tex.Apply(); tex = TextureScaler.scaled(tex, (int)flowMapSize.x, (int)flowMapSize.y); tex = Blur.FastBlur(tex, 4, 2); GetComponent <MeshRenderer>().material.mainTexture = tex; currentFlowMap = tex; if (debugging) { displayPlane.GetComponent <MeshRenderer>().materials[0].mainTexture = tex; } SaveTextureToAssets.Save(tex); }
static int _CreateTextureScaler(IntPtr L) { try { int count = LuaDLL.lua_gettop(L); if (count == 0) { TextureScaler obj = new TextureScaler(); ToLua.PushObject(L, obj); return(1); } else { return(LuaDLL.luaL_throw(L, "invalid arguments to ctor method: TextureScaler.New")); } } catch (Exception e) { return(LuaDLL.toluaL_exception(L, e)); } }
private IEnumerator LoadAvatar(string id, string avatar_id) { UnityWebRequest avatarURL = UnityWebRequestTexture.GetTexture("https://cdn.discordapp.com/avatars/" + id + "/" + avatar_id + ".png"); yield return(avatarURL.SendWebRequest()); Texture2D avatarTexture = ((DownloadHandlerTexture)avatarURL.downloadHandler).texture; if (avatarTexture != null && avatarTexture.height >= 128) { avatar = avatarTexture; } else { UnityWebRequest standardAvatarURL = UnityWebRequestTexture.GetTexture("https://discordapp.com/assets/6debd47ed13483642cf09e832ed0bc1b.png"); yield return(standardAvatarURL.SendWebRequest()); avatar = ((DownloadHandlerTexture)standardAvatarURL.downloadHandler).texture; } TextureScaler.Scale(avatar, 64, 64); yield return(null); }
private void SaveAsPNG() { // Show save file dialog #if UNITY_EDITOR path = UnityEditor.EditorUtility.SaveFilePanel("Export Single Image", "Assets/", fileName, "png"); #endif if (string.IsNullOrEmpty(path)) { return; } // Pause character animation character.speed = 0; playToggle.isOn = false; // Render and save to file Texture2D tex2D = new Texture2D(width * superSampling, height * superSampling, TextureFormat.RGBA32, false); RenderTexture.active = renderTexture; previewCam.Render(); tex2D.ReadPixels(new Rect(0, 0, width * superSampling, height * superSampling), 0, 0, false); TextureScaler.Bilinear(tex2D, width, height); tex2D.Apply(); byte[] bytes = tex2D.EncodeToPNG(); File.WriteAllBytes(path, bytes); RenderTexture.active = null; Object.Destroy(tex2D); // Show success dialog box Debug.Log("Saved to " + path); #if UNITY_EDITOR UnityEditor.EditorUtility.DisplayDialog("Save Successful", "Saved to " + path, "OK"); #else runtimeDialog.DisplayDialog("Save Successful", "PNG saved to <color=#178294>" + path + "</color> successfully."); #endif }
private IEnumerator SaveSequence() { // Show save dialog #if UNITY_EDITOR path = UnityEditor.EditorUtility.SaveFilePanel("Export Sequence", "Assets/", fileName, "png"); #endif if (string.IsNullOrEmpty(path)) { yield break; } // Split path into base (without extension) and directory path to use when saving sequence string basePath = path.Replace(".png", "_"); // Get animation length GetAnimationLength(); float frameDelay = 1 / (float)targetFPS; float elapsedTime = 0; // Pause character animation and reset aim layer to make sure muzzle flash particle is off playToggle.isOn = false; character.Play("None", 1, 0); yield return(null); // Iterate and render through each frame of the sequence for (int i = 0; i < frameCount; i++) { yield return(new WaitForSeconds(frameDelay)); // update progress bar float progress = ((float)i + 1) / frameCount; #if UNITY_EDITOR UnityEditor.EditorUtility.DisplayProgressBar("Export Sequence", "Exporting frame " + i.ToString() + "/" + frameCount.ToString(), progress); #else runtimeDialog.DisplayProgressBar("Export Sequence", "Exporting frame " + i.ToString() + "/" + frameCount.ToString(), progress); #endif // Set the character animation and convert animation length into normalized time float baseTime = (float)i * frameDelay / baseLength; character.Play(selectedAnimation, 0, baseTime); character.speed = 0; // Only play aim layer once and clamp the animation at the end // or keep looping if loop aim layer is set to true if (elapsedTime <= aimLength || loopAimLayer) { float aimTIme = (float)i * frameDelay / aimLength; character.Play(selectedAim, 1, aimTIme); character.speed = 0; } // Wait til animator is updated properly elapsedTime += frameDelay; yield return(null); // Render and save the frame Texture2D tex2D = new Texture2D(width * superSampling, height * superSampling, TextureFormat.RGBA32, false); RenderTexture.active = renderTexture; previewCam.Render(); tex2D.ReadPixels(new Rect(0, 0, width * superSampling, height * superSampling), 0, 0, false); TextureScaler.Bilinear(tex2D, width, height); tex2D.Apply(); byte[] bytes = tex2D.EncodeToPNG(); path = basePath + i.ToString("000") + ".png"; File.WriteAllBytes(path, bytes); RenderTexture.active = null; Object.Destroy(tex2D); } // Show success dialog box Debug.Log("PNG sequences saved to " + path); #if UNITY_EDITOR UnityEditor.EditorUtility.ClearProgressBar(); UnityEditor.EditorUtility.DisplayDialog("Save Successful", "PNG sequence saved to " + path, "OK"); #else runtimeDialog.DisplayDialog("Save Successful", "PNG sequence saved to <color=#178294>" + path + "</color> successfully."); #endif }