コード例 #1
0
 public void ReadSavedGame(bool obscured)
 {
     if (obscured)
     {
         gameData = "Money: " + ObscuredPrefs.GetInt("money") + "\n";
         string text = gameData;
         gameData = text + "Life bar: " + ObscuredPrefs.GetFloat("lifeBar") + "\n";
         gameData = gameData + "Player name: " + ObscuredPrefs.GetString("playerName") + "\n";
         text     = gameData;
         gameData = text + "bool: " + ObscuredPrefs.GetBool("gameComplete") + "\n";
         text     = gameData;
         gameData = text + "long: " + ObscuredPrefs.GetLong("demoLong") + "\n";
         text     = gameData;
         gameData = text + "double: " + ObscuredPrefs.GetDouble("demoDouble") + "\n";
         byte[] byteArray = ObscuredPrefs.GetByteArray("demoByteArray", 0, 4);
         text     = gameData;
         gameData = text + "Vector3: " + ObscuredPrefs.GetVector3("demoVector3") + "\n";
         text     = gameData;
         gameData = text + "byte[]: {" + byteArray[0] + "," + byteArray[1] + "," + byteArray[2] + "," + byteArray[3] + "}";
     }
     else
     {
         gameData = "Money: " + PlayerPrefs.GetInt("money") + "\n";
         string text = gameData;
         gameData = text + "Life bar: " + PlayerPrefs.GetFloat("lifeBar") + "\n";
         gameData = gameData + "Player name: " + PlayerPrefs.GetString("playerName");
     }
 }
コード例 #2
0
        private void LoadObscuredPrefs()
        {
            byte[] ba = ObscuredPrefs.GetByteArray(PREFS_BYTE_ARRAY, 0, 4);

            obscuredPrefs  = "int: " + ObscuredPrefs.GetInt(PREFS_INT, -1) + "\n";
            obscuredPrefs += "float: " + ObscuredPrefs.GetFloat(PREFS_FLOAT, -1) + "\n";
            obscuredPrefs += "string: " + ObscuredPrefs.GetString(PREFS_STRING, "No saved ObscuredPrefs!") + "\n";
            obscuredPrefs += "bool: " + ObscuredPrefs.GetBool(PREFS_BOOL, false) + "\n";
            obscuredPrefs += "uint: " + ObscuredPrefs.GetUInt(PREFS_UINT, 0) + "\n";
            obscuredPrefs += "long: " + ObscuredPrefs.GetLong(PREFS_LONG, -1) + "\n";
            obscuredPrefs += "double: " + ObscuredPrefs.GetDouble(PREFS_DOUBLE, -1) + "\n";
            obscuredPrefs += "Vector2: " + ObscuredPrefs.GetVector2(PREFS_VECTOR2, Vector2.zero) + "\n";
            obscuredPrefs += "Vector3: " + ObscuredPrefs.GetVector3(PREFS_VECTOR3, Vector3.zero) + "\n";
            obscuredPrefs += "Quaternion: " + ObscuredPrefs.GetQuaternion(PREFS_QUATERNION, Quaternion.identity) + "\n";
            obscuredPrefs += "Rect: " + ObscuredPrefs.GetRect(PREFS_RECT, new Rect(0, 0, 0, 0)) + "\n";
            obscuredPrefs += "Color: " + ObscuredPrefs.GetColor(PREFS_COLOR, Color.black) + "\n";
            obscuredPrefs += "byte[]: {" + ba[0] + "," + ba[1] + "," + ba[2] + "," + ba[3] + "}";
        }
