Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 13 Next capture
2021 2022 2023
1 capture
13 Jun 22 - 13 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
1
Question by Alanimator · Jan 22, 2014 at 09:16 PM · c#textassetbundlestringdictionary

Populating Dictionary at run-time from .txt file on imported asset bundle

I have created a software that will create a dictionary in C# structure for unity.....or any other format .

I came across a problem right away when trying to implement a similar method od creating a dictionary in unity.

 if(GameObject.Find("ImportedBundle"))// This is the bundle that was imported and instantiated 
         {
             string thetext;
             thetext = GameObject.Find("ImportedBundle").GetComponent<txtFile>().text;
                 foreach(string line in thetext )
             {
 
             }
         }

seeing as 'txtFile' or 'ImportedBundle' wont exist until the bungle is imported i end up getting an error which seems almost inevitable.

i wrote a code in .net which takes in lines of string like this

'hello this is my shoes_up_car_van_truck' 'hello who are you_aHand_pen_comb_fork'

and using this.net code

  For Each line As String In Text1.Lines
 
             For Each st As String In line.Split("_")
                 TextBox1.Text = ReplaceFirst(TextBox1.Text, "_", st)
 
             Next st
             Text2.Text += TextBox1.Text + _
         Environment.NewLine
             
 
         Next

I will get this result

    dictionary.Add("hello this is my shoes", new string[] {"up", "car","van(A)","truck"});
 
     dictionary.Add("hello who are you", new string[] {"aHand", "pen","comb","fork"});


i will get this result which works fine for C# .

but now I need to populate the dictionary directly from a .txt file at runtime from a instantiated asset bundle which has a .txt file attached to it

needless to say I NEED help . how can i get this to work ?

Comment
Add comment · Show 1
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 rutter · Jan 22, 2014 at 09:46 PM 1
Share

Defining new script classes in an AssetBundle is difficult (read: not quite impossible). In your case, it seems like it would be much easier to embed a TextAsset and work with the file's contents directly.

0 Replies

· Add your reply
  • Sort: 

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

19 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 avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

How do I create a Key and Values Dictionary array in C# 1 Answer

Changing a text equal to a string variable 1 Answer

Multiple Cars not working 1 Answer

Change alpha color of specific letter in a Text UI with C# 2 Answers

How to check if the string is on a text file 0 Answers


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