public void setPlayerParam(string paramName, string sParam) { #if !UNITY_EDITOR && !LOCALARCHIVES && UNITY_ANDROID using (AndroidJavaClass jc = new AndroidJavaClass("com.unity3d.player.UnityPlayer")) { using (AndroidJavaObject jo = jc.GetStatic <AndroidJavaObject>("currentActivity")) { jo.Call("setPlayerParam", paramName, sParam); } } #else //为了适应之前的系统,这里,非加密档案,更换新的存储文件 //using (UniDataFileWriter writer = new UniDataFileWriter()) //{ // writer.Open(UniGameResources.ConnectPath("gamecenter_", // paramName, ".txt")); // writer.writer.Write(sParam); // writer.Close(); //} using (UniDataFileWriter writer = new UniDataFileWriter()) { writer.Open(UniGameResources.ConnectPath("new_gamecenter_", paramName, ".txt"), false); writer.writer.Write(sParam); writer.Close(); } #endif //UNITY_ANDROID }
public void setPlayerScore(int score) { #if !UNITY_EDITOR && !LOCALARCHIVES && UNITY_ANDROID using (AndroidJavaClass jc = new AndroidJavaClass("com.unity3d.player.UnityPlayer")) { using (AndroidJavaObject jo = jc.GetStatic <AndroidJavaObject>("currentActivity")) { jo.Call("setPlayerScore", score); } } #else //为了适应之前的系统,这里,非加密档案,更换新的存储文件 //using (UniDataFileWriter writer = new UniDataFileWriter()) //{ // writer.Open("gamecenter_playerscore.txt"); // writer.writer.Write(score); // writer.Close(); //} using (UniDataFileWriter writer = new UniDataFileWriter()) { writer.Open("new_gamecenter_playerscore.txt", false); writer.writer.Write(score); writer.Close(); } #endif }