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; } }
private void Zoom() { if (_camera == null) { _camera = GetComponent <Camera>(); } var objectToView = transform.parent.transform; if (objectToView == null) { return; } var objs = objectToView.GetComponentsInChildren <Renderer>(); var bounds = objs[0].bounds; for (int i = 1; i < objs.Length; i++) { bounds.Encapsulate(objs[i].bounds); } var dir = SpriteFacingControl.GetCameraSide(SpriteFacing.Eightway, objectToView, objectToView, 0f, out var inMargin); SpriteFacingControl.SetCameraPos(Camera, dir, _viewOffset, 0f); if (main._debug) { DebugExtension.DebugBounds(bounds, Color.red, 5f); } Zoom(bounds); PositionBottom(objectToView.transform.position); }
private void UpdateBillboard(SpriteBillboardComponent billboard, Transform baseTr, Transform spriteTr, bool backwards) { billboard.Billboard.Apply(spriteTr, backwards, ref billboard.LastAngleHeight); var orientation = SpriteFacingControl.GetCameraSide(billboard.Facing, spriteTr, baseTr, 5, out var inMargin); if (!inMargin || !(orientation.IsAdjacent(billboard.Orientation))) { billboard.Orientation = orientation; } }
private IEnumerator TestAnimationRunnerBounds() { _spriteAnimator.ResetAnimation(_sprite); UpdateSpriteFrame(); int noCam = 0; _spriteCollider = _renderer.GetComponent <SpriteCollider>(); if (_spriteCollider != null) { _spriteCollider.OnCreate(null); } while (_spriteAnimator.Active) { if (!_looping) { break; } if (Camera.current == null) { yield return(null); noCam++; if (noCam > 500) { break; } continue; } Game.SpriteCamera = Camera.current; noCam = 0; var orientation = SpriteFacingControl.GetCameraSide(_facing, transform, transform, 5, out var inMargin); _billboard.Apply(_renderer.transform, _backwards, ref _lastAngleHeight); if (_spriteAnimator.CheckFrameUpdate()) { UpdateSpriteFrame(); } else if (_orientation != orientation && (!inMargin || (!orientation.IsAdjacent(_orientation)))) { _orientation = orientation; UpdateSpriteFrame(); } if (!_spriteAnimator.Active && _looping) { _spriteAnimator.ResetAnimation(_sprite); } if (_spriteCollider != null) { _spriteCollider.UpdateCollider(); } yield return(null); } }
private void UpdateNode(ref DirectionalSpriteNode node) { node.Animator.Billboard.Apply(node.Renderer.SpriteTr, node.Animator.Backwards, ref node.Animator.LastAngleHeight); if (node.Animator.Requests.Count > 0) { var request = node.Animator.Requests[0]; if (node.Animator.Requests.Count > 1) { for (int r = 1; r < node.Animator.Requests.Count; r++) { if (!request.OverrideClip && node.Animator.Requests[r].OverrideClip) { request = node.Animator.Requests[r]; } } } #if DEBUG DebugLog.Add("Playing " + request.Clip + " for " + node.Entity.DebugId); #endif node.PlayAnimation(request.Clip, request.OverrideClip); node.Animator.Requests.Clear(); } if (node.Animator.CurrentClipHolder == null || node.Animator.IsSimpleClip) { node.CheckMoving(); } var orientation = SpriteFacingControl.GetCameraSide(node.Animator.Facing, node.Renderer.SpriteTr, node.Renderer.BaseTr, 5, out var inMargin); if (node.Animator.Orientation == orientation || (inMargin && (orientation.IsAdjacent(node.Animator.Orientation)))) { if (node.CheckFrameUpdate()) { node.UpdateSpriteFrame(); } return; } node.Animator.Orientation = orientation; node.CheckFrameUpdate(); node.UpdateSpriteFrame(); }
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(); }
public static void TakePicture(Transform parent, Bounds bounds, DirectionsEight dir, RenderTexture texture) { Camera.enabled = true; Camera.transform.parent = parent; Camera.targetTexture = texture; SpriteFacingControl.SetCameraPos(Camera, dir, main._viewOffset, 0f); if (main._debug) { DebugExtension.DebugArrow(Camera.transform.position, Camera.transform.forward, Color.blue, 5f); } main.Zoom(bounds); main.PositionBottom(parent.position); _canvasHackField.SetValue(null, null); Camera.Render(); _canvasHackField.SetValue(null, _canvasHackObject); Camera.Render(); Camera.enabled = false; //Camera.targetTexture = null; Camera.transform.parent = null; }
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(); }