示例#1
0
    private void OnGUI()
    {
        GUILayout.BeginHorizontal();
        GUILayout.BeginVertical();

        CenteredLabel("Memory cheating protection");

        GUILayout.Space(10);

        if (obscuredStringTest && obscuredStringTest.enabled)
        {
            if (GUILayout.Button("Use regular string"))
            {
                obscuredStringTest.UseRegular();
            }

            if (GUILayout.Button("Use obscured string"))
            {
                obscuredStringTest.UseObscured();
            }

            string currentString;

            if (obscuredStringTest.useRegular)
            {
                currentString = obscuredStringTest.cleanString;
            }
            else
            {
                currentString = obscuredStringTest.obscuredString;
            }
            GUILayout.Label("Current string (try to change it!):\n" + currentString);
        }

        if (obscuredIntTest && obscuredIntTest.enabled)
        {
            GUILayout.Space(10);
            if (GUILayout.Button("Use regular int (click to generate new number)"))
            {
                obscuredIntTest.UseRegular();
            }

            if (GUILayout.Button("Use ObscuredInt (click to generate new number)"))
            {
                obscuredIntTest.UseObscured();
            }

            int currentLivesCount;

            if (obscuredIntTest.useRegular)
            {
                currentLivesCount = obscuredIntTest.cleanLivesCount;
            }
            else
            {
                currentLivesCount = obscuredIntTest.obscuredLivesCount;
            }
            GUILayout.Label("Current lives count (try to change them!):\n" + currentLivesCount);
        }

#if !UNITY_4_0 && !UNITY_4_1 && !UNITY_4_2 && !UNITY_4_3
        GUILayout.BeginHorizontal();
        GUILayout.Label("ObscuredInt from inspector: " + dummyObscuredInt);
        if (GUILayout.Button("+"))
        {
            dummyObscuredInt++;
        }
        if (GUILayout.Button("-"))
        {
            dummyObscuredInt--;
        }
        GUILayout.EndHorizontal();
#endif

        if (obscuredFloatTest && obscuredFloatTest.enabled)
        {
            GUILayout.Space(10);
            if (GUILayout.Button("Use regular float (click to generate new number)"))
            {
                obscuredFloatTest.UseRegular();
            }

            if (GUILayout.Button("Use ObscuredFloat (click to generate new number)"))
            {
                obscuredFloatTest.UseObscured();
            }

            float currentHealthBar;

            if (obscuredFloatTest.useRegular)
            {
                currentHealthBar = obscuredFloatTest.healthBar;
            }
            else
            {
                currentHealthBar = obscuredFloatTest.obscuredHealthBar;
            }
            GUILayout.Label("Current health bar (try to change it!):\n" + System.String.Format("{0:0.000}", currentHealthBar));
        }

        if (obscuredVector3Test && obscuredVector3Test.enabled)
        {
            GUILayout.Space(10);
            if (GUILayout.Button("Use regular Vector3 (click to generate new one)"))
            {
                obscuredVector3Test.UseRegular();
            }

            if (GUILayout.Button("Use ObscuredVector3 (click to generate new one)"))
            {
                obscuredVector3Test.UseObscured();
            }

            Vector3 position;

            if (obscuredVector3Test.useRegular)
            {
                position = obscuredVector3Test.playerPosition;
            }
            else
            {
                position = obscuredVector3Test.obscuredPlayerPosition;
            }
            GUILayout.Label("Current player position (try to change it!):\n" + position);
        }

        GUILayout.Space(10);

        GUILayout.EndVertical();
        GUILayout.Space(10);
        GUILayout.BeginVertical();
        CenteredLabel("Saves cheating protection");
        GUILayout.Space(10);

        if (obscuredPrefsTest && obscuredPrefsTest.enabled)
        {
            if (GUILayout.Button("Save game with regular PlayerPrefs!"))
            {
                obscuredPrefsTest.SaveGame(false);
            }

            if (GUILayout.Button("Read data saved with regular PlayerPrefs"))
            {
                obscuredPrefsTest.ReadSavedGame(false);
            }

            GUILayout.Space(10);

            if (GUILayout.Button("Save game with ObscuredPrefs!"))
            {
                obscuredPrefsTest.SaveGame(true);
            }

            if (GUILayout.Button("Read data saved with ObscuredPrefs"))
            {
                obscuredPrefsTest.ReadSavedGame(true);
            }

            ObscuredPrefs.preservePlayerPrefs = GUILayout.Toggle(ObscuredPrefs.preservePlayerPrefs, "preservePlayerPrefs");

#if UNITY_EDITOR
            ObscuredPrefs.unobscuredMode = GUILayout.Toggle(ObscuredPrefs.unobscuredMode, "unobscuredMode");
#endif

            ObscuredPrefs.emergencyMode = GUILayout.Toggle(ObscuredPrefs.emergencyMode, "emergencyMode");

            GUILayout.Label("LockToDevice level:");
            savesLock = GUILayout.SelectionGrid(savesLock, new[] { ObscuredPrefs.DeviceLockLevel.None.ToString(), ObscuredPrefs.DeviceLockLevel.Soft.ToString(), ObscuredPrefs.DeviceLockLevel.Strict.ToString() }, 3);
            ObscuredPrefs.lockToDevice = (ObscuredPrefs.DeviceLockLevel)savesLock;

            ObscuredPrefs.readForeignSaves = GUILayout.Toggle(ObscuredPrefs.readForeignSaves, "readForeignSaves");

            GUILayout.Label("PlayerPrefs: \n" + obscuredPrefsTest.gameData);

            if (savesAlterationDetected)
            {
                GUILayout.Label("Saves were altered! }:>");
            }

            if (foreignSavesDetected)
            {
                GUILayout.Label("Saves more likely from another device! }:>");
            }
        }

        if (detectorsUsageExample != null)
        {
            GUILayout.Label("Speed hack detected: " + detectorsUsageExample.speedHackDetected);
#if UNITY_STANDALONE || UNITY_WEBPLAYER || UNITY_IPHONE || UNITY_ANDROID
            GUILayout.Label("Injection detected: " + detectorsUsageExample.injectionDetected);
#else
            GUILayout.Label("Injection detection is not available on current platform");
#endif
            GUILayout.Label("Obscured type cheating detected: " + detectorsUsageExample.obscuredTypeCheatDetected);
        }

        GUILayout.EndVertical();
        GUILayout.EndHorizontal();
    }
