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 Er_ellison · Aug 02, 2017 at 09:55 AM · assignment

NOT ASSIGNING VARIABLE

here is the code :

 using System.Collections;
 using System.Collections.Generic;
 using UnityEngine;
 using UnityEngine.UI;
 using System;
 
 
 public class RMP_count : MonoBehaviour {
 
 
 
     // REFORMED UI RMP DATA
     public GameObject Rmp;
     private Text text;
     private string canvas_RMP_to_string;
     private string y;
 
     // Use this for initialization
     void Start () {
 
         text = Rmp.GetComponent<Text> ();
 
     }
     
     // Update is called once per frame
     void Update () {
         float x = float.Parse(text.text);
         y = text.text;
         y = Math.Round((x / 1000) , 1).ToString();
         text.text = y;
 
         Debug.Log (text.text);
     }
 }
 

I get what i want in Debug.Log (text.text); part and it is perfect but the problem is the part text.text = y; it IS NOT ASSIGNING and in game scene it is not shows up !!! what can i do?

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
Best Answer

Answer by Er_ellison · Aug 02, 2017 at 01:55 PM

hey man ...
Thanx every one for helping
i just solved the problem from source code , i just found that variable from the source and then divided that to 1000 and problem been solved !
thanx every one ....
love u

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 NorthStar79 · Aug 02, 2017 at 11:41 AM

change this

  text.text

with this

 text.GetComponent<Text>().text


Comment
Add comment · Show 3 · 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 Er_ellison · Aug 02, 2017 at 12:25 PM 0
Share

i changed both , but still not working

avatar image Er_ellison · Aug 02, 2017 at 12:26 PM 0
Share
 using System.Collections;
 using System.Collections.Generic;
 using UnityEngine;
 using UnityEngine.UI;
 using System;
 
 
 public class R$$anonymous$$P_count : $$anonymous$$onoBehaviour {
 
 
 
     // REFOR$$anonymous$$ED UI R$$anonymous$$P DATA
     public GameObject Rmp;
     private Text text;
     private string canvas_R$$anonymous$$P_to_string;
     private string y;
 
     // Use this for initialization
     void Start () {
 
         text = Rmp.GetComponent<Text> ();
 
     }
     
     // Update is called once per frame
     void Update () {
         float x = float.Parse(text.text);
         y =  text.GetComponent<Text>().text;
         y = $$anonymous$$ath.Round((x / 1000) , 1).ToString();
         text.GetComponent<Text>().text = y;
 
         Debug.Log (text.text);
     }
 }
 

avatar image ShadyProductions Er_ellison · Aug 02, 2017 at 12:29 PM 0
Share
  void Update () {
      float x = float.Parse(text.text);
      y = $$anonymous$$ath.Round((x / 1000) , 1).ToString();
      text.text = y;
      Debug.Log (text.text);
  }

Don't use GetComponent in update.

avatar image
0

Answer by Bunny83 · Aug 02, 2017 at 01:19 PM

Are you sure that your "Rmp" reference actually point to the object in the scene? I suspect that this might reference a different instance, for example a prefab?

Change your Debug.Log to:

 Debug.Log (text.text, Rmp);

Now when you click on the debug message in the console, the editor will highlight the referenced object yellow, either in the hierarchy or in the project view. Make sure that the object is the correct instance.

Comment
Add comment · Show 2 · 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 Er_ellison · Aug 02, 2017 at 01:53 PM 0
Share

Yes , that's correct

avatar image amykl · Jan 15, 2018 at 06:35 AM 0
Share

Variables play a significant role in computer program$$anonymous$$g for the reason that they allow programmers to write supple programs. ... A variable's data type shows what sort of worth the variable signifies, such as whether it is an integer, a floating-point quantity, assignment help, or a personality. The reverse of a variable is a endless.

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

70 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

Related Questions

Swapping a base and derived class giving unexpected results. 0 Answers

How to assign GameObject to script while in prefab mode? 0 Answers

Set public Image in canvas from script 0 Answers

How to make multiple sprites move using a loop from the scene script? 0 Answers

Variable not assigned but is. 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