Code (CSharp): public static LuaComponent CreateComponent (GameObject g, string componentName,bool enabled = true) { LuaComponent lc = g.AddComponent<LuaComponent>(); lc.componentName = componentName; lc.enabled = enabled; return lc; } Will Awake be called when g.AddComponent is called? Because this is not suitable and I'd like for it to be called after the return.
That doesn't tell me if it will be called directly after AddComponent or the next frame though. I'm curious because lc.componentName NEEDS to be set first.
Code (CSharp): void Awake(){ Debug.Log("Awake called"); } ... LuaComponent lc = g.AddComponent<LuaComponent>(); Debug.Log("Component Created"); ??? Profit
Well crap, Awake is called before I have a chance to initialize the component EDIT : Any way to stop this? EDIT : Duh, I'm dumb, I should just make my own awake function Might help if I initialize the filesystem first haha
Hmm..can you explain a bit more why you would like to initialize the component before ? Also, you could just do a return; in the Awake if you don't want it to execute immediately and later just call another method to initialize or do your stuff.
Because i have to load the code chunk into the Lua subsystem, then it will do it's precompile work, THEN I can call my custom awake function which would call the function Awake() --Do stuff end In the Lua file. I can't have it calling before since there is no loaded code to call.
You could change the script execution order, Or try using OnEnable () http://docs.unity3d.com/Manual/ExecutionOrder.html