• 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 11, 2014 at 05:56 AM by Loius for the following reason:

Duplicate Question

avatar image
-1
Question by markzareal · Jul 11, 2014 at 05:54 AM · javascripterror

BCE0005: Unknown identifier: 'spriteRenderer'.

 #pragma strict
 
 var diamond : Texture;
 var square : Texture;
 var triangle : Texture;
 var circle : Texture;
 var start : Texture;
 private var number : int = Random.Range(1,4);
 
 function Start () {
 spriteRenderer.Sprite = start;
 }
 
 function Update () {
 if (number == 1) {
 spriteRenderer.Sprite = diamond;
 }
 else if (number == 2) {
 spriteRenderer.Sprite = square;
 }
 else if (number == 3) {
 spriteRenderer.Sprite = triangle;
 }
 else {
 spriteRenderer.Sprite = circle;
 }
 
 }

I don't get what I got wrong here. It said BCE0005: Unknown identifier: 'spriteRenderer'. Anyone help please? 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

1 Reply

  • Sort: 
avatar image
0
Best Answer

Answer by Loius · Jul 11, 2014 at 05:56 AM

http://unity3d.com/search?refinement=answers&gq=bce0005

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 Loius · Jul 11, 2014 at 05:57 AM 0
Share

GameObject does not have a spriteRenderer member. It does have a renderer member. You have to get the spriterenderer yourself using GetComponent. '.Sprite' should be '.sprite'.

http://docs.unity3d.com/ScriptReference/index.html

Welcome to Unity Answers

The best place to ask and answer questions about development with Unity.

To help users navigate the site we have posted a site navigation guide.

If you are a new user to Unity Answers, check out our FAQ for more information.

Make sure to check out our Knowledge Base for commonly asked Unity questions.

If you are a moderator, see our Moderator Guidelines page.

We are making improvements to UA, see the list of changes.



Follow this Question

Answers Answers and Comments

3 People are following this question.

avatar image avatar image avatar image

Related Questions

Multiple Cars not working 1 Answer

Problems with java script. 1 Answer

BCE0022: Cannot convert 'UnityEngine.Sprite to 'UnityEngine.SpriteRenderer' 1 Answer

Exception error 1 Answer

JS Unity Boolean 'not possible to evoke an expression of type 'boolean'' 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