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 /
  • Help Room /
avatar image
0
Question by KnightRiderGuy · Aug 21, 2016 at 07:55 PM · c#uitextimportingdocuments

How do I make an external text document show only between certain lines in UI Text

I have a script I am trying to use an external text document (.txt) to display UI text on a canvas panel, but the tricky part is that for each public void called upon I want each one to display the text from the .txt document in blocks, for example:

Display these lines of text from the text document:

BILLY THE KIDD

REAL NAME WILLIAM BONNEY

BORN: 1860

DIED: JULY 13, 1881

And then be able to call on another section of text from the .txt document. This is what i'm using but I'm not understanding the array usage correctly:

 using UnityEngine;
 using System.Collections;
 using UnityEngine.UI;
 
 public class FactoidManager : MonoBehaviour {
 
     public Text factoidScreenText;
     public TextAsset factoidText;
     public string[] factoidLines;
 
     public int startLine;
     public int endLine;
 
 
     void Start(){
         if (factoidText != null) {
             factoidLines = (factoidText.text.Split ('\n'));
         }
 
         if (endLine == 0) {
             endLine = factoidLines.Length - 1;
         }
     }
 
 
 
     //Factoid Calls
     public void  GoFactoid01(){
         factoidScreenText.text = factoidLines[startLine]; //NEEDS to Display multiple lines from the .txt doc
 
         StartCoroutine(LoadFactoid01());
     }
 
 
     //Factoid Calls
     IEnumerator LoadFactoid01(){
         yield return new WaitForSeconds(1.5f); // wait time
         MasterPanelManager mpm = FindObjectOfType<MasterPanelManager>();
         mpm.EnableFactoidPanel();
         CameraSwitcher cs18 = FindObjectOfType<CameraSwitcher>();
         cs18.EnableCamera18();
 
         yield return new WaitForSeconds(15.5f); // wait time
         MasterPanelManager ebd = FindObjectOfType<MasterPanelManager>();
         ebd.DisableFactoidPanel();
         CameraSwitcher csdef = FindObjectOfType<CameraSwitcher>();
         csdef.CameraDefault();
 
     }
 }
 
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

1 Reply

· Add your reply
  • Sort: 
avatar image
0

Answer by toddisarockstar · Aug 21, 2016 at 11:39 PM

seems you could make things easier by just putting your own split character in your text doc.

BILLY THE KIDD%

REAL NAME WILLIAM BONNEY%

BORN: 1860%

DIED: JULY 13, 1881

and split like this:

  factoidLines = factoidText.text.Split("%"[0]);

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 KnightRiderGuy · Aug 22, 2016 at 12:17 AM 0
Share

Thanks but I think you miss understood my question. Splitting the text is not the issue.... it's getting the UI text to display between a line range, like say if you had a block of text and you just wanted to display a few lines from that block or paragraph of text.

The idea is to try and use one external text document to draw information from.

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

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

Related Questions

How To Load TTF Font From External File 0 Answers

Display CPU usage on a UI Slider or Text 1 Answer

How to properly display debug messages on UI 0 Answers

Updated with UI text element not correct (same frame) 0 Answers

Score UI per player 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