- Home /
Grid Layout Group: draw sprite on top of selected item
I'm using a Grid Layout Group to give me flexibility on how multiple objects are displayed. When the player taps/selects one of the objects, I need to draw a sprite on top of that object. (I don't want to replace the existing sprite in that object.)
I've read that to draw a second sprite on top of an existing object, I need to create a second game object and instantiate it at the location of the first object (I guess this will display the two sprites on top of each other).
When I try the following code, the new game object is displayed at the next available slot in the grid, instead of displaying the new object at the same location as the tapped/selected object.
Vector3 _thisPosition = this.transform.position; // get location of tapped object (this)
Transform _newSelection = Instantiate(this.transform, _thisPosition, Quaternion.identity, parentTransform);
_newSelection.transform.SetParent (parentTransform, false); // in case it helped, it didn't
Does the Grid Layout Group take complete position control of all objects added to it, so that I can't draw two objects in one location?
Or, am I doing something wrong?
Your answer
![](https://koobas.hobune.stream/wayback/20220612141438im_/https://answers.unity.com/themes/thub/images/avi.jpg)
Follow this Question
Related Questions
2D Layout + 2D Spritesheets 0 Answers
How do I force layout group to size all images with same width, no matter how the image is sliced? 0 Answers
Making sprites just rotate and not tilt. 3 Answers
How do you flip a enemy sprite so its facing the player when you get close. 1 Answer
Unity2D Sprite Fade In and Out 3 Answers