Hello, I just got my new computer and had to reinstall everything.
Everything was going fine until I noticed that really annoying issue from the title.
I looked it up and it seems it happened to a few people but the solutions they provided (regenerating project files, deleting .csproj files etc) didn’t work for me.
I’m reading that visual studio warns you about empty functions, is this not correct? What about just remove those functions instead of having unity call those functions at runtime wasting cpu time? Did you lost money because I’ve posted in “your” thread? Did they deduced a fee from your bank account? funny
No it’s about Visual Studio erroneously warning that Unity’s magic methods such as Awake and Update are ‘unused’, even though they will be used by Unity.
When Unity integration is correctly set up, this warning is supressed.
Usually when you have the Unity Tools extension installed in Visual Studio, that should take care of not reporting those magic methods. Haven’t used the latest Unity / VS so I can’t tell if the extension may be lacking. An alternative would be to make all the magic methods protected. Even though you may not plan to derive from your own class, it doesn’t really hurt and even prepares the class for being derived when necessary. So it’s generally a good iead fo make the magic methods protected instead of private. No need to make them virtual since Unity will always call the implementation in the actual instance.
I understand that unity will use those empty functions. I’m saying why you keep those empty functions in game wasting system resources? those are in the script just because the default template of creating scripts create them for you for convenience. VS is not doing anything wrong, it tells you that you need to get rid of those because you don’t use them.
That’s the part you don’t understand: the functions are of course not empty. What they are not, is CALLED. Hence Visual Studio saying they are “unused”.
Usually when you have the Unity Tools extension installed in Visual Studio, that should take care of not reporting those magic methods. Haven’t used the latest Unity / VS so I can’t tell if the extension may be lacking. An alternative would be to make all the magic methods protected. Even though you may not plan to derive from your own class, it doesn’t really hurt and even prepares the class for being derived when necessary. So it’s generally a good iead fo make the magic methods protected instead of private. No need to make them virtual since Unity will always call the implementation in the actual instance.
Yeah, I couldn’t find such an extension. I did install VS using this option though.
Unless the name is not what I thought it was ?
But I searched for Unity in the extensions in VS, and couldn’t find anything that looked like it.
probably you don’t know how to write english fluently and you’ve not described well the issue. it happens. if all are market as used then there may be a bug or something either on visual studio side or likely unity side
Wow… He does understand english very well and he described the issue properly. It’s not like that’s a new issue. It existed off and on for more than a decade as long as Unity exists. You can not “mark” a method as “used”. The warning is generated by VS own code analyser which determines that there is no explicit call to those methods. Since they are private methods, following normal OOP rules they can only be called from within the class itself. Since the code analyser hasn’t found any such call, it displays this warning. It’s of course a false warning since Unity will call those methods from the native side, something that the C# compiler can not know. That’s where the Unity extension for VS comes in. It takes care of those warnings.
You are quite often confidentally incorrect… almost like ChatGPT. You may step down a bit.
I actually have VS 2019 and 2022 installed on my machine and 2022 does have the Unity tools available. However you have to install them yourself. Click on Extras --> Get Tools and Features
When you scroll down a bit you should see “Game development with Unity” (or something similar. Mine is in german :P). You only need to checkmark them and they should get installed.
If it’s really not available for you, maybe they aren’t ready for the latest version. The VS installer says I have the community edition 2022 - 17.8.2
Yeah, that’s the weird part, I do see the “Game development with Unity”, and it is already, indeed checked. Though it seems to have no effect (at least on this issue), which I don’t get why
“Visual Studio Tools for Unity” is also checked in “Individual components”.
And I have to say, without this, setting all unused methods to not appear “unused” is not gonna work for me, but your “Set them as protected” actually certainly will, so thanks for the help dude
fine, I see in the thread he posted that is an issue with visual studio that they work on fixing so till then he either installs an older version or he needs to wait for the fix. not much one can do if the app is broken.
is a visual studio bug that breaks some stuff unity relies on. read the link he posted
edit: pointing the explanation of the error and I get downvoted lol, I love this forum. such an welcoming community unity managed to create by managing to send away all the good people that were here
You are not pointing out the explanation, you are talking down to everyone and don’t understand what the issue is even after we explained it to you several times. You are confusing such simple concepts as “empty” functions and “unused” functions, which are not at all the same thing, even after people explained the difference to you.
in the link is clearly stated by microsoft that they have changed something that unity needed and there is an issue with that visual studio version and you either use an older version or wait for the fix. if you don’t like this explanation, I don’t know what is the issue then