Answer the question
In order to leave comments, you need to log in
Unity how to save positions of objects in inventory?
List<Item> list;
int count = list.Count;
for (int i = 0; i < count; i++)
{
Item it = list[i];
if (inventory.transform.GetChild(1).childCount >= i)
{
GameObject img = Instantiate(container);
img.transform.SetParent(inventory.transform.GetChild(1).GetChild(i).transform);
img.GetComponent<Image>().sprite = Resources.Load<Sprite>(it.sprite);
img.GetComponent<Drag>().item = it;
}
else break;
}
Answer the question
In order to leave comments, you need to log in
So get in your Item
field to store the position. Sort them by it and only then create inventory pictures.
Router.onBeforeAction( Iron.Router.bodyParser.json(), {except: ['creditReferral'], where: 'server'});
Router.onBeforeAction( Iron.Router.bodyParser.raw({type: '*/*', only: ['creditReferral'],
verify: function(req, res, body){
req.rawBody = body.toString();
}, where: 'server'}));
Router.onBeforeAction( Iron.Router.bodyParser.urlencoded({ extended: false }), {where: 'server'});
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question