To prevent unity from having to reevaluate an if statement each frame, i would like to know if its possible to reassign the update function via script during runtime. So that only after a specific event the Update-function gets activated
like:
function myOwnUpdate()
{
DosomethingRealImportant();
}
function onImportandEvent()
{
// after this, myOwnUpdate get's called each frame
Update = myOwnUpdate;
}
Is this possible ? - I’m coming from Actionscript, where this IS indeed possible…
I think you should not worry about the performance impact of one if-statement. Unless your update is called thousands upon thousands of times per frame and has virtually no other code besides that if-statement, the performance impact will be unmeasurable.
The trick is not not to care about performance until you run into to actual performance problems. If you don’t, you’re bound to sacrifice program readability and possibly stability for slightly better performance of code that is not even a bottleneck.
your site, and the great graphics&gameplay of “Temple Troubles” was some major motivation to dig deeper into AS3 coding. Over the last few years I revamped pre-AS3 coded flashgames (3D GFX codewise), and i really started to love AS3 - but hey -now its unity time
Anyway - back then i thought it would be cool to work at your company (since you got job offers for both 3ds max + Flash game programmer) - but here’s me, still sitting in Vienna, fighting to make a living with all this indie/casual gameing stuff myself…
one of the things u can do is code several update methods UpdateCaseWorking, UpdateCaseLeaving, UpdateCaseInProcess,… and then have ur update method call the proper one through a function delegate called currentUpdateMethod.