void Update()
        {
            if (!_active)
            {
                return;
            }
            _billboard.Apply(_renderer.transform, _backwards, ref _lastAngleHeight);
            bool inMargin;
            var  orientation = SpriteFacingControl.GetCameraSide(_facing, transform, transform.parent, 5, out inMargin);

            if (_orientation == orientation || (inMargin && (orientation.IsAdjacent(_orientation))))
            {
                return;
            }
            _orientation = orientation;
            var facing = orientation;

            if (_facing.RequiresFlipping())
            {
                facing          = _orientation.GetFlippedSide();
                _renderer.flipX = _orientation.IsFlipped();
            }
            var sprite = _sprite.GetFacingSprite(facing);

            if (sprite != null)
            {
                _renderer.sprite = sprite;
            }
        }
Exemplo n.º 2
0
        public void OnSystemUpdate(float dt)
        {
            if (!_active)
            {
                return;
            }
            _billboard.Apply(_renderer.transform, _backwards, ref _lastAngleHeight);
            var orientation = SpriteFacingControl.GetCameraSide(_facing, transform, transform.parent, 5, out var inMargin);

            if (_orientation == orientation || (inMargin && (orientation.IsAdjacent(_orientation))))
            {
                if (_spriteAnimator.CheckFrameUpdate())
                {
                    UpdateSpriteFrame();
                }
                return;
            }
            _orientation = orientation;
            UpdateSpriteFrame();
        }
        void Update()
        {
            if (!_active)
            {
                return;
            }
            if (_spriteAnimator.CheckFrameUpdate())
            {
                UpdateSpriteFrame();
            }
            _billboard.Apply(transform, _backwards);
            bool inMargin;
            var  orientation = SpriteFacingControl.GetCameraSide(_facing, transform, transform.parent, 5, out inMargin);

            if (_orientation == orientation || (inMargin && (orientation.IsAdjacent(_orientation))))
            {
                return;
            }
            _orientation = orientation;
            UpdateSpriteFrame();
        }