Question On Inventory System

Discussions, Solutions & How To with Inventory
Khazzack
Posts: 4
Joined: 18 May 2014, 20:35

Question On Inventory System

Postby Khazzack » 18 May 2014, 20:53

Hello there.
Been looking at this for a while. But before I purchase, I would like a few questions answered ;)

I will be adding a crafting system using this inventory system as a base layer, as it seems to fit ALOT of my needs.

- How easy is it to add / remove items from the inventory through scripting?

- Can you stack items with this? I did not see it from the video, and if not, could you provide support in helping certain items stack.

I have tried making a crafting system from another Inventory system, but there was no way to check what stacks you had in your inventory for each item through scripting, so manipulating these variables is near impossible for me to work with that system, so i'm looking for one that does keep track of everything in your inventory, items / stacks / id and different statistics the items have. Does yours do this?

Thanks in advance :)

User avatar
Adam
Site Admin
Posts: 106
Joined: 07 Aug 2009, 14:54
Location: London, UK
Contact:

Re: Question On Inventory System

Postby Adam » 20 May 2014, 12:30

Adding and Removing items from the inventory system can easily be hooked into as this is done already though the system when looting (AddItem), using or destroying (RemoveItem).

These should not change for the upcoming v3 release.

I will be changing the system form OnGUI to uGUI. There are some basic struggles changing from an immediate mode UI (OnGUI) to a persistent UI (uGUI), which is based on sprites and prefabs.

If you go ahead and get this version, I'll help you out as much as possible integrating it. I'm sure it'll help me see how people use the system. If something needs changing, I'll help you with that - and integrate that if needed into the next release.

Khazzack
Posts: 4
Joined: 18 May 2014, 20:35

Re: Question On Inventory System

Postby Khazzack » 21 May 2014, 10:48

And you can easily check what's in the inventory during run time... For exmaple, If I needed to check if the player has like 5 wood and 5 stone, then if true, remove the items and spawn a Stone Axe into the inventory.

Also, you didn't specify if I can already have stacked items? Or would I have to code this myself?

Well so far i've only used OnGUI, but I guess when the new version is released I can always give uGUI a go and see where I stand with it.

Thanks in advanced :)

User avatar
Adam
Site Admin
Posts: 106
Joined: 07 Aug 2009, 14:54
Location: London, UK
Contact:

Re: Question On Inventory System

Postby Adam » 21 May 2014, 15:03

uGUI is in active Beta now, targeting 4.6.

You can see a sneak peek of it here:
http://unity3d.com/learn/tutorials/modu ... h-game-pt2

Currently, I don't have stacks built in, but it is on the road map. This is planned to be in the v3 for uGUI release.

Checking content: I have not looked at that part of the code recently, but I know it can be done. I had a test quest system hooked up to this where the quest system looked at the inventory and the player could only complete a quest when certain objects or certain number of objects were in the inventory. When completing the quest, the quest system removed the items from the inventory.

This is essentially the same mechanic as the crafting system. You want to "do something" that is predicated on the success of an item count, and when the "something is done" the items are removed.

Version 2 (for OnGUI) also had a prototype bank and shop system, as these are essentially a form of protected lootable object.

Using OnGUI, the paradigm is to feed basic bits to the system: slot images, etc. and then OnGUI will build it.

In uGUI, the system is based on PreFabs. The system will include a sample prefab setup for the Inventory GUI, which you can use or modify.

The nice thing about it, is it's nicely anchored and scales, so you don't have to rewrite the UI for every resolution.

Khazzack
Posts: 4
Joined: 18 May 2014, 20:35

Re: Question On Inventory System

Postby Khazzack » 25 May 2014, 08:10

Sounds good. I bought the C# version now, just so I can have a little mess around. Will the v3 uGUI be free to upgrade, or would it be a separate purchase?

Alright, well i'm going to be scanning your code from top to bottom ;)

That's the one thing i've hated about unity... The GUI and resolution. I mean, even if you used Screen.height and other ways to do the resolution, there was also something that would go wrong and not look right at a different resolution, maybe it was just me ;P

Any idea's how well this would work for multi-player. Is there some code that already pre-defines certain functions that would make it hard to manipulate for different instances of this system at the same time? Or as long as we did the networking instantiate and setup part fine, there should be no trouble?
( You may have not tested this at all or even thought about it, but with your experience you may be able to foresee or predict problems ;P )

Sorry for the 100 questions, but I got one more ;P
Back to the multiplayer thing, if a player was killed using this inventory system, is the whole inventory saved or stored somewhere, where I could reference or copy it over onto a" loot-able" window.

Cheers for your ongoing help :)

User avatar
Adam
Site Admin
Posts: 106
Joined: 07 Aug 2009, 14:54
Location: London, UK
Contact:

Re: Question On Inventory System

Postby Adam » 29 May 2014, 11:33

Absolutely a free upgrade!

And, if you want, I can let you test the work in progress on a beta of Unity 4.6 when v3 is more ready. Being that this code is so old and I've learned so much since I created that system, I'm making huge improvements.

When it comes to resolution, in uGUI, there is anchor, and there is also stretch, and stretch with preserved aspect ratio - which acts as a scale - so the UI should be deployable on any device, and *should* also support different monitor resolutions and aspect ratios.

You can see the most current blog post here:
http://blogs.unity3d.com/2014/05/28/ove ... ui-system/

I'm somewhat embarrassed by that OnGUI code, as it's so nested.

TBH, I put development on hold for Inventory Manager when Unity announced the new GUI system coming "soon"... in late 2.x! :-/

Well, as promised, development has restarted now that we have a new UI framework.

When it comes to network instantiating the system, it should be driven by the client's resolution. The "canvas" looks at either the screen-space (there are two types) or world space (in the case of lootable objects, etc.); so you should be able to just instantiate the UI as part of the scene and it will work, if the anchoring and scaling is setup correctly.

Saving: I have not implemented a specific "save" function per se, as every developer will have a unique way of saving their game - whether this is a 3rd party solution (say from the asset store) or a "roll your own".

In the current implementation you have, it is simply an instantiated list.

I am considering using a ScriptableObject of some sort to hold this, but as saving is very unique per game, it's not the first thing on my list. v3 will ship with some obvious place to have the inventory that can be serialised and saved by the game's developer.

Please ask any questions, as it will give me an insight into what people need, and give me a light as I dust off code and brush away cobwebs...

User avatar
Adam
Site Admin
Posts: 106
Joined: 07 Aug 2009, 14:54
Location: London, UK
Contact:

Re: Question On Inventory System

Postby Adam » 02 Jun 2014, 22:04

Just an update, as I've been plugging away at this when I can...

The Framework is well underway in uGUI.

uGUI is so flexible, I have draggable, resizable windows that can be used for any of the panels. Currently, it works best for the Inventory itself, so you can size this as needed.

The basic inventory functionality is there, I just need to hook this up to be a little more seamless, and then you can have a test if you'd like.


Return to “Inventory (for Unity Gui)”

Who is online

Users browsing this forum: No registered users and 1 guest