public void Init(string text) { // InitPosition remove = false; characterController = GetComponentInChildren <GuiCharacterController>(); transform.position = GetPosition(startScreenX, startScreenY, startOffsetX, startOffsetY); startPos = transform.position; endPos = GetPosition(endScreenX, endScreenY, endOffsetX, endOffsetY); removePos = GetPosition(removeScreenX, removeScreenY, endOffsetX, endOffsetY); easeFunction = easeFunctionIn; seconds = secondsIn; isMoving = true; t = 0; characterController.Show(text); }
public virtual void ShowTextBox(string text) { if (!isInit) { Init(); } charController = transform.GetComponentInChildren <GuiCharacterController>(); bgrController = transform.GetComponentInChildren <GuiSimpleCharacterBackgroundController>(); charController.Show(text); Vector2 sizeBox = bgrController.GetSize(); Vector3 favoritePosition = new Vector3(transform.parent.position.x + offsetX, transform.parent.position.y + offsetY + (sizeBox.y / 2F), transform.parent.position.z); float minX = favoritePosition.x - (sizeBox.x / 2F); float maxX = favoritePosition.x + (sizeBox.x / 2F); Vector2 cameraLeft = Camera.main.ViewportToWorldPoint(new Vector3(0F, 0F, 0)); Vector2 cameraRight = Camera.main.ViewportToWorldPoint(new Vector3(1F, 0F, 0)); float distanceLeft = (minX - cameraLeft.x); float distanceRight = (cameraRight.x - maxX); if (distanceLeft < 0) { // nach rechts verschieben favoritePosition = new Vector3(favoritePosition.x + Mathf.Abs(distanceLeft), favoritePosition.y, favoritePosition.z); bgrController.MoveArrowLeft(distanceLeft); } if (distanceRight < 0) { // nach rechts verschieben favoritePosition = new Vector3(favoritePosition.x - Mathf.Abs(distanceRight), favoritePosition.y, favoritePosition.z); bgrController.MoveArrowRight(distanceRight); } transform.position = favoritePosition; }
// Start is called before the first frame update void Start() { charController = transform.GetComponentInChildren <GuiCharacterController>(); charController.Show(text); }