#Update: Rotation issue is fixed, but
1 messages · Page 1 of 1 (latest)
What does the targetImage inspector look like now?
Laying Bottle is target
Can you record the issue again, but include the entire Unity editor.. with targetImage selected showing its inspector and make sure the hierarchy is visible
Let me knopw if you need more. This is starting in game mode
test something..
Go into play mode -> grab the bottle and pause it -> change the width of that rect to 70
or just change that rect to 70 before grabbingn the bottle
probably just need to click 'preserve aspect' on the image components
Ok, so I notice changing x value changes for both A & B within the drag
Preserve aspect worked!
because they're different sized sprites, your image rect is set to fit the laying down bottle... when you switch the standing bottle, it's stretching to fit the rect. Preserving the aspect stops it stretching to fit, and keeps it at the correct aspect ratio to fit within the bounds of the rect
The standing bottle is a little smaller though
also, FYI - you don't need GameObject imageBObject. Every component can access the gameobject. so, you can just do targetImage.gameObject.SetActive() .. that way you don't need to assign two things in the inspector leading to a possible mistake
yes, because of the height of the laying down bottle is set to smaller
Is it possible to increase the standing while keeping the laying?
Also I plan for the books laying in the locker to stand up upon grabbing (same as blue one)
You'd be better off having..
- Parent object with an invisble image sized to what you want (set the colour alpha to 0)
- two children objects, one for each bottle
- toggle the correct bottle on/ off for when grabbed etc
the two child would just have an image component on them
Does that mean the code would need to be altered?
A little bit.
You won't need any of the sprite swapping, and you'll need references to the two new game objects to toggle