I just recently tried importing the program into my project. However, when I tried opening Unity, an error message is generated:
System.InvalidCastException: Unable to cast object of type ‘System.Boolean’ to type ‘System.String’
Hence, I was lead into the safe mode of Unity.
Please advise on how I should solve the issue.
This likely means that you closed unity while your code had an error.
That error means you (or something else) gave a boolean (true/false) value when it was expecting a string (“text”) value.
A cast is what the compiler tries to do to convert from one datatype to another. With some data types (such as numbers) this is straightforward. But it has no idea what to do when it tries to convert true/false to a string.
Ultimately, the fix is to change the code so you give a string where it expects a string.
At first I wrote an answer about null-checking a string, but then I realized that this is an exception, not a compile-time error. I believed that only compile-time errors make Unity to suggest the safe mode, but maybe it happens even with runtime exceptions during some initialization. Anyway, the best you can do is double-click the error in the console and see where does it take you - if it’s a code that’s in your project, your IDE should open with a cursor to the place where the exception happened. If not, you can still select the exception in the console and see the stacktrace below. Posting that stacktrace here would really help to investigate further.
But I was wondering if this could be because the project that I imported was created on the Unity 2017 version hence when I try to open it in the 2022 version, it resulted in a compilation error. Ps, I got this project from an online source, the codes are not done by me. I saw the demo video which he posted and it seem to work.