Answer the question
In order to leave comments, you need to log in
How to calculate the center of the position when zoomed in?
Here I have a panel, I can move it and delete / zoom in, the problem is that if you delete / zoom in the center, then the object that is in the center and remains in the center, but if you move the panel to the side and start increasing the object by of course, the screen will visually shift, so I’m thinking how to make the center stay in place when zoomed in, that is, moved to the side, focused on some object, I zoom in and this object also remains in the center, although it may not be an object but just empty space.
Give me an idea how this can be calculated...
What I have:
canvas: render mode -> screen overlay, UI Scale Mode -> Scale Width Screen
Panel: script on it
public void OnDrag(PointerEventData eventData){
this.transform.Translate(eventData.delta);
}
void Update(){
if(Input.GetAxis("Mouse ScrollWheel") != 0){
if(Input.GetAxis("Mouse ScrollWheel") > 0) MapScale = MapScale + 0.05f; else MapScale = MapScale - 0.05f;
this.transform.localScale = new Vector3(MapScale, MapScale, 1f);
}
}
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question