Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 12 Next capture
2021 2022 2023
1 capture
12 Jun 22 - 12 Jun 22
sparklines
Close Help
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
avatar image
0
Question by RoughDesign · Sep 23, 2011 at 04:31 PM · javascriptbuild-errortype

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?)

Comment
Add comment · Show 1
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image timberlan9696 · Sep 24, 2011 at 02:40 PM 0
Share

====( 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 )=====

1 Reply

· Add your reply
  • Sort: 
avatar image
0
Best Answer

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.

Comment
Add comment · Show 6 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image RoughDesign · Sep 24, 2011 at 08:46 AM 0
Share

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.

avatar image msknapp · Sep 24, 2011 at 02:08 PM 0
Share

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.

avatar image RoughDesign · Sep 25, 2011 at 10:33 AM 0
Share

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?

avatar image msknapp · Sep 25, 2011 at 01:54 PM 0
Share

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.

avatar image RoughDesign · Sep 25, 2011 at 04:43 PM 0
Share

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!

Show more comments

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this Question

Answers Answers and Comments

3 People are following this question.

avatar image avatar image avatar image

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


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges