I have a gameObject(*GameGrid*) with a Grid Layout Group component, its parent is a gameObject(*GameBox*) with a Vertical Layout Group and his parent is (*MainCanvas*) is a Canvas.
- *GameGrid* = Grid Layout Group
- *GameBox* = Vertical Layout Group
- *MainCanvas* = Canvas
![alt text][2]
I have another gameObject(*Item(0/1/2)*) its parent is (*keyboard1*) with a Grid Layout Group and its parent is a gameObject(*Keyboard*) with a Canvas.
- *keyboard1* = Grid Layout Group
- *Keyboard* = Canvas
![alt text][1]
I have a Drag and Drop script that lets me drag *Item(0/1/2)* to one of *GameGrid*'s children and then changes *Item*'s position to the child's position :
(Script is on GameGrid children)
`eventData.pointerDrag.GetComponent().position = GetComponent().position;` (This works fine)
But when I need to get the children's positions from an other script I can't seem to move *Item* to the right position. It gives me tiny coordinates as well as huge ones.
Why does this work : `eventData.pointerDrag.GetComponent().position = GetComponent().position;`
And not `Item.GetComponent().position = child.GetComponent().position;` ?
I have tried all the solutions that I've found on forums but none of them seem to work for me.
Am I accessing the position badly or am I setting the position badly ? Both ?
[1]: /storage/temp/197727-capture.png
[2]: /storage/temp/197728-capture2.png
↧