コード例 #3
0
 public void ReadSavedGame(bool obscured)
 {
     if (obscured)
     {
         gameData  = "Name: " + ObscuredPrefs.GetString(PREFS_NAME) + "\n";
         gameData += "Money: " + ObscuredPrefs.GetInt(PREFS_MONEY) + "\n";
         gameData += "Level: " + ObscuredPrefs.GetInt(PREFS_LEVEL) + "\n";
         gameData += "Life bar: " + ObscuredPrefs.GetFloat(PREFS_LIFE_BAR) + "\n";
         gameData += "bool: " + ObscuredPrefs.GetBool(PREFS_GAME_COMPLETE) + "\n";
         gameData += "long: " + ObscuredPrefs.GetLong(PREFS_LONG) + "\n";
         gameData += "double: " + ObscuredPrefs.GetDouble(PREFS_DOUBLE) + "\n";
         byte[] ba = ObscuredPrefs.GetByteArray(PREFS_BYTE_ARRAY, 0, 4);
         gameData += "Vector3: " + ObscuredPrefs.GetVector3(PREFS_VECTOR3) + "\n";
         gameData += "byte[]: {" + ba[0] + "," + ba[1] + "," + ba[2] + "," + ba[3] + "}";
     }
     else
     {
         gameData  = "Name: " + PlayerPrefs.GetString(PREFS_NAME) + "\n";
         gameData += "Money: " + PlayerPrefs.GetInt(PREFS_MONEY) + "\n";
         gameData += "Level: " + PlayerPrefs.GetInt(PREFS_LEVEL) + "\n";
         gameData += "Life bar: " + PlayerPrefs.GetFloat(PREFS_LIFE_BAR);
     }
 }
コード例 #4
0
        internal void LoadObscuredPrefs()
        {
            // you can store typical int, float and string at the ObscuredPrefs
            obscuredPrefs  = "int: " + ObscuredPrefs.GetInt(PrefsInt, -1) + "\n";
            obscuredPrefs += "float: " + ObscuredPrefs.GetFloat(PrefsFloat, -1) + "\n";
            obscuredPrefs += "string: " + ObscuredPrefs.GetString(PrefsString, "No saved ObscuredPrefs!") + "\n";

            // comparing to the vanilla PlayerPrefs, you have much more freedom on what to save
            obscuredPrefs += "bool: " + ObscuredPrefs.GetBool(PrefsBool, false) + "\n";
            obscuredPrefs += "uint: " + ObscuredPrefs.GetUInt(PrefsUint, 0) + "\n";
            obscuredPrefs += "long: " + ObscuredPrefs.GetLong(PrefsLong, -1) + "\n";
            obscuredPrefs += "double: " + ObscuredPrefs.GetDouble(PrefsDouble, -1) + "\n";
            obscuredPrefs += "Vector2: " + ObscuredPrefs.GetVector2(PrefsVector2, Vector2.zero) + "\n";
            obscuredPrefs += "Vector3: " + ObscuredPrefs.GetVector3(PrefsVector3, Vector3.zero) + "\n";
            obscuredPrefs += "Quaternion: " + ObscuredPrefs.GetQuaternion(PrefsQuaternion, Quaternion.identity) + "\n";
            obscuredPrefs += "Rect: " + ObscuredPrefs.GetRect(PrefsRect, new Rect(0, 0, 0, 0)) + "\n";
            obscuredPrefs += "Color: " + ObscuredPrefs.GetColor(PrefsColor, Color.black) + "\n";

            // you can even store raw byte array with any data inside
            var ba = ObscuredPrefs.GetByteArray(PrefsByteArray, 0, 4);

            obscuredPrefs += "byte[]: {" + ba[0] + "," + ba[1] + "," + ba[2] + "," + ba[3] + "}";
        }
