I’ve got into quite the predicament. Bottom line, I have a script in my standard assets folder and need it to access the parent folder and then to ‘GoogleMobileAds/Api/’. When i’m in Assets/ and have ‘using GoogleMobileAds.Api;’ It works fine, but as i’m not experienced with C#, I haven’t a clue how I can instruct it to go up one directory.
Thank in advance!
The “using” statement has nothing to do with directories. It is using the namespace. If you look at the script files, you should see a namespace directive up under the using statements for that script file. That namespace that is defined there would be the namespace you would need to use elsewhere.
If you move the files without changing the namespace in the scripts, it should still work with GoggleMobileAds.Api.
A lot of times when programmers develop the code, they use the original folders as the naming convention for creating their namespaces and better organizing the code. But in the end, I don’t think it matters what folder it is in.
It is worth noting that ‘child’ namespaces are considered completely separate from their ‘parent’ namespaces.
So UnityEngine, UnityEngine.UI and UnityEngine.SceneManagement are three completely separate namespaces and must each be added with a using statement.
- Thank you for responding so quickly! Do you think the problem originates from my script being in the Standard Assets folder? I’ve read that that folder has priority on compilation or something like that. If so, how would I go about calling the corresponding functions from a javascript?
I have no clue… I refuse to use UnityScript. If you are just starting out, I’d recommend learning C# and doing your scripting in C#. I don’t even buy assets that are developed in UnityScript unless I don’t have any other choice.
Wow, turns out I needed to have another script to act as a conduit for accessing the standard assets script.
I agree with you on javascript, This recent project has shown me how flawed it is. Afterwards i’m switching to an engine that supports C++.
That’s a little extreme.
I’d suggest trying C# in Unity as another option.
Ditto…
@Choppedporks01 - The only reason you need another script to act as a conduit is because you are trying to use UnityScript (which is a modified version of JavaScript so in reality, you aren’t using JavaScript ). If you were writing your code in C# and needed to access that same script, you could access it directly. That is one of the reasons I recommend doing your Unity development in C# and hate trying to integrate anything UnityScript into my projects. They are just too big of a pain in the ass… lol Possible to do, but a pain unless you really know what you are doing.