I’m trying to code a game like hearthstone. Every time the player earns a new card I instatiate a “carta” (card) prefab with the hierarchy shown in the image.
I would like to instatiate every earned card a little bit to the right of the previous card but when I try to move the GameObject transform.position nothing happens, because it has a canvas I guess.
Because of that I’m trying to move the card by the child panel RectTransform, But I don’t know how to do it via script and if it’s the best way to do the thing that I want.
Any help is welcome.
The translation of the image is: Card-Canvas-Card Panel-Mask-Image-Card frame-Description-Bottom left text-bottom right text-card title text
It might be because you have a layout item driving its position however.
Be sure you do NOT use magical numbers for anything in UI because at different resolutions and aspect ratios, your layout will become incorrect. Instead always use anchors and invisible objects placed in scene to drive positions, spacings, etc. dynamically.
I was just looking at this on friday, as I had forgotten the inspector for the RectTransform changes what it displays based on what it thinks makes it easier to edit manually, and what it shows aren’t actually accessible fields. If you set the inspector to Debug mode, you get a better view of what is happening and what you can edit. But you’re probably going to be looking at RectTransform.localPosition.