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 /
avatar image
0
Question by GaryMowat93 · Nov 11, 2013 at 09:19 PM · errorargument

BCE0023 No appropriate Version of UnityEngine.GameObject.GetComponent

This is the full Error Message:

Assets/guiHUD.js(59,59): BCE0023: No appropriate version of 'UnityEngine.GameObject.GetComponent' for the argument list '(UnityEngine.GameObject)' was found.

Basically creating a simple game and the section i'm trying to code uses another script to reference from (PlayerDataScript) in this script it holds information for players name, score, items picked up etc. What i'm trying to do in my other script "GUIhud" is first create a HUD but secondly show the players name score and items picked up etc. Basically keep getting the same error for 4 similar lines of code which are basically 4 blocks which refer to going back and looking at the PlayerDataScript and returning the answer. This is a screen shot of the code that is wrong.alt text

screen shot 2013-11-11 at 21.02.18.png (38.0 kB)
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
2

Answer by Kiloblargh · Nov 11, 2013 at 09:24 PM

This is the kind of trouble you get into not following the lowercase-for-variables, uppercase-for-scripts convention.

Rename PlayerDataScript and the error will go away.

Example:

 var pds : PlayerDataScript = playerData.GetComponent.< PlayerDataScript >();

(I usually use the "generic" version of GetComponent (with the angle brackets) because it always returns the proper type instead of just type Component.)

What you did in the original script is just as bad as having a transform variable named "Transform".

Comment
Add comment · Show 4 · 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 GaryMowat93 · Nov 11, 2013 at 09:38 PM 0
Share

Thank you however i'm completely new to unity and i'm only doing a crash course for a module in university, so would I put this line of code at the beginning of the script with the errors or the beginning of the script that is named PlayerDataScript?

Thanks

avatar image jacobschellenberg · Nov 11, 2013 at 09:40 PM 0
Share
 function getNumItemsPickedUp() : int{
  var pds : PlayerDataScript = playerData.GetComponent.< PlayerDataScript >();
 
  if(playerData != null){
   //logic
  }
 }
avatar image jacobschellenberg · Nov 11, 2013 at 09:41 PM 0
Share

You may want the pds var declared at the top, not within the function, so that it sticks around.

avatar image GaryMowat93 · Nov 11, 2013 at 09:43 PM 0
Share

Thank you, however i'm completely new to unity and program$$anonymous$$g and it is only a side module at university and i'm not completely sure with how to go about fixing this, would I use this code at the beginning of the script that has the errors or the Script that is called PlayerDataScript

Thanks :)

avatar image
0

Answer by escalador · Jun 24, 2017 at 05:29 PM

my problem is Assets/AmmoBox.js(10,51): BCE0023: No appropriate version of 'UnityEngine.GameObject.GetComponent' for the argument list '(UnityEngine.GameObject)' was found.

my script is : #pragma strict

var ammo : int = 30; var eject : GameObject;

private var shoteject : eject; private var showGUI : boolean = false;

function Start () { shoteject = GameObject.Find("eject").GetComponent (eject); }

function Update () { if(showGUI == true){ if(Input.GetKeyDown("e")){ shoteject.reserve += ammo; Destroy (gameObject); } } }

function OnTriggerEnter(hit : Collider){

if(hit.gameObject.tag == "Player"){ showGUI = true; } }

function OnTriggerExit(hit : Collider){

if(hit.gameObject.tag == "Player"){ showGUI = false;

} }

function OnGUI(){

if(showGUI == true){ GUI.Box(Rect(Screen.width/2-100,Screen.height/2-12.5,200,25), "Press E to pickup ammo"); } }

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

18 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

Related Questions

Photon RPC problem... 3 Answers

URGENT - Serializing error The type of argument is not primitive 0 Answers

"Takes `2' arguments" 2 Answers

Argument out of Range 1 Answer

Some problems after switch the game for iOS mode 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