How to Drag & Drop Camera Position movement ?
public Vector2 dragOrigin;
void start(){
}
void update(){
if(Input.GetMouseButtonDown(0){
dragOrigin = Input.mousePosition;
}
if(Input.GetMouseButton(0)) {
if((transform.position.x > Constants.screenMinX && transform.position.x < Constants.screenMaxX) && (transform.position.y < Constants.screenMaxY && transform.position.y > Constants.screenMinY)) {
Vector3 mpos = Camera.main.ScreenToViewportPoint(Input.mousePosition - dragOrigin);
Vector3 movent = -mpos * (Time.deltaTime * 2.0f);
Vector3 condition = transform.position + movent;
if((condition.x >= (Constants.screenMinX + 0.1f) && condition.x <= (Constants.screenMaxX - 0.1f)) && (condition.y >= (Constants.screenMinY + 0.1f) && condition.y <= (Constants.screenMaxY - 0.1f))) {
transform.Translate(movent, Space.World);
}
}
}
}