43 lines
1.4 KiB
C#
43 lines
1.4 KiB
C#
using Com.LuisPedroFonseca.ProCamera2D;
|
|
using System.Collections;
|
|
using System.Collections.Generic;
|
|
using UnityEngine;
|
|
|
|
public class ProCamera2DFollowFocusController : MonoBehaviour {
|
|
[SerializeField] ProCamera2DCameraWindow cameraWindow;
|
|
|
|
[SerializeField] private float boundsChangeX;
|
|
[SerializeField] private float boundsChangeUp;
|
|
[SerializeField] private float boundsChangeDown;
|
|
|
|
float _originalX;
|
|
float _originalY;
|
|
|
|
private void Start() {
|
|
_originalX = cameraWindow.CameraWindowRect.x;
|
|
_originalY = cameraWindow.CameraWindowRect.y;
|
|
}
|
|
|
|
// Update is called once per frame
|
|
void FixedUpdate() {
|
|
if (Input.GetButton("LookLeft")) {
|
|
// Look left
|
|
cameraWindow.CameraWindowRect.x = _originalX + boundsChangeX;
|
|
} else if (Input.GetButton("LookRight")) {
|
|
// Look right
|
|
cameraWindow.CameraWindowRect.x = _originalX - boundsChangeX;
|
|
} else {
|
|
cameraWindow.CameraWindowRect.x = _originalX;
|
|
}
|
|
if (Input.GetButton("LookDown")) {
|
|
// Look down
|
|
cameraWindow.CameraWindowRect.y = _originalY + boundsChangeDown;
|
|
} else if (Input.GetButton("LookUp")) {
|
|
// Look up
|
|
cameraWindow.CameraWindowRect.y = _originalY - boundsChangeUp;
|
|
} else {
|
|
cameraWindow.CameraWindowRect.y = _originalY;
|
|
}
|
|
}
|
|
}
|