Page 1 of 2
[SOLVED]Visual Studio issue
Posted: Mon Jul 27, 2020 3:15 am
by dwmitch
When I import Dialogue System into my project it works out of the box with no errors. In Visual Studio (2017 Community if it's relevant) when I want to add a Lua function it says it can't find the namespace PixelCrushers and any functions in the PixelCrushers.DialogueSystem, such as Lua.RegisterFunction and SystemExtensions.GetMethodInfo are flagged as errors. If I delete the using statement and check the quick refactoring options it will add the using statement back for me so obviously VS is aware of the assembly, but it's still flagged as an missing.
Like I said, it doesn't prevent it from working in Unity. The functions register, they run when triggered, but it prevents the use of Intellisense. It's a quality of life issue, but it's a big enough thorn in my side that I refuse to move on until a solution is found so it's pretty much putting me on hold.
Re: Visual Studio issue
Posted: Mon Jul 27, 2020 8:40 am
by Tony Li
Hi,
Are you using the assembly definition files? By default, they're not imported, so you'd only be using them if you actually went through the steps to import the asmdef unitypackages in Dialogue System/Scripts and Common/Scripts. In my own projects, I prefer
not using asmdefs with the Dialogue System. It's already in Plugins, so it compiles separately from your own code anyway. And, without the asmdefs, I don't have to worry about managing asmdef references with other asmdefs. Anyway, it shouldn't make a difference with this VS issue, but it's info to consider as we look into the issue.
Please try this:
1. Back up your project.
2. Make sure you have a good backup.
3. Exit Unity and VS.
4. Delete the .vs folder and the .sln file(s).
5. Open Unity.
6. Open VS.
This will rebuild VS's info cache.
Re: Visual Studio issue
Posted: Mon Jul 27, 2020 4:53 pm
by dwmitch
It didn't work. I checked every folder of the project and there are no .asmdef files in it. I deleted the .sln file and .vs and reopened it. It still threw a namespace error. Then I deleted the .sln, .vs, and .proj files. Still didn't work. I tried to manually add a reference in VS but instead of giving me the option to add a reference like it does when I'm making a console or WPF program it just gave me the option to add an analyzer. After digging through every folder I didn't see any dlls other than the ones Unity adds to every project.
Since it's a throwaway project to familiarize myself with Dialogue System I deleted it, started a new project, and imported Dialogue System. I followed the same steps multiple times and it still didn't work.
Re: Visual Studio issue
Posted: Mon Jul 27, 2020 5:11 pm
by Tony Li
Hi,
That's odd. I used VS 2017 Community for years until I switched to VS 2019 Community.
Please try this:
1. Close VS.
2. In Unity, select menu item Edit > Preferences.
3. In the "External Tools > Generate .csprog files for" section, tick all of the checkboxes.
4. Click Regenerate project files.
5. Try reopening VS.
If that doesn't help, what version of Unity are you using?
What's the full name of your project folder, including path? If you don't want to post the full name, check it for any special characters such as ':' (except for the drive letter indicator) and '/'. Visual Studio might be having a problem with it.
Re: Visual Studio issue
Posted: Mon Jul 27, 2020 5:37 pm
by dwmitch
I'm afraid that didn't work, either. After testing it I went back and tried the steps from your first reply for good measure.
I'm using Unity 2019.3.12f1 and there aren't any special characters in the file path. The name of the project is PnCTest and the path to it is "C:\Users\...\PnCTest" where the ... is my name.
Re: Visual Studio issue
Posted: Mon Jul 27, 2020 7:51 pm
by Tony Li
I'm afraid I don't know. Is your VS 2017 fully up to date?
Re: Visual Studio issue
Posted: Tue Jul 28, 2020 9:07 pm
by dwmitch
I updated it after you asked about it. No change. I also noticed an issue. It's not giving me any compile errors, but functions that alter the database don't seem to work. When I followed your tutorial on linking C# functions I was able to replicate your GiveExperience and status check function (in my case it checked an NPC's opinion variable), though I had to type them in manually instead of being able to select them from a dropdown, but when I tried your Discover Name demo the database remained unaltered.
I tried copying the relevant portion into my own player script with no results. Then I attached the demo script itself to the player object and it didn't work. I'm wondering if, even though it's not throwing an error in Unity, the namespace issue might be preventing database related functions from working.
Re: Visual Studio issue
Posted: Tue Jul 28, 2020 9:28 pm
by Tony Li
Hi,
dwmitch wrote: ↑Tue Jul 28, 2020 9:07 pmI updated it after you asked about it. No change. I also noticed an issue. It's not giving me any compile errors, but functions that alter the database don't seem to work. When I followed your tutorial on linking C# functions I was able to replicate your GiveExperience and status check function (in my case it checked an NPC's opinion variable), though I had to type them in manually instead of being able to select them from a dropdown...
You can create a
Custom Lua Function Info asset to add them to the dropdown.
dwmitch wrote: ↑Tue Jul 28, 2020 9:07 pm...but when I tried your Discover Name demo the database remained unaltered.
The database will remain unaltered, but the runtime values should change. You won't see those changes in the Dialogue Editor, except in the Watches tab that becomes available in play mode. The database contains the static design-time data. All runtime changes exist in the Dialogue System's Lua environment in memory.
dwmitch wrote: ↑Tue Jul 28, 2020 9:07 pmI tried copying the relevant portion into my own player script with no results. Then I attached the demo script itself to the player object and it didn't work. I'm wondering if, even though it's not throwing an error in Unity, the namespace issue might be preventing database related functions from working.
I think the info above may clarify that. If not, let me know. If you play DemoScene1 and can pick up the quest from Private Hart, then database-related functions are working, as the quest functions and alert message are all driven by the same Lua function process.
The Visual Studio installer has a repair function. You might try that.
If possible, try it on another computer, too. If it works on another computer, you can compare your Visual Studio setups on both. If it doesn't, look for commonalities in how you've set up VS on both.
Re: Visual Studio issue
Posted: Tue Jul 28, 2020 10:13 pm
by dwmitch
Tony Li wrote: ↑Tue Jul 28, 2020 9:28 pm
The database will remain unaltered, but the runtime values should change. You won't see those changes in the Dialogue Editor, except in the Watches tab that becomes available in play mode. The database contains the static design-time data. All runtime changes exist in the Dialogue System's Lua environment in memory.
I see. I misunderstood the tooltip for the Instantiate Database option. I thought it was to protect it from scripted changes instead of editing during play mode.
I also found my error in the name change test. I got a bit mixed up on the order of execution on a node so I put TextInput in the sequence box of the first node and the change name script in the function section of the same node, thinking that the script would wait for the sequence to finish and putting the change name function in the player's first dialog node would show the default name for that node. Turns out it was assigning the default value of PlayerName to the display name, which was the same default text so I didn't see any change. Moving the function down one node got it to working.
I'll try updating to 2019 Community tomorrow night and see if that fixes the namespace issue. Thanks for your help.
Re: Visual Studio issue
Posted: Tue Jul 28, 2020 10:38 pm
by Tony Li
dwmitch wrote: ↑Tue Jul 28, 2020 10:13 pmI see. I misunderstood the tooltip for the Instantiate Database option. I thought it was to protect it from scripted changes instead of editing during play mode.
It does protect from unintended scripted changes (e.g., if you inadvertently change something in DialogueManager.masterDatabase), but Lua is where the real runtime changes should go.
dwmitch wrote: ↑Tue Jul 28, 2020 10:13 pmI'll try updating to 2019 Community tomorrow night and see if that fixes the namespace issue. Thanks for your help.
Good luck! Hopefully that will resolve the issue.