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 /
This question was closed Jul 30, 2015 at 12:29 AM by rimawi for the following reason:

found some work around

avatar image
0
Question by rimawi · Aug 30, 2014 at 03:54 PM · uixmlnullreference

NullReferenceException: Object reference not set to an instance of an object

Hello, I am using the code below to read values from xml file.

the issue is : if i use:

 question_TXT.text=reader.GetAttribute("Text");

nothing shows up in the text field.

if i use :

  question_TXT.text=reader.GetAttribute("Text").ToString();

the value shows up in text field but i get NullReferenceException

Thanks

function fillInfo () {

         var reader:XmlTextReader = new XmlTextReader(new StringReader(Malaf2.text));
         // as long as there are info read.
         while(reader.Read())
        {         
 
                  //if the element name= question assign it yo questionText
                 if(reader.Name == "Question")
                  {  
                 // var questionText:Text=question_TXT.GetComponent("Text");
                  //var questionText:Text=GetComponent("UI.Text");
                   //question_TXT.text=reader.GetAttribute("Text");
                   question_TXT.text=reader.GetAttribute("Text").ToString();
                  }
         
        }
     }



Comment
Add comment · Show 3
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 everett24 · Aug 30, 2014 at 07:38 PM 0
Share

what is question_TXT? a class?

avatar image rimawi · Aug 30, 2014 at 10:17 PM 0
Share

it is part of the new UI.

import UnityEngine.UI; VAR question_TXT:Text;

avatar image Dr. Zoop · Sep 03, 2015 at 07:54 PM 0
Share

Without further information, it appears that reader.GetAttribute("Text") is returning null.

You can't call any method, including ToString() on a null reference. (Think of it like this, can you ask nobody their name?)

0 Replies

  • Sort: 

Follow this Question

Answers Answers and Comments

24 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

Related Questions

A node in a childnode? 1 Answer

How to update text every time I press space? 1 Answer

How to use U.I.Elements/ U.I.Builder to access bools/toggles? 2 Answers

Is it possible to change the default caret in an InputField? 1 Answer

How can i play with text which have string and int (from XML) 2 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