Author Topic: populate fields in one database w/names from another?  (Read 9270 times)

amaranth

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 21
    • View Profile
populate fields in one database w/names from another?
« on: July 10, 2012, 06:45:47 PM »
I'm working on two inspector scripts that let the designer (a) create a list of states in one inspector, then (b) populate these states in another inspector where weapons are created. 

From your sample inventory scripts (awesome!!!), I see how to do this using an enum, but since my list of states is created through the inspector and can change w/o going into the scripts, I'm not sure what to use. Any hints?

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: populate fields in one database w/names from another?
« Reply #1 on: July 10, 2012, 10:36:30 PM »
Not exactly an NGUI question, but you can display a drop-down list using a custom array of strings instead. I do that to display layer masks within the camera tool for example.

JRoch

  • Full Member
  • ***
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 140
    • View Profile
Re: populate fields in one database w/names from another?
« Reply #2 on: July 11, 2012, 04:10:46 AM »
I haven't delved that deeply into Mono functions that come from .NET yet, but you likely would want to (if they work properly) use DataTable structures (which are essentially SQL db tables that are just stored in memory) in combination with reading/writing the data from/to XML files.  And, yes, this is a slightly advanced topic that has nothing to do with NGUI.

If you aren't into DataTables and SQL, you could also write your own classes in script, and manage all of the objects within collections/lists/hashtables.  However, then you bear the brunt of file I/O if you need to read/write the contents of those classes to storage.  Having innate read/write XML is an awfully nice feature of DataTables.

Read about System.Data.DataTable here: 
http://msdn.microsoft.com/en-us/library/system.data.datatable(v=vs.80).aspx

amaranth

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 21
    • View Profile
Re: populate fields in one database w/names from another?
« Reply #3 on: July 11, 2012, 12:32:25 PM »
Thank you for answering even though it's not NGUI. Checking out both ways. :)

JRoch

  • Full Member
  • ***
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 140
    • View Profile
Re: populate fields in one database w/names from another?
« Reply #4 on: July 12, 2012, 04:46:53 PM »
I'll amend my prior response now that I've actually looked up the compatibility matrix in Mono.  Turns out that System.Data isn't a namespace that is implemented in Mono, so ignore my ravings about using DataTables in Unity.

joreldraw

  • Guest
Re: populate fields in one database w/names from another?
« Reply #5 on: July 13, 2012, 05:31:12 AM »
You need to Copy System.Data.dll file in your asset folder.

JRoch

  • Full Member
  • ***
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 140
    • View Profile
Re: populate fields in one database w/names from another?
« Reply #6 on: July 13, 2012, 06:29:25 PM »
Is that platform specific?  Or is there a Mono version of the .dll that works on all supported platforms?

joreldraw

  • Guest
Re: populate fields in one database w/names from another?
« Reply #7 on: July 23, 2012, 06:10:24 AM »
Is .Net Framework