protected virtual void OnDestroy() { if (_constraint != null) { BulletPhysicsWorldManager.Unregister(_constraint); Dispose(); } }
//Unity OnDisable protected override void OnDisable() { //Check if registered //TODO: See OnEnable() if (!Registered || !Initialized) { return; } //Unregister from the physics world if (!Initialized) { return; } BulletPhysicsWorldManager.Unregister(BodyInstance); Registered = false; }
/// <summary> /// Disposes of the RigidBody /// Should only be called internally or from a physics world instance. /// </summary> public override void Dispose() { //Dispose of all the components in reverse order if (Disposing) { return; } if (Registered) { BulletPhysicsWorldManager.Unregister(_staticBody); } Disposing = true; _staticBody?.Dispose(); _constructionInfo?.Dispose(); PhysicsCollisionShape?.Dispose(); }