Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 11 Next capture
2021 2022 2023
1 capture
11 Jun 22 - 11 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 Quartsik · Aug 09, 2015 at 12:06 PM · textspawn

How can i split text file in unity and then spawn it as UI TEXT in game?

For example, I have a text file: small little girl lived in deep space. Her parents died, when she was three years old, since that time, she´s browsing space around her, finding new friends.

I need to spawn this text by words with one second delay...

it´s also can be done by creating new game object for each word, but i am sure, that it can be more easily..

it should works like this :

Small (1sec) little (1sec) girl (1sec)

lived(1sec) etc...

Thank you for answer

Comment
Add comment
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

3 Replies

· Add your reply
  • Sort: 
avatar image
0

Answer by stepan-stulov · Aug 09, 2015 at 12:35 PM

 [SerializeField] private TextAsset _myTextAsset;
 List<string> words = _myTextAsset.text.split(" ").ToList();

And then run some sort of timer or coroutine over the words list storing current index.

Comment
Add comment · Show 1 · 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 Quartsik · Aug 22, 2015 at 09:44 AM 0
Share

Thank you... i tried to do it as you say, but i have problem.. i am new in unity, so sorry, if my question is stupid... but is it possible to instantiate new text object directly from script? for example to do something like this? i didn't make a coroutine yet, but i know, how to make it.. =]

List words = _myTextAsset.text.split(" ").ToList();

     public float distanceX; // space between words
     public float distanceY; // space between lines
     public float endOfLine$$anonymous$$ultiplier; // multiplier for word.length 
     public float endOfLineIdentifier; // identifying end of line
     
     private float defaultYtransform;
     private float defaultXtransform;
     private float previousXTransform;
     private float previousYTransform;
     
     
     foreach string word in words // going throw list
 {
      private text = new TextObject;
      text = word;
      
         if (endOfLineIdentifier >= (previousXTransform + distanceX + word.Length * endOfLine$$anonymous$$ultiplier)) // if end of line != 1 write word to this line
     {
         text.Transform =  (previousXTransform + distanceX + word.Length * endOfLine$$anonymous$$ultiplier, previousYTransform , 0)
     }
         else // if end of line = 1 , return to start of second line 
     {
         text.Transform = (defaultXtransform,defaultYtransform + distanceY,0)
         defaultYtransform = (defaultYtransform + distanceY)
     }
 
     Instantiate text;
    

   
avatar image
0

Answer by Quartsik · Aug 23, 2015 at 01:12 PM

Thank you.. I tried to make it as you say, but i have a problem. is it possible to make a new text object directly from script? i am sorry, if my questions are stupid, i am new in unity, and i am working on one project and i try to learn it by way. for example... is little bit possible to make a script like this? i know some syntax is bad, but i think, you will understand, what i am trying to do...

 List<string> words = _myTextAsset.text.split(" ").ToList();
     
      
     public float distanceX; // space between words
     public float distanceY; // space between lines
     public float endOfLineMultiplier; // multiplier for word.length 
     public float endOfLineIdentifier; // identifying end of line
     
     private float defaultYtransform;
     private float defaultXtransform;
     private float previousXTransform;
     private float previousYTransform;
     
     
     foreach string word in words // going throw list
 {
      private text = new TextObject;
      text = word;
      
         if (endOfLineIdentifier >= (previousXTransform + distanceX + word.Length * endOfLineMultiplier)) // if end of line != 1 write word to this line
     {
         text.Transform =  (previousXTransform + distanceX + word.Length * endOfLineMultiplier, previousYTransform , 0)
     }
         else // if end of line = 1 , return to start of second line 
     {
         text.Transform = (defaultXtransform,defaultYtransform + distanceY,0)
         defaultYtransform = (defaultYtransform + distanceY)
     }
 
     Instantiate text;
    
Comment
Add comment · 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
0

Answer by Varaughe · Apr 05, 2020 at 04:30 PM

Did you check https://assetstore.unity.com/packages/tools/gui/fully-flexible-ui-text-148050? You can have each character as a separate UI Text and then changing it's scale, position etc.

Comment
Add comment · 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

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

4 People are following this question.

avatar image avatar image avatar image avatar image

Related Questions

HUD appearence 2 Answers

how to get text object to the server with A specific text?(with mirror) 0 Answers

Text Prefrab problem 1 Answer

Changing the UI text value from server to Client side 0 Answers

Text smaller on higher resolution screen than on lower resolution screen 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