Creating a variable named renderer

[SOLVED]

Hi, i’m trying to create a variable named renderer and i get an error message if i name it like that

.
i can call it whatever else i want and it will work (which is what i will do so i can move on, but i would like to understand what is the problem that i have with this variable name that Rick doesn’t have when he uses it?).

thank you

There is actually nothing wrong with what you are doing. The message is just a warning because the instance variable ‘renderer’ is already defined. Already defined? Yes, by the Component class which Monobehaviour inherits from. It is warning you that you are redefining the variable and will lose access to the default Component.renderer.

Seeing this documentation I would guess you are using an older version of Unity because that variable is now obsolete and removed from the Component class:

i am using unity 2020.2.4f1, ill try to update it and see if that fixes the warning. thank you

i now have 27 problems since i installed the new unity version… And now my scenes don’t have the unity logo on them anymore (even tho they can still open).

Yeah, this kind of issue happens a lot, that’s why it is not recommended to update your Unity version in the middle of a project.

There are two ways to solve this:

  • Erase your Library folder that is inside your project’s folder.
  • Reset your packages. Go to Help / Reset Packages to defaults.
1 Like

I managed to fix the 27 error by setting the edit > project settings > player > Api compatibility level to .NET 4.x (it was back to 2.0 after I updated unity) but to fix the missing unity logo, I simply did a system restore to before I updated unity and everything came back to normal. I then added unity 2020.2.5f1 to my install tab WITHOUT removing unity 2020.2.4f1 before, which is what made the logo disappearing. Everything is back to normal now.
Thank you very much for taking the time to answer me!! :heart:

2 Likes

This topic was automatically closed 24 hours after the last reply. New replies are no longer allowed.