Hi all,
I am having trouble connecting Unity and Visual Studio 2017, so that the IDE suggests me the fuctions present in the UnityEngine library.
It has stopped working completely when I introduce the square brackets in: [SerializeField].
I don’t know why,but it stops correctly identifying { }, thus closing if statements or functions.
I have googled before coming here, and have done the usual installation of Visual Studio Tools for Unity 2017… not working ever.
This sounds more like a case of syntax issues, as such the compiler cannot make any sense of your code.
If you take a look at your screenshot, you’ll see the Thrust method, for example, is missing at least 4 closing curly braces. So the compiler will currently think that you Rotate method’s code is part of the Thrust method - which is then syntactically wrong.
Can you post your whole script up here please, not as a screenshot, but via copy/paste (and format it).
Just to clarify, VS2017 should know of the libraries’ functions I add to the code, right?
Yes, as long as the solution/project has references to the required libraries. But if you have code that cannot compile due to syntax errors, it makes little difference. The compiler needs to be able to understand all of the code in your file.
Thanks for the code.
The issue is caused by where you are trying to serialize your fields. You can serialize members variables, but not local variables, e.g. those within a method.
Take a look at the code from the project on GitHub at this stage in the course and you will see the difference.