Unity覚書 Texture2DのPNG変換

自分用メモです。(進行中)

■Texture2DをPNGに変換してローカルに書き込む方法
・Unity Script Reference – Texture2D.EncodeToPNG
http://docs.unity3d.com/Documentation/ScriptReference/Texture2D.EncodeToPNG.html

☆Application.dataPathを使う場合は、/Dataを/Documents
に変換しないとエラーになるそうな。
・クリエイトウェーブ開発日記
Unity 3D http://createwave.blog104.fc2.com/blog-category-10.html

☆AndroidでもiOSでも使いたい場合は下記が使えそう?
・Application.persistentDataPath
http://www.previewlabs.com/file-io-in-unity3d/

☆EncodeToPNGを使った際
You can make the texture readable in the Texture Import Settings.
と言われて画像が読み込めない場合の対処方法。

読み込めない画像のInspectorで下記設定をする。
Texture Type -> Advance
Read/Write Enabled -> Check

http://answers.unity3d.com/questions/25775/trying-to-access-a-textures-pixel-coords.html

☆画像をアルバムに保存する方法
iOS:
Pluginを作って、UIImageWriteToSavedPhotosAlbumを呼ぶ。
http://mthr.blogspot.jp/2009/10/iphoneuiimagewritetosavedphotosalbum.html
取り敢えず、Texture2Dをカメラロールに保存できた。目茶目茶時間掛かったです。

Android:
まだ

Follow me!