using namespace; vs namespace.some_method_or_class_name
I want to know when to use which, i.e., say if i have a gamecontroller class which will run for the entire course of the game. And, i want to use 1-2 functions from a given namespace (which could be big in size) 4-5 times a frame (can vary). So, i want to know which way is better; including the whole namespace (for eg. using UnityEditor;).or using the second way (eg. UnityEditor.Editor in Editor Scripts)?
Can anyone explain which is the better way based on the situation (i.e., acc. to number of times the function is called.)
@Eric5h5 , if you can explain this, that would be awesome.
Answer by tanoshimi · Nov 08, 2016 at 11:54 AM
This is entirely a matter of code style and as such there is no "right" answer. You should do whatever makes your code clearer to understand.
If the namespace is too big, won't it affect the memory being used by the game?,
Absolutely zero effect on memory - the "using" statement only means "in this class I'm going to reference methods from the following namespace, but don't want to have to type it out each time so look for them there".
Follow this Question
Related Questions
Unity performance questions 1 Answer
gfx.WaitForPresent causing performance drops? 1 Answer
5.4 GB of RAM used by editor. 1 Answer
How to optimise image effects on Android? 1 Answer
Multi-core PCs and performance. 0 Answers