Hello,
I'm still working on my inventory system - I keep finding better ways of doing stuff.
My items in the scene are just gameObjects, with a hierarchy of:
Item: (Has Item script)
-- Model
-- Sprite (Has UISprite)
Of course, one should add widgets to a panel otherwise it wouldn't look right - I was wondering if there's a way to create a sprite just like that (outside a panel) - And then when the item is picked, it gets added to my inventory (which has a panel) - I was hoping I could do that, and the sprite would correct itself- Since the item's parent now is a slot in the inventory - But it didn't seem to correct itself too well.
I tried:
sprite.ParentHasChanged();
and:
But none worked
Again, I'm creating the sprite in a gameObject (the item) outside any panel - and then adding the item to the inventory which has a panel. How can I tell the item's sprite to correct itself?
If I can't do that, what's the right approach?
Thanks!
PS: Currently, I have an ItemTemplate reference in my inventory, whenever I add an item, I instantiate that template and add it as a child to the item and then set the atlas and sprite accordingly all in code. But I found that to be a bit of a hassle - I'm really hoping to get it working the way I want (ie create the sprite outside)