Ejemplo n.º 1
0
    public static void Main()
    {
        AllocateMemory();

        // Get addresses of static Age fields.
        IntPtr freePtr1 = FreeClass.AddressOfFreeAge();

        AllocateMemory();

        IntPtr fixedPtr1 = FixedClass.AddressOfFixedAge();

        AllocateMemory();

        // Garbage collection.
        GC.Collect();
        GC.WaitForPendingFinalizers();

        // Get addresses of static Age fields after garbage collection.
        IntPtr freePtr2  = FreeClass.AddressOfFreeAge();
        IntPtr fixedPtr2 = FixedClass.AddressOfFixedAge();

        // Display addresses before and after garbage collection
        Console.WriteLine("Normal static: {0} -> {1}", freePtr1, freePtr2);
        Console.WriteLine("Pinned static:  {0} -> {1}", fixedPtr1, fixedPtr2);
    }
Ejemplo n.º 2
0
    // Use this for initialization
    void Start()
    {
        freeClass      = new FreeClass();
        freeClass.mode = true;

#if UNITY_ANDROID && !UNITY_EDITOR
        path = Path.Combine(Application.persistentDataPath, "SaveProgress.json");
#else
        path = Path.Combine(Application.dataPath, "SaveProgress.json");
#endif
        if (File.Exists(path))
        {
            save = JsonUtility.FromJson <SaveProgress>(File.ReadAllText(path));
        }
        Awake();
    }
    public static int Main()
    {
        // Get addresses of static Age fields.
        IntPtr freePtr1 = FreeClass.AddressOfFreeAge();

        IntPtr fixedPtr1 = FixedClass.AddressOfFixedAge();

        // Garbage collection.
        GC.Collect(3, GCCollectionMode.Forced, true, true);
        GC.WaitForPendingFinalizers();

        // Get addresses of static Age fields after garbage collection.
        IntPtr freePtr2  = FreeClass.AddressOfFreeAge();
        IntPtr fixedPtr2 = FixedClass.AddressOfFixedAge();

        if (freePtr1 != freePtr2 && fixedPtr1 == fixedPtr2)
        {
            return(100);
        }

        return(-1);
    }
Ejemplo n.º 4
0
 public void OnReplay()
 {
     LevelSceneController.freeClass = freeClass;
     Application.LoadLevel("LevelScene");
 }