S
S
Sergey Ivanov2019-05-08 12:08:58
Unity
Sergey Ivanov, 2019-05-08 12:08:58

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;
                }

When moving objects around the inventory after closing and opening, they become in their original cells

Answer the question

In order to leave comments, you need to log in

2 answer(s)
F
freeExec, 2019-05-08
@keksmr

So get in your Itemfield to store the position. Sort them by it and only then create inventory pictures.

M
Mikhail Smykov, 2017-04-17
@Chronosms

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'});

This piece of code helped. Thanks for the knowledge of English to the school and to me personally. 17 years old, and not knowing English - it would probably be a shame.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question