Unity/UIImage/Texture
提供: 初心者エンジニアの簡易メモ
Textureの値渡し
var tmpTexture = CopyTexture((Texture2D)texture); tmpTexture.Apply();
コピーロジック
public Texture2D CopyTexture(Texture2D source) { var texture = new Texture2D(source.width, source.height, TextureFormat.RGBA32, false); var renderTexture = new RenderTexture(texture.width, texture.height, 32); Graphics.Blit(source, renderTexture); RenderTexture.active = renderTexture; texture.ReadPixels(new Rect(0, 0, renderTexture.width, renderTexture.height), 0, 0); RenderTexture.active = null; RenderTexture.DestroyImmediate(renderTexture); return texture; }
参考:https://qiita.com/UnityFoo/items/25b8304036e0a8ca7798
Texture削除
Destroy(texture); tmpTexture = null;
解放(Destroy)して削除しないと、メモリ内に、データが溜まっていきます。