• 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
-1
Question by Ambrose998800 · Oct 23, 2016 at 02:26 AM · c#variable

Unity wont accepted variable

For some reason Unity declines a variable all of sudden...

The second to last variable is not accepted:

alt text

What can I do?

cs-canvasvariable-issue.jpg (60.7 kB)
Comment
Add comment · Show 2
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 Bunny83 · Oct 23, 2016 at 02:59 AM 0
Share

Post relevant code and when you post code, post it as text and not as partial image. If you get a compiler error, the actual error has to be either on the line where the compiler complains or before that line. So If the compiler complains about your code after your "Visualisations" comment, the error is most likely on the last line of your "Positions & dimensions" block.

I downvoted because:

  • The question isn't clearly presented. Only partial information is provided. In such a case the compiler gives you a clear error, an error code as well as a line number. You haven't provided any of those.

  • Code should be provided as text and formatted properly. If you have trouble how that is done, see the userguide which is also linked on the right side here on UA.

  • This question is a pure debugging question. UnityAnswers isn't ment for such questions. Since we don't want people with such trivial problems to get lost we have the Help Room. Though you posted this question in the default space.

avatar image Ambrose998800 Bunny83 · Oct 23, 2016 at 03:20 AM 0
Share

Thanks for constructive criticism!

The problem was, there was no explicite compiler error. I deleted everything now and rewrote it, now it works. I had that issue before, but I never figured out what to do ins$$anonymous$$d of rewrite everything.

Next time I get this issue, I will post the code here as an edit before opening a new question.

1 Reply

· Add your reply
  • Sort: 
avatar image
0

Answer by Naphier · Oct 23, 2016 at 02:40 AM

Looks like an IDE issue, but hard to tell. What IDE are you using? I can't see your code, but it's probably a missing semicolon...

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 Ambrose998800 · Oct 23, 2016 at 02:48 AM 0
Share

Where can I see the IDE?

 //Visualisations
 NewCanvas.GetComponent<UnityEngine.UI.Image>().sprite = Item.GetComponent<Item_Basic>().Icon;
 NewCanvas.name = Item.gameObject.name;


Same code works on another object correctly.

Edit: if I delete the wrong variable, the next one is wrong: alt text

cs-canvasvariable-issue2.jpg (56.4 kB)
avatar image Naphier Ambrose998800 · Oct 23, 2016 at 07:40 PM 0
Share

If you delete that line and the next line above has an issue then you've got a bad statement/syntax error somewhere. I can't help you unless you post more of the code. This is pretty typical issue when you're missing a semicolon.

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.

Welcome to Unity Answers

If you’re new to Unity Answers, please check our User Guide to help you navigate through our website and refer to our FAQ for more information.

Before posting, make sure to check out our Knowledge Base for commonly asked Unity questions.

Check our Moderator Guidelines if you’re a new moderator and want to work together in an effort to improve Unity Answers and support our users.

Follow this Question

Answers Answers and Comments

228 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 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 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

Way of Finding/accessing a variable from another script though another variable? 1 Answer

Vector3 variable not changing 0 Answers

How to get all the variables in a folder. C# 0 Answers

Passing in objects to class constructor 0 Answers

How to Attach Variables to Objects? 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