コード例 #5
0
    public void ReadSavedGame(bool obscured)
    {
        if (obscured)
        {
            gameData  = "Money: " + ObscuredPrefs.GetInt("money") + "\n";
            gameData += "Life bar: " + ObscuredPrefs.GetFloat("lifeBar") + "\n";
            gameData += "Player name: " + ObscuredPrefs.GetString("playerName") + "\n";
            gameData += "bool: " + ObscuredPrefs.GetBool("gameComplete") + "\n";
#if !UNITY_FLASH
            gameData += "long: " + ObscuredPrefs.GetLong("demoLong") + "\n";
            gameData += "double: " + ObscuredPrefs.GetDouble("demoDouble") + "\n";
#endif
            byte[] ba = ObscuredPrefs.GetByteArray("demoByteArray", 0, 4);
            gameData += "Vector3: " + ObscuredPrefs.GetVector3("demoVector3") + "\n";
            gameData += "byte[]: {" + ba[0] + "," + ba[1] + "," + ba[2] + "," + ba[3] + "}";
        }
        else
        {
            gameData  = "Money: " + PlayerPrefs.GetInt("money") + "\n";
            gameData += "Life bar: " + PlayerPrefs.GetFloat("lifeBar") + "\n";
            gameData += "Player name: " + PlayerPrefs.GetString("playerName");
        }
    }
コード例 #6
0
        private void LoadObscuredPrefs()
        {
            byte[] byteArray = ObscuredPrefs.GetByteArray("demoByteArray", 0, 4);
            this.obscuredPrefs = "int: " + ObscuredPrefs.GetInt("money", -1) + "\n";
            string text = this.obscuredPrefs;

            this.obscuredPrefs = string.Concat(new object[]
            {
                text,
                "float: ",
                ObscuredPrefs.GetFloat("lifeBar", -1f),
                "\n"
            });
            this.obscuredPrefs = this.obscuredPrefs + "string: " + ObscuredPrefs.GetString("name", "No saved ObscuredPrefs!") + "\n";
            text = this.obscuredPrefs;
            this.obscuredPrefs = string.Concat(new object[]
            {
                text,
                "bool: ",
                ObscuredPrefs.GetBool("gameComplete", false),
                "\n"
            });
            text = this.obscuredPrefs;
            this.obscuredPrefs = string.Concat(new object[]
            {
                text,
                "uint: ",
                ObscuredPrefs.GetUInt("demoUint", 0u),
                "\n"
            });
            text = this.obscuredPrefs;
            this.obscuredPrefs = string.Concat(new object[]
            {
                text,
                "long: ",
                ObscuredPrefs.GetLong("demoLong", -1L),
                "\n"
            });
            text = this.obscuredPrefs;
            this.obscuredPrefs = string.Concat(new object[]
            {
                text,
                "double: ",
                ObscuredPrefs.GetDouble("demoDouble", -1.0),
                "\n"
            });
            text = this.obscuredPrefs;
            this.obscuredPrefs = string.Concat(new object[]
            {
                text,
                "Vector2: ",
                ObscuredPrefs.GetVector2("demoVector2", Vector2.zero),
                "\n"
            });
            text = this.obscuredPrefs;
            this.obscuredPrefs = string.Concat(new object[]
            {
                text,
                "Vector3: ",
                ObscuredPrefs.GetVector3("demoVector3", Vector3.zero),
                "\n"
            });
            text = this.obscuredPrefs;
            this.obscuredPrefs = string.Concat(new object[]
            {
                text,
                "Quaternion: ",
                ObscuredPrefs.GetQuaternion("demoQuaternion", Quaternion.identity),
                "\n"
            });
            text = this.obscuredPrefs;
            this.obscuredPrefs = string.Concat(new object[]
            {
                text,
                "Rect: ",
                ObscuredPrefs.GetRect("demoRect", new Rect(0f, 0f, 0f, 0f)),
                "\n"
            });
            text = this.obscuredPrefs;
            this.obscuredPrefs = string.Concat(new object[]
            {
                text,
                "Color: ",
                ObscuredPrefs.GetColor("demoColor", Color.black),
                "\n"
            });
            text = this.obscuredPrefs;
            this.obscuredPrefs = string.Concat(new object[]
            {
                text,
                "byte[]: {",
                byteArray[0],
                ",",
                byteArray[1],
                ",",
                byteArray[2],
                ",",
                byteArray[3],
                "}"
            });
        }