Tasharen Entertainment Forum
Support => NGUI 3 Support => Topic started by: Genhain on May 23, 2014, 01:12:34 AM
-
So I am Attempting to follow the SOLID Principles while using NGUI...Particularly when it comes to the O part the Open/Closed principle and extending any NGUI class that i need a little extra functionality from. Generally the scripts seem to have been made with this in mind, quite a few virtual functions sitting around...However i recently subclassed from UIScrollView and i noticed the Awake function was not protected virtual, and my question is, is this by design or do you think the dev(s) never got round to it? The subclass is working without a hitch...Until of course i want to instantiate my own subclass member variables via Awake() or Start(), then i am out of luck.
-
It's best to do it in Start() rather than Awake(). Awake() is for local member initialization, and is also generally fired before the object is parented properly. Most people seem oblivious of this fact.
-
@ArenMook Yeah i did read into the whole Awake() Start() difference. My question though is that i have subclassed UIScrollView The aforementioned Awake and Start were private so i could not call base.start() from my class, which is kind of needed as you have a lot of stuff going on in both. Easy fix would be to obviously to set them to protected but this violates open/closed principle and i am not sure if it's what you intended or not.
-
Start() is a protected virtual function. Only Awake() is private.