Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 12 Next capture
2021 2022 2023
1 capture
12 Jun 22 - 12 Jun 22
sparklines
Close Help
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
avatar image
0
Question by jonander · Jan 24, 2017 at 11:19 AM · c#instantiatearrayunityeditordatabase

How can i create [n] prefabs taking Array data?

I have a table in a local database which contains a mini-Market Stock data .svc inport.

I need to take all the database information, and set it in a unity table.

I want to create a prefab containing 4 text-fields and setting the database info in those fields, and create 1 prefab for each array(there is 1 array for each line on the database)

Here is my script

 public string[] items;

 // Use this for initialization
 IEnumerator Start () 
 {
     WWW itemsData = new WWW ("http://localhost/inventario_iraule/Leer_Stock_Ropa_2016.php");
     yield return itemsData;
     string itemsDataString = itemsData.text;
     //print (itemsDataString);
     items = itemsDataString.Split (';');
     for (int i = 0; i < items.Length; i++) 
     {
         print (GetDataValue (items [i], "Rotulos_fila:"));
     }
 }

 string GetDataValue(string data, string index)
 {
     string value = data.Substring (data.IndexOf (index) + index.Length);
     if(value.Contains("|"))value = value.Remove (value.IndexOf ("|"));
     return value;
 }

Okey, i get all the data, and i have a index to search about specific data, but.. i don't know how to continue with these..

expected that the solution was creating 1 Php file for each column in the database, for filter all the information, but i'm sure there's a easier way to do it.

My objective is to show all the database info organized in unity. And i don't know how to "separate" the whoole array in a lot of game-objects(prefabs) or Text-fields.

Thank you so much for reading.

Hope someone can help me

Comment
Add comment · Show 2
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image GarretLawrence · Jan 24, 2017 at 01:19 PM 1
Share

I'm not quite understand what is your problem.

So atm you can get all info from db, what do you want to do with them?

Fill them into 4 textfields like :

$$anonymous$$enu 1 : X , Y , Z , W $$anonymous$$enu 2 : A, B , C, D

Is that what you want?

What about A prefab for each array? I don't understand....

If you can use $$anonymous$$mviewer, it would be easier for me to help you.

avatar image jonander GarretLawrence · Jan 25, 2017 at 02:51 PM 0
Share

Thanks for your help men, I have already solved my problem. But as you know is a world full of problems that you have to face, we will read again :P

1 Reply

· Add your reply
  • Sort: 
avatar image
1
Best Answer

Answer by Deliboyz · Jan 25, 2017 at 09:09 AM

 public Text Textbox;

 public Transform DesiredTransform;

 for(int i = 0; i < items.Length; i++) 

 {

 Text TextElement = Instantiate(Textbox) as Text;

 TextElement.transform.SetParent(DesiredTransform);

 TextElement.text = items[i];

 }
Comment
Add comment · Show 2 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image jonander · Jan 25, 2017 at 02:47 PM 0
Share

Thank you very much broo', so quick answer,

That's exactly what i was looking for!

I'm working so hard with this, and You helped me take another step!

Sorry for my bad English xD

avatar image Deliboyz jonander · Jan 25, 2017 at 02:52 PM 0
Share

No problem :)

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this Question

Answers Answers and Comments

10 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

Can´t instantiate objects in list correctly 1 Answer

Cycle Through GameObjects in Array Issue. 1 Answer

Prefabs instantiated from an array are keeping their public int value 1 Answer

Multiple Cars not working 1 Answer

C# How to Find the Height of an Instantiated GameObject in an Array? 1 Answer


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges