당신은 playerprefs에서 64 기수로 스프라이트의 질감을 저장할 수 있습니다, 당신은 저장 질감에서 스프라이트를 만들 수 있습니다. 그러나 텍스처는 읽기/쓰기가 가능해야하며 ARGB32, RGBA32, RGB24 등과 같이 지원되는 형식이어야합니다.
using UnityEngine;
using System.Collections;
public class TextureStore
{
public static void WriteTextureToPlayerPrefs (string tag, Texture2D tex)
{
// if texture is png otherwise you can use tex.EncodeToJPG().
byte[] texByte = tex.EncodeToPNG();
// convert byte array to base64 string
string base64Tex = System.Convert.ToBase64String (texByte);
// write string to playerpref
PlayerPrefs.SetString (tag, base64Tex);
PlayerPrefs.Save();
}
public static Texture2D ReadTextureFromPlayerPrefs (string tag)
{
// load string from playerpref
string base64Tex = PlayerPrefs.GetString (tag, null);
if (!string.IsNullOrEmpty (base64Tex)) {
// convert it to byte array
byte[] texByte = System.Convert.FromBase64String (base64Tex);
Texture2D tex = new Texture2D (2, 2);
//load texture from byte array
if (tex.LoadImage (texByte)) {
return tex;
}
}
return null;
}
}
그래서 문자열로 저장 하시겠습니까? –
@TimCooley 예. – Iggy
GetComponentInChildren() .name 이제 스프라이트의 이름을 캡처하려고합니다. –