For the default scripts that comes with the first person controller, such as “Mouse Look”, I can put their script names in <> to get them. However, when I put my script within the <>, I get an error saying “The type or namespace ‘Test’ could not be found (are you missing a using directive or an assembly reference?)”
The type of a script should be the script name, why it says the type can not be found? I tried to declare a variable that is of the type of the script, and get the same error. How can I let the compiler know I am referring to a script created by me?
are you sure it’s created correctly, that the name matches up, and that it’s not in some namespace (all components/monobehaviours that can be added to gameobjects can’t be in a namespace).
Also is this ‘Test’ script possibly written in unityscript. I’ve heard noise about compiling order between C# and javascript, and C# can’t recognize the unityscript script files because they get compiled after the C# or something. (I don’t know for certain if this is true, I use all C#)
That isn’t accurate. The call GetComponent without any object specified and if the class derives from Monobehavior will be executed on the object instance that the OnGUI script example(from Yifan) is attached to. I suppose
Well isn’t the result the same in this case? .this refers to the game object this script is attached to, gameObject also refers to the game object the script is attached to. If I’m wrong let me know I’m still learning myself
By the way I was aware I didn’t specify the component but that wasn’t the point I was trying to make.
In C# script, it does have problem with recognizing unityscripts.
Just curious have you ever met situation that you really don’t know what’s wrong with your scripts, but when you rewrite a new one maybe after you restart your unity, everything works again, although you wrote the same code as last time?
Can you explain a little bit in the section 3, what does it mean by the “editor”? Is it a folder? I am confused. The “editor” to me meant the unity software interface that we’ve been working on.
BTW, thank you for answering my questions yesterday!
In section 3 “Editor” refers to a folder/directory in your project. This folder contains specialized scripts that use or modify the actual editing process which are not appropriate or compatible with the game build. So scripts that add functionality to Unity’s editor menus and such should be put in this “Editor” folder.
That is not a default folder, right? So when you need to add functionality to Unity’s editor menu, you create a folder called “Editor” and put your related scripts in it?
I believe this is the case. If the folder doesn’t exist you create it. I put mine as a sub directory of assets and most of the info I’ve seen seems to use this as a standard but I did see a post where it was mentioned “so long as it’s in the assets folder hierarchy” but have no experience with this case.
"The AssetDatabase interface is only available in the editor and has no function in the built player. Like all other editor classes, it is only available to scripts placed in the Editor folder (just create a folder named �Editor� in the main Assets folder of your project if there isn’t one already). "