Hello all, so even though this is my first script I tried to do some research to solve this on my own, I’ve had no luck.
So I’m starting on this guided project, and I’ve entered the code as described in the tutorial…
But then I get this error message in the unity console : Assets\Scripts\RubyController.cs(21,9): error CS0104: ‘Debug’ is an ambiguous reference between ‘UnityEngine.Debug’ and ‘System.Diagnostics.Debug’
I tried replacing it with : UnityEngine.debug.log and System.Diagnostics.Debug and got :
Assets\Scripts\RubyController.cs(21,27): error CS0117: ‘Debug’ does not contain a definition for ‘log’
I also tried to set an alias with : using Debug = UnityEngine.debug
Got similar issues.
I tried a few other words and variations and got nowhere lol.
Now I can delete the debug line completely and move on with the tutorial, but the fact remains that I need to figure out to solve the problem so I can use the function in the future.
I wonder if because Unity has had some updates since this project was released that it uses a different command now? I’ve never done this before so I’m out here shooting in the dark, any help would be very much appreciated! Thank you!
Do you have to use System.Diagnostics? I think it also have an Debug function in there so it get confused which debug to use.
also i think you dont need to use System.Security.Cryptography, but it dosne’t seem to be a problem if you need it.
1 Like
@DeanAseraf1 is 100% correct, but perhaps somewhat brief in his response:
You need to remove the ‘using System.Diagnostics’ line in your code. The reason for this is that Unity also defines a Debug.Log method, and now the compiler does not know which to use.
If you need to use both, you need to tell the compiler first which version you want to use UnityEngine.Debug.Log
Note that you need to also be very careful with upper/lower case. It looks like you already tried the correct approach, but simply misspelled the initial capital letter of Debug and/or Log.
1 Like
Okay, I’m following you here. Want to state that the script was partially setup through the Unity project and everything up
to the “void Update()” was already in the file when I opened it. So anyone that goes through this project is going to have the same issue.
I can do a little more research, but a couple times I saw people with different types of files have issues with running without “system.diagnostics” because (now I don’t know about code so just guessing based on what I saw) that command checks the script quality on the windows side? is that correct? While say UnityEngine specifys the check in the program itself? I’m not running this game/file outside of Unity so I don’t think it’ll be a problem now but maybe in the future? Just want to understand.
Removing the “using System.Diagnostics” did fix the issue and I can now see debugging in the console, so thank you!
I’m also following you on the need for proper upper/lower case as I had to correct the “Input.Getaxis(“Horizontal”);”
portion because I kept getting an error saying controls weren’t setup. I did correct all spelling to proper upper and lower, so its all working smoothly now.
Edit : I re-added System.Diagnostics and the changed Debug.Log to UnityEngine.Debug.Log and it worked properly. Like you said, I must’ve missed the proper upper/lower case while troubleshooting that as well. facepalm
I don’t understand what the System.Security.Cryptography; command is but it was already there and not interfering so I won’t mess with it.
Thank you both for the kind help and instruction!