- Home /
Question by
PanDenat · Nov 11, 2015 at 12:59 AM ·
networkinginitializationbestpracticesbest practicescaching
[UNet] Best practice to cache components in NetworkBehaviour
In single player game I used to cache components in Awake or Start for my own comfort (and performance). Like that
private SpriteRenderer _renderer;
void Start()
{
_renderer = GetComponent<SpriteRenderer>();
}
Problem is: in NetworkBehaviour I have OnStartClient, OnStartServer, OnStartLocalPlayer. And nowhere in script reference is stated how it chains with Awake and Start. So where should I cache my components?
I cannot do that in both OnStartClient and OnStartServer because in local match both of them are triggered.
Comment
Your answer
Follow this Question
Related Questions
Should player & pickups be children of the level, or keep them separate? 2 Answers
Unity networking tutorial? 6 Answers
You may not be connected when initializing security layer. 1 Answer
UNET. Proper way to set player's team OnServerAddPlayer. 2 Answers
Best Saving Practices using Firebase 0 Answers