示例#2
0
 private void OnGUI()
 {
     GUILayout.BeginHorizontal();
     GUILayout.BeginVertical();
     CenteredLabel("Memory cheating protection");
     GUILayout.Space(10f);
     if ((bool)obscuredStringTest && obscuredStringTest.enabled)
     {
         if (GUILayout.Button("Use regular string"))
         {
             obscuredStringTest.UseRegular();
         }
         if (GUILayout.Button("Use obscured string"))
         {
             obscuredStringTest.UseObscured();
         }
         string str = (!obscuredStringTest.useRegular) ? ((string)obscuredStringTest.obscuredString) : obscuredStringTest.cleanString;
         GUILayout.Label("Current string (try to change it!):\n" + str);
     }
     if ((bool)obscuredIntTest && obscuredIntTest.enabled)
     {
         GUILayout.Space(10f);
         if (GUILayout.Button("Use regular int (click to generate new number)"))
         {
             obscuredIntTest.UseRegular();
         }
         if (GUILayout.Button("Use ObscuredInt (click to generate new number)"))
         {
             obscuredIntTest.UseObscured();
         }
         int num = (!obscuredIntTest.useRegular) ? ((int)obscuredIntTest.obscuredLivesCount) : obscuredIntTest.cleanLivesCount;
         GUILayout.Label("Current lives count (try to change them!):\n" + num);
         if (obscuredIntTest.cheatingDetected)
         {
             GUILayout.Label("ObscuredInt cheating try detected!");
         }
     }
     if ((bool)obscuredFloatTest && obscuredFloatTest.enabled)
     {
         GUILayout.Space(10f);
         if (GUILayout.Button("Use regular float (click to generate new number)"))
         {
             obscuredFloatTest.UseRegular();
         }
         if (GUILayout.Button("Use ObscuredFloat (click to generate new number)"))
         {
             obscuredFloatTest.UseObscured();
         }
         float num2 = (!obscuredFloatTest.useRegular) ? ((float)obscuredFloatTest.obscuredHealthBar) : obscuredFloatTest.healthBar;
         GUILayout.Label("Current health bar (try to change it!):\n" + $"{num2:0.000}");
         if (obscuredFloatTest.cheatingDetected)
         {
             GUILayout.Label("ObscuredFloat cheating try detected!");
         }
     }
     if ((bool)obscuredVector3Test && obscuredVector3Test.enabled)
     {
         GUILayout.Space(10f);
         if (GUILayout.Button("Use regular Vector3 (click to generate new one)"))
         {
             obscuredVector3Test.UseRegular();
         }
         if (GUILayout.Button("Use ObscuredVector3 (click to generate new one)"))
         {
             obscuredVector3Test.UseObscured();
         }
         Vector3 vector = (!obscuredVector3Test.useRegular) ? ((Vector3)obscuredVector3Test.obscuredPlayerPosition) : obscuredVector3Test.playerPosition;
         GUILayout.Label("Current player position (try to change it!):\n" + vector);
     }
     GUILayout.Space(10f);
     GUILayout.EndVertical();
     GUILayout.Space(10f);
     GUILayout.BeginVertical();
     CenteredLabel("Saves cheating protection");
     GUILayout.Space(10f);
     if ((bool)obscuredPrefsTest && obscuredPrefsTest.enabled)
     {
         if (GUILayout.Button("Save game with regular PlayerPrefs!"))
         {
             obscuredPrefsTest.SaveGame(obscured: false);
         }
         if (GUILayout.Button("Read data saved with regular PlayerPrefs"))
         {
             obscuredPrefsTest.ReadSavedGame(obscured: false);
         }
         GUILayout.Space(10f);
         if (GUILayout.Button("Save game with ObscuredPrefs!"))
         {
             obscuredPrefsTest.SaveGame(obscured: true);
         }
         if (GUILayout.Button("Read data saved with ObscuredPrefs"))
         {
             obscuredPrefsTest.ReadSavedGame(obscured: true);
         }
         ObscuredPrefs.preservePlayerPrefs = GUILayout.Toggle(ObscuredPrefs.preservePlayerPrefs, "preservePlayerPrefs");
         ObscuredPrefs.emergencyMode       = GUILayout.Toggle(ObscuredPrefs.emergencyMode, "emergencyMode");
         GUILayout.Label("LockToDevice level:");
         savesLock = GUILayout.SelectionGrid(savesLock, new string[3]
         {
             ObscuredPrefs.DeviceLockLevel.None.ToString(),
             ObscuredPrefs.DeviceLockLevel.Soft.ToString(),
             ObscuredPrefs.DeviceLockLevel.Strict.ToString()
         }, 3);
         ObscuredPrefs.lockToDevice     = (ObscuredPrefs.DeviceLockLevel)savesLock;
         ObscuredPrefs.readForeignSaves = GUILayout.Toggle(ObscuredPrefs.readForeignSaves, "readForeignSaves");
         GUILayout.Label("PlayerPrefs: \n" + obscuredPrefsTest.gameData);
         if (savesAlterationDetected)
         {
             GUILayout.Label("Saves were altered! }:>");
         }
         if (foreignSavesDetected)
         {
             GUILayout.Label("Saves more likely from another device! }:>");
         }
     }
     if (detectorsUsageExample != null)
     {
         GUILayout.Label("Speed hack detected: " + detectorsUsageExample.speedHackDetected);
         GUILayout.Label("Injection detected: " + detectorsUsageExample.injectionDetected);
     }
     GUILayout.EndVertical();
     GUILayout.EndHorizontal();
 }