public void Dispose() { if (_attached != null) { var placeable = _attached.GetComponent <PlaceObject>(); if (placeable != null) { placeable.Dispose(); } _attached = null; } if (_stateMachine != null) { _stateMachine.Dispose(); _stateMachine = null; } GameObject.Destroy(gameObject); }