Author Topic: List of items with values that change at runtime.  (Read 1616 times)

JonnyDoeInWisco

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 6
    • View Profile
List of items with values that change at runtime.
« on: August 31, 2014, 03:10:56 PM »
Im making my own version of Dope Wars and Im using NGUI to handle many of the actions such as buy/sell, banking, police chases, health, etc. I would like to have a list of items to buy or sell and the prices for each, which would change at runtime at random. If I can figure out how to do that I can do everything else. Im not sure the best way to go about this though and Im looking for suggestions since Im not familiar with all the capabilities of NGUI.

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: List of items with values that change at runtime.
« Reply #1 on: August 31, 2014, 03:25:16 PM »
Create a prefab out of what a single item should look like and attach a script to it that will reference all the important fields such as item name label, price label, etc. You will then instantiate this prefab as many times as you need using NGUITools.AddChild(parent, prefab). After instantiation, GetComponent of the script you wrote, and set the label values accordingly.

JonnyDoeInWisco

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 6
    • View Profile
Re: List of items with values that change at runtime.
« Reply #2 on: August 31, 2014, 04:55:52 PM »
Ok, this is close but not quite there. Im starting out with two options Buy or Sell. When you say press Buy I want it to destroy the Buy Sell options and instantiate the list with randomly generated prices. But I also want to give the option to go back to the Buy Sell options. 

JonnyDoeInWisco

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 6
    • View Profile
Re: List of items with values that change at runtime.
« Reply #3 on: August 31, 2014, 05:52:39 PM »
Figured it out, I made it instantiate the list and destroy parent OnClick. Is there a guide to get people started that gives a general overview?