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 Moritz13 · Nov 15, 2016 at 07:04 AM · textmesh

BCE0023: No appropriate version of 'UnityEngine.Component.GetComponent' for the argument list '(UnityEngine.TextMesh)' was found.

New to programming so sorry if this is simple. I am trying to use a textmesh code to edit a 3D text in game. basically what i have done is assigned an invisible integer as its health, that integer is sent to a string so i can use that string to edit the 3D text (hopefully that makes sense) Here is my code.

 #pragma strict
 var Militia : GameObject;
 var hp : GameObject;
 var cube : GameObject;
 var trigger : GameObject;
 var red_hp : int = 100;
 var red_range : boolean = false;
 var hp_value : String ="";
 var hp_real : TextMesh;
 function Start () 
 {
     Militia.SetActive(false);
     hp.SetActive(false);
     red_range = false;
 }
 
 function Update () 
 {
     if(Input.GetKeyUp(KeyCode.F))
     {
         if(red_range == true)
         {
             red_hp = red_hp - 25;
             hp_value= red_hp.ToString();
             GetComponent(hp_real).text = hp_value; << Error is here
             if (red_hp <=0)
             {
                 Destroy (cube);
                 Destroy (Militia);
                 Destroy(hp);
             }
         }
     }
 }
 
 function OnTriggerEnter (trigger : Collider)
     {  
         Militia.SetActive(true);
         hp.SetActive(true);
         red_range = true;
     }
 function OnTriggerExit (trigger : Collider)
 {  
     if (red_hp >=0)
     {
         Militia.SetActive(false);
         hp.SetActive(false);
         red_range = false;
     }
 }


Any help will be appreciated

Thanks

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

2 Replies

· Add your reply
  • Sort: 
avatar image
1
Best Answer

Answer by ElijahShadbolt · Nov 15, 2016 at 07:10 AM

 hp_real = GetComponent<TextMesh>();
 hp_real.text = hp_value;

Edit: oh, right, it's in JS, not C#.

 hp_real = GetComponent.<TextMesh>();
 hp_real.text = hp_value;
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 Moritz13 · Nov 15, 2016 at 07:20 AM 0
Share

replaced my

 GetComponent(hp_real).text = hp_value; << Error is here

With your

 hp_real = GetComponent<Text$$anonymous$$esh>();
 hp_real.text = hp_value;
 

But i have 3 new errors now:

  • Assets/test.js(25,46): BCE0043: Unexpected token: ).

  • Assets/test.js(25,47): BCE0044: expecting ), found ';'.

  • Assets/test.js(25,48): UCE0001: ';' expected. Insert a semicolon at the end.

I have copied yours exactly so im not sure why its telling me to add brackets and semicolons.

avatar image
1

Answer by Moritz13 · Nov 15, 2016 at 07:22 AM

Never mind fixed it. Took out hp_real = GetComponent(); And it worked.

Thank you for your help

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 ElijahShadbolt · Nov 15, 2016 at 08:49 AM 0
Share

You're welcome :D

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

Textmesh.text: How to change it on playmode with the keyboard like in hierarchy? 1 Answer

Scroll TextMesh Down? 0 Answers

Set TextMesh Pro width via script? 0 Answers

Duplicate Object Draw order text issue 1 Answer

Is it possible to place a TextMeshPro component under a SpriteMask? 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