Skip to content

Instantly share code, notes, and snippets.

@anchan828
Created September 30, 2012 15:39
Show Gist options
  • Save anchan828/3807207 to your computer and use it in GitHub Desktop.
Save anchan828/3807207 to your computer and use it in GitHub Desktop.
WindowsでEditorPrefsを使うときにはBase64で保存する
using UnityEngine;
using UnityEditor;
using System.Text;
public class NewBehaviourScript{
[MenuItem("Window/Save")]
static void Save (){
EditorPrefs.SetString ("Hoge", ToBase64 ("日本語"));
}
[MenuItem("Window/Load")]
static void Load (){
Debug.Log (FromBase64 (EditorPrefs.GetString ("Hoge")));
}
static string ToBase64 (string s){
return System.Convert.ToBase64String (UTF8Encoding.UTF8.GetBytes (s));
}
static string FromBase64 (string s){
return UTF8Encoding.UTF8.GetString (System.Convert.FromBase64String (s));
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment