- Home /
Accessing static classes - where to put packages?
Ok I give up and need your help!
I recently pulled in the Photon package from the Unity store into my project. I simply dropped it under Assets.
Now under my Standard Assets I have a scripts folder and I create a new script and try to called PhotonNetwork(which is a static class in the photon package.)
Problem is: it says it cant be found. So I move my script inside the photon folder and it works fine. Why cant I access that static class? Does it have to been in the standard assets folder? When I move it then I have other problems with classes in Photon.
Help!! :)
Answer by Linus · Aug 15, 2013 at 01:14 AM
Your script will communicate with their scripts. Therefore their script will have to be compiled first. Put their scripts in Standard Assets and your script outside of that folder.
http://docs.unity3d.com/Documentation/Manual/ScriptCompileOrderFolders.html
The phases of compilation are as follows:-
Phase 1: Runtime scripts in folders called Standard Assets, Pro Standard Assets and Plugins.
Phase 2: Editor scripts in folders called Standard Assets/Editor, Pro Standard Assets/Editor and Plugins/Editor.
Phase 3: All other scripts that are not inside a folder called Editor.
Phase 4: All remaining scripts (ie, the ones that are inside a folder called Editor).
Additionally, any script inside a folder called WebPlayerTemplates will not be compiled at all.
A common example is where a UnityScript file needs to reference a class defined in a C# file. You can achieve this by placing the C# file inside a Plugins folder and the UnityScript file in a non-special folder. If you don't do this, you will get an error saying the C# class cannot be found.
Thanks - all this time I never knew that ha. I ended up moving my "scripts folder" out of standard assets and its working now. Thanks!
Your answer
Follow this Question
Related Questions
static class not keeping changes after playmode 1 Answer
Static class not working properly on game build 3 Answers
Best way to access static variables from the inspector 0 Answers
How can you extend UnityEngine.ProBuilder.MeshOperations when it's immutable and not public? 0 Answers
NullRefrenceExeption on Awake and in some other places 2 Answers