12345678910111213141516171819202122232425262728 |
- using UnityEngine;
- using System.Collections;
- public class CameraRect : MonoBehaviour {
- private InputController inputController;
- private RectTransform rectTrans;
- public void init(InputController inputController)
- {
- this.inputController = inputController;
- rectTrans = this.GetComponent<RectTransform>();
- }
- // Update is called once per frame
- void FixedUpdate ()
- {
- Vector3 position = inputController.cameraPosition;
- int col = (int)NumberUtil.forceBetween(position.x/Map.TILE_WIDTH, 0, 128f);
- int row = (int)NumberUtil.forceBetween((position.z)/Map.TILE_LENGTH, 0, 128f);
- Vector3 pos = rectTrans.localPosition;
- pos.x = MiniMap.offsetX+col;
- pos.y = MiniMap.offsetY+row;
- rectTrans.localPosition = pos;
- }
- }
|