- Home /
Screen space camera makes unity UI object loose track of mouse.
So im making a card game and I have to use screen space camera or overlay, just something to give the board a tilt back look. anyway, when I click and drag a card (made with unity UI) the card looks bigger than it needs to be and the card isnt on the mouse its somewhere else in the scene but it still knows its getting dragged please send help!!!!
edit: when you look at it on scene its fits in the cell you want it to, but on game its off
so what object are you scaling size with when doing these two different images? to me it appears the 1 set of images remain the same the background is scaling bigger and smaller. I'd try to place all the objects on the background and try and scale again. the background should be on a canvas
I was having a scaling issue with my title when scaling it was moving up and down and not staying in place, to fix i placed on an empty game object and locked that objects pivot to top and center, then the title text components is expanded to full on that game objects position. How i did this was the object was placed on my background in the same position as my current text component position, i just copied the transform and pasted it on empty object. Then i dragged my title text onto it and reset it to 0,0,0,0. The perimeter is where i want my whole text component to display. The size i wanted was as wide as my canvas and 1/4 the top of it, so i could use this obj as a boundary area. that solved my title problem. title remained at top and scaled with canvas along with the buttons, though because the buttons are not on objects like the title, the don't scale the same, but the effect i personally was looking for.
Answer by prototyped · Feb 19, 2019 at 02:52 AM
did more digging found this link to be more than helpful https://answers.unity.com/questions/1063429/problem-moving-a-gameobject-with-an-ondrag-event-w.html
Glad you could find a solution. there are many ways to do things, it's just which way works best for you.
Also more on this in this question from the day before you
https://answers.unity.com/questions/1602884/scale-ui-text.html?childToView=1602982#answer-1602982
Answer by zereda-games · Feb 18, 2019 at 08:18 PM
This can be cause when a parent of a child is change in size and the children are set to expand with the parent by means of it's Pivot Points If you don't want it to scale to the parent have the local Anchor centered, otherwise adjust the Anchors to where it works for your purposes.
Okay so in scene it is lined up fine in game its not heres some shots ill also update the question and thanks for the fast reply.
Your answer
Follow this Question
Related Questions
Camera preview different from when actually running the game? 0 Answers
Why use different Canvas Render Modes 0 Answers
Keep camera perfectly in box and scaled to fit view 0 Answers
How to render canvas with screen space - camera on top of canvas with screen space - overlay? 2 Answers
Canvas is hiding my 3D model, can I place the model in front of the canvas? 1 Answer