Exemplo n.º 1
0
    void Awake()
    {
        if (sceneManagerExists)
        {
            Debug.Log("PhysX Scene Manager already exists");
            Destroy(gameObject);
            return;
        }

        IntPtr unalignedMem = Marshal.AllocHGlobal(scratchKilobytes * 1024 + 15);

        scratchMem = new IntPtr(16 * ((unalignedMem.ToInt64() + 15) / 16));

        sceneManagerExists = true;

        GetComponent <PhysicsToggle>().Setup();

        PhysXLib.SetupPhysX();
        PhysXLib.RegisterCollisionCallback(AddCollision);
        PhysXLib.RegisterTriggerCallback(AddTrigger);
        DontDestroyOnLoad(gameObject);
        SceneManager.sceneLoaded   += OnSceneLoaded;
        SceneManager.sceneUnloaded += OnSceneUnloaded;
        PhysXSceneSimulator.AddScene(this);
    }