Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 13 Next capture
2021 2022 2023
1 capture
13 Jun 22 - 13 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
1
Question by vexe · Jun 20, 2014 at 03:38 PM · javascriptdllcompile

When JS scripts compiles into a dll, the Start, Update, etc methods all are 'overrides'? and... there's also a 'Main' method?

So I was messing with manual compilation a bit, and compiled a simple JS script into a dll:

TestJs.js

 #pragma strict
 
 function Update() { }
 function Start() { }

I looked at the generated dll, and was quite surprised...

alt text

I'm not a JS dude, so I could be missing something simple. But, what are we 'overriding', and who the hell is this "Main"?!

compile.png (20.8 kB)
Comment
Add comment · Show 4
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 meat5000 ♦ · Jun 20, 2014 at 03:57 PM 0
Share

$$anonymous$$ain() is the Universal Entry point.

Which languages do you know (not necessarily for Unity)? A good few I assume.

I have to be honest, I'm quite new to JS but I do know that in JS $$anonymous$$ain() is just another function, not like the one in C, for example. I imagine it's there for convention. Perhaps as a helper function. In the stats window rests the '$$anonymous$$ain Thread' time so this could indicate some forced entry point or C compatibility function.

As a guess.

avatar image tanoshimi · Jun 20, 2014 at 04:03 PM 0
Share

There was a thread on this site recently about $$anonymous$$ain(), but I can't now find it.

From simple tests, it appears that any code placed inside $$anonymous$$ain() in a $$anonymous$$onoBehaviour will be called after Awake() but before Start(), but given it's undocumented and doesn't provide any functionality beyond those two existing hooks, I would personally leave it alone. Interesting to note that it exists in the compiled dll as well though.

avatar image vexe · Jun 20, 2014 at 04:05 PM 0
Share

@meat5000

$$anonymous$$ain() is the Universal Entry point.

That is, in executables, not dlls.

avatar image meat5000 ♦ · Jun 20, 2014 at 04:13 PM 0
Share

Ok :) Thanks for the clarification.

I learned program$$anonymous$$g as an Engineer. Still getting to grips with the Computer Sciency aspect of program$$anonymous$$g :D

1 Reply

· Add your reply
  • Sort: 
avatar image
0

Answer by Landern · Jun 20, 2014 at 04:01 PM

But, what are we 'overriding', and who the hell is this "Main"?!

You're overriding the base implementation that exists in MonoBehavior in favor of your implementation, the state machine needs to have some consistency when calling methods.

Main is just a another method available, probably not documented due to UT either not expecting a user to override it typically or it has a very particular execution path that is generally covered by Awake/Start.

Comment
Add comment · Show 1 · 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 vexe · Jun 20, 2014 at 04:10 PM 0
Share

You're overriding the base implementation that exists in $$anonymous$$onoBehavior

Start, Awake, Update etc are not located in $$anonymous$$onoBehaviour - They're called from the C++ side - See Lucas's comments at the end of this blog (which kind of drifted away at the end...)

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

23 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

How to use (AVPro) plugin with JavaScript. 1 Answer

unity allow player to script a object or compile and run a code in runtime 1 Answer

Why can't I build Web Player in Unity while I have no problems with building standalone versions? 2 Answers

How do you compile a managed dll with mono/mcs targeting .net 2.0 or 3.5 for Unity? 1 Answer

Including a DLL in unity? 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