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 PredatorProductions · Nov 09, 2016 at 07:47 PM · error messagetext box

Keep getting this error on different Text boxes. Any help would be appreciated!

NullReferenceException: Object reference not set to an instance of an object textHolder+c__Iterator1.MoveNext () (at Assets/Script/textHolder.cs:27) UnityEngine.MonoBehaviour:StartCoroutine(IEnumerator) textHolder:Start() (at Assets/Script/textHolder.cs:19)

The code:

using UnityEngine; using System.Collections; using UnityEngine.UI;

public class textHolder : MonoBehaviour {

 public string talking;
 private TextManager TMan;

 public float speed = 0.1f;
 //public string fullText;
 //private string currentText = "";

 public string[] talkingLines;

 // Use this for initialization
 void Start () {
     TMan = FindObjectOfType <TextManager> ();
     StartCoroutine(ShowText());
 }

 IEnumerator ShowText(){
     for (int i = 0; i < talkingLines.Length; i++) {

         talking = talkingLines[i];

         this.GetComponent<Text> ().text = talking;

         yield return new WaitForSeconds (1);
     }
 }
 
 // Update is called once per framea
 void Update () {
     
 }

 void OnTriggerStay2D (Collider2D other)
 {
     
     if (other.gameObject.name == "Player")
     {    
         if (Input.GetKeyUp (KeyCode.Space)) 
         {
             //TMan.ShowBox (talking);

              if (!TMan.talkingActive)
             
             {
                 TMan.talkingLines = talkingLines;
                 TMan.currentLine = 0;
                 TMan.showTalking ();
             }
         }
     
     }
 }

}

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 aditya007 · Nov 10, 2016 at 04:55 AM 1
Share

I don't know which specific line of code the error is pointing to, but as you said, you're getting error on Text box. It could be the line this.GetComponent<Text> ().text = talking; and if it is, then the reason is you don't have Text component attached to your gameobject. Please double check that.

1 Reply

· Add your reply
  • Sort: 
avatar image
0

Answer by Brylos · Nov 10, 2016 at 07:21 AM

I believe it has something to do with scripts detecting certain components. Check that you dont have any deleted scripts on objects and or dont have a public game object or component that isnt assigned to a script. I'm not completely sure that is how to fix it, but I hope this helps.

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

79 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

Related Questions

getting error "Operator '<' cannot be used with a left hand side of type 'Object' and a right hand side of type 'float'." 0 Answers

All compiler errors have to be fixed before you can enter playmode! UnityEditor.SceneView:ShowCompileErrorNotification() but my script has 0 errors 1 Answer

Keep getting Null reference error for AI Script 1 Answer

Unity 2017 playmode is not working 0 Answers

IndexOutOfRangeException in TextureInspector 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