charles
New Member
Posts: 3
Posts: 3
|
Post by charles on Dec 26, 2021 15:16:19 GMT
I am trying to add a sound to the Math Highway example in ForeverRunner when a correct and incorrect answer happens. I loaded Master Audio and the page Triggering Audio With Code! indicates I should use using DarkTonic.MasterAudio;
The compiler states that namespace is not found. I found the namespace being used in the Plugins/DarkTonic/MasterAudio/scripts files but it does not seem to be available outside that subdirectory. How do I get the using statement to work in my or other people's code? It is a bit hard to use an API if it is not available. I have just started coding with Unity so I am not sure where references are specified. Or how to create them for that matter.
|
|
|
Post by DarkTonic Dev on Dec 26, 2021 19:11:25 GMT
Where is your script located? It should work almost everywhere. Give me the full path. This page may provide some insight. docs.unity3d.com/Manual/ScriptCompileOrderFolders.htmlThe order of compilation table means that anything located in a higher step is visible to the steps after it, but not vice versa.
|
|
charles
New Member
Posts: 3
Posts: 3
|
Post by charles on Dec 28, 2021 12:34:54 GMT
Assets\Dreamteck\Forever\Examples\Math Highway\Scripts I can move that. For now I am trying to learn both packages and how to get them to work together.
The example I picked has a prefab that it spawns 3 of at a time. One will have a correct answer to a question and two will have wrong answers. I am trying to put an explosion sound on the ones with a wrong answer and an "upgrade" sound on the one with the correct answer. This needs to be done after they are spawned and when the answers are added. I added an "event sound" to the prefab but can't access it as the GetComponet line of code doesn't recognize the types from MasterAudio. And that is probably because the using doesn't see the MasterAudio code. And I don't know why that isn't being found.
Thanks for the help.
|
|
|
Post by DarkTonic Dev on Dec 28, 2021 16:52:27 GMT
Anything in the Assets folder would see the Assets/Plugin folder. I can't reproduce the problem on my end.
So next, tell me where the file MasterAudio.cs lives, full path please.
You can always send me your project code and I can try and reproduce it on my end that way.
-B
|
|
charles
New Member
Posts: 3
Posts: 3
|
Post by charles on Dec 28, 2021 21:42:45 GMT
Well this is interesting. After work I created a new project and imported MasterAudio. Created a script in the default Assets/Scenes subdirectory and tried to add the using statement. It worked.
Then I imported the Forever package and created a TestScript1.cs file in the Assets/Dreamteck subdirectory and tried to add the using statement. It worked.
Then I created a TestScript2.cs file in the Assets/Dreamteck/Forever subdirectory and tried to add the using statement. It would not work. Their examples are below that level and the using statement will not work in the subdirectories below that level that I checked.
So I created an Assets/Scripts subbdirectory and added a TestScript3.cs file and tried to add the using statement. It worked
adding a Forever subdirectory to the Assets/Scripts subdirectory and a TestScript4.cs file still allowed the using statement.
There seems to be something weird about the Assets/Dreamteck/Forever subdirectory that blocks the using statement anywhere within or below it.
I don't consider this to be your problem. Sorry for the waisted time. I will try to work around what ever is blocking the namespece below that subdirectory. But it thought you might want to know what I found.
I have never seen namespaces getting blocked before based on the depth of the subdirectories and didn't expect that. I still don't have any idea what Unity or C# is doing to cause that.
Thanks for the link to the unity documentation about order of compilation. Based on that I would expect the using statement to work but reality doesn't always care about documentation.
Again, thanks for taking the time to help.
|
|
|
Post by DarkTonic Dev on Dec 28, 2021 22:38:44 GMT
That's pretty weird. It may be worth checking if the issue exists in both MonoDevelop and Visual Studio. Not sure which editor you use.
-B
|
|