- Home /
Type monoScript in javascript
Hi everyone,
I'm using the 'MonoScript' type in one of my javascripts and trying to build, I noticed the script has to be in the "Editor" folder for the type MonoScript to work.
However, when I put it there and build, the script is just left out.
I get no error, but the warning
"Script attached to 'Main Camera' in scene 'Temp/__BuildPlayer Backupscene' is missing or no valid script is attached. UnityEditor.HostView:OnGUI()"
and quite unsurprisingly, the script (showing GUI stuff when ESC is pressed) won't work in the build.
The script is perfectly attached to my GameObject in editor, where it works just fine.
The most similar thing I found on the web was a guy using C# and the problem was that his script didn't derive from MonoBehaviour - but as far as I got it, this is done automatically in javascripts.
So my question is "How can I make the type 'MonoScript' work in javascript?"
PS
I'm using the UART, maybe this does not compile the editor folder on windows?
This thing has its own Editor folder and the readme says it has to be renamed to 'Editor_' before building for windows - but my builds for windows worked without that.
(Can a script tell unity to not build a certain folder when building for windows?)
====( http://www.clothes6.us )=====
online store wholesale sneakers,Jerseys, jewelry, glasses, shirt, sports,handbags,clothes ,news, vogue,jeryse at ugg boots,luxury fashion ysl women boots, christian louboutin boots,ed hardy clothes, jordan shoes,nike shoes,hoodies,t-shirts,nfl jerseys,mlb jerseys,nhl jerseys,coach handbags,handbags,wholesale, retail, sunglasses,belts, caps, ed hardy caps,suit,fashion good,newest style goods All the products are free shipping,
====( http://www.clothes6.us )=====
free shipping
competitive price
any size available
accept the paypal
jordan shoes $32
nike shox $32
$$anonymous$$BT shoes 48
NFL jersys 24
NBA jersys 24
Timberland boots 45
Christan Audigier bikini $20
Ed Hardy Bikini $23
Smful short_t-shirt_woman $14
ed hardy short_tank_woman $15
Sandal $26
christian louboutin $60
Sunglass $14
COACH_Necklace $18
handbag $33
AF tank woman $16
====( http://www.clothes6.us )=====
Answer by msknapp · Sep 23, 2011 at 11:12 PM
Runtime classes cannot use any UnityEditor classes. MonoScript is a UnityEditor class. If you intend on writing an Editor script/class, it must be in the Assets/Editor folder.
Hmyeahhhh but it IS in the Assets/Editor folder!
When I don't put it in this folder, I get some error like "$$anonymous$$onoScript is not a valid type" and it won't build at all.
When i put it in the Editor folder, I get no errors but a warning, it builds and I can start it, just the script is not included.
Long story short, I think you might be confusing $$anonymous$$onoScript with $$anonymous$$onobehaviour. You would never attach a $$anonymous$$onoscript, or an extension of $$anonymous$$onoscript, to a game object. You can only attach classes that inherit from Component onto a game object. $$anonymous$$onobehaviour is an extension of Component, that lets you write your own custom script for the object. $$anonymous$$onoscript is not an extension of Component.
I might have misunderstood you though, are you saying that you have a $$anonymous$$onobehaviour script to attach to your camera, and one of the variables in your script is of type $$anonymous$$onoscript? If that is the case, I have to wonder why on earth you would want it in your class. The monoscript class was designed to help you manage your script files, it is not meant to be extended with a script itself. And why would you want a game whose purpose is to manage the very scripts that were used to compile it? That would not be a fun game...
Unity is designed to prevent you from using editor classes at runtime on purpose. They either cannot support the functionality of the editor classes at runtime, or don't want to for performance or security reasons. Editor classes might make use of the asset database, but at runtime that database might not be available because the game might have been published as an independent executable. That is one example why a class might belong to the editor api and not the runtime engine api.
So what we should really be discussing is why you need to use the $$anonymous$$onoscript class, I seriously doubt that it is what you want to use.
Thank you for the time you already put into this, msknapp.
I have a script attached to my main camera.
In this script, I want to access several other scripts' (public) variables,
so I wanted to declare a public array to which i can assign the other scripts in the editor.
So I think it's that i was confusing it with $$anonymous$$onoBehaviour...
That would mean I would have to go for
var myScripts : $$anonymous$$onoBehaviour[];
right?
you could do that, but the problem there is your array has no logic to resize itself. Which means you will probably have an index out of bounds exception sooner or later. You should use the "Array" class and use its Push method to add $$anonymous$$onobehaviours ins$$anonymous$$d.
I want to assign the scripts in the editor and there will be no changes made to that in the game lateron, so I'm gonna try with these .NET arrays first. If it doesn't work, I know what to do, thanks!
Your answer
![](https://koobas.hobune.stream/wayback/20220612222910im_/https://answers.unity.com/themes/thub/images/avi.jpg)
Follow this Question
Related Questions
type not found 1 Answer
after build, crash when dbcon.Open(); 0 Answers
How do I perform math on Vector3.x or Vector4.x as if it were a float? 3 Answers
How to draw another camera's view without "Handles"-class? 0 Answers
Is it possible to use a custom object in java (my WeaponObject) as a data type (like Vector3) 1 Answer