private void Awake() { _rb = (Rigidbody)NullChecker.TryGet <Rigidbody>(gameObject); _rb.constraints = RigidbodyConstraints.FreezePositionZ; _rb.freezeRotation = true; _rb.useGravity = false; }
private void Awake() { Collider collider = (BoxCollider)NullChecker.TryGet <BoxCollider>(gameObject); _boundaryWrapDistance = collider.bounds.size.x * _collisionScale; _rb = (Rigidbody)NullChecker.TryGet <Rigidbody>(gameObject); _rb.constraints = RigidbodyConstraints.FreezePositionZ; _rb.freezeRotation = true; _rb.useGravity = false; }
private void Start() { _constants = (IConstants)NullChecker .TryFind <Constants>(Tags.Constants, gameObject); _gameController = (IGameController)NullChecker .TryFind <GameController>(Tags.GameController, gameObject); _cube = GameObject.FindWithTag(Tags.Cube); if (_cube == null) { _cube = new GameObject(); _cube.AddComponent <CubeHandler>(); } _offset = _cube.GetComponent <Collider>().bounds.size.x *_collisionScale; _cubeEmitters = NullChecker.TryGet(GameObject.FindGameObjectsWithTag(Tags.CubeEmitter)); _emitterProperties = new EmitterProperties(_constants, _offset); SetEmitterPositions(); StartCoroutine(EmitCubes()); }
public void TryGet_NullGameObject_ReturnsNull() { var result = NullChecker.TryGet <Rigidbody>(null); Assert.That(result, Is.Null); }
public void TryGet_GameObject_ReturnsComponent() { var result = NullChecker.TryGet <Rigidbody>(new GameObject()); Assert.That(result, Is.TypeOf <Rigidbody>()); }