- Home /
Use my own update() and start() methods.
I would like to use my own update() and start() methods which would be called directly from a root GameObject that has the expected Update() and Start() methods that Unity calls for MonoBehavior-derived classes. Unity would call Start() of the root game object, and the root game object would store references to the other objects in the scene that need scripted behavior, and call setup methods on those objects. And Unity would also call Update() of the root game object, and the root game object would directly call an update method (named differently than "Update") on the other objects. Unity would not call start or update on any scene objects except for the root game object.
For my project, the advantages are as follows:
Complete control of the sequence of calls
Ability to pass data efficiently as parameters of the direct-called start and update methods.
Access to the complete call stack in the debugger that shows me what has already executed at any point.
What are the disadvantages?
Some extra coding work in setup to find objects and store instances to them for later calls. (For my project, I don't care about setup running slow--just update.)
Maybe the scripted code that calls methods directly is slower than native code in Unity?
Maybe Unity is trying to get some work done between individual calls to MonoBehavior.Update and Start? And a single monolithic start() and update() call chain will impact performance?
I dunno. What do you think? Bad idea?
-Erik
Answer by coldwar98 · Jun 25, 2014 at 09:21 AM
well i dont know what space ship u r making,if u can tell what ur primitive script wants to do i can bet u can do it without these strnge requirment. most u can do without coding is to add ur script to Project settng>script execution order . as far as passing parameters are concerned u can use playerPref function it is life saver. Good luck!!!
Coldwar, somebody else modded you down, sorry. But I don't think you've understood the situation I've described very well. There are lots of things I can do that will work, including setting script execution order as you suggest. The architecture I proposed works too. It is a question about what is BEST and WHY? Also, when you say "I don't know what space ship u r making," it doesn't hurt my feelings, but a more useful thing is to comment on what part of my question you don't understand so that we can have a constructive conversation.
Your answer
Follow this Question
Related Questions
Prevent update until child script start completes? 1 Answer
Script variables resetting on play 0 Answers
C# void names 1 Answer
How do I use iTween outside of start? 0 Answers
bool value does not change 1 Answer