Author Topic: Couple questions about NGUI's Inventory System  (Read 3450 times)

MrCottonman

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 2
    • View Profile
Couple questions about NGUI's Inventory System
« on: July 15, 2014, 04:17:24 AM »
Hello,

I have been looking into the Example X scene to kinda understand how the inventory system is setup as I want to do something similar to it in a game that I am making but, there are a couple things that I have been stumped on while trying to re-iterate it and I was wondering if anyone could help.

The First question I have is about the random item script and how to expand upon it. Here is something that I have tried and it works for what it does: http://pastebin.com/GCLqKU88 which I put this on an object and after moving into the area it adds it to the equipment slot and destroys itself but, instead of going to the equipment slot, how do I make it go to the generated Storage Slot from the Backpack and check if the space is occupied so it doesn't write over an existing item?

The Second question I have is about multiple panels within a UIRoot and how to switch between them. I was able to write a script to turn off and on GameObjects (such as the different UIPanels) http://pastebin.com/KBFyN55w but, if I do it this way, items that if I could pick up off the ground and into my bag would most likely disappear due to the UIPanel being turned off by SetActive. Is there a way to set my Inventory Panel out of camera view and bring it in with a key press with/without an animation?

Last question I have is about the item stats that are from the items I made within the Inv Database. How is it possible to setup a Character Stats panel or something were it shows base stats for a character and when I equip an item it changes those stats accordingly and implementing the level range(with xp to increase player level)?

I know it might be too much for one thread and I might have to make separate threads but if you can help I will be grateful.

Aeneas

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 2
    • View Profile
Re: Couple questions about NGUI's Inventory System
« Reply #1 on: July 15, 2014, 10:30:15 AM »
The second question I have also been looking at.

I tried adding different GUI camera's and setting the to render different layers and then changing the layers to render during run time, but that didn't seem to work for me.

Hopefully someone has a better idea to try :)

MrCottonman

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 2
    • View Profile
Re: Couple questions about NGUI's Inventory System
« Reply #2 on: July 15, 2014, 01:49:19 PM »
Whether or not you were looking for other packages, I remember seeing something for NGUI within the asset store called Panel Manager which kinda does what I want but I am trying to see if I can limit coding and such to just NGUI.

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: Couple questions about NGUI's Inventory System
« Reply #3 on: July 15, 2014, 10:52:58 PM »
#2 first: NGUI menu -> Open -> Panel Tool. Click on the panel within the window to select it.

As for #1... the inventory system is outside of NGUI's scope. It's just a quick and dirty thing I put together a long time ago to show how NGUI could be used in a game. It's not meant to be a system that's used in actual games. That said, some people have been doing just that... The idea behind the system is simple: create templates for items, and then you can generate actual game items using the template + desired quality + desired item level. That's what the EquipRandomItem script does. The script then equips it (equipment.Equip(gi)) -- and the 'equipment' is what references the InvEquipment component somewhere. Note how it has Equip, Replace, Unequip etc functions? You could us any of them, or you could go directly to the UIEquipmentSlot instead.