i’m using unity3d 3 with c#
here is my code
void Start()
{
debug.log(screen.width);
}
void Update()
{
debug.log(screen.width);
}
why the first output is wrong ,
i’m using unity3d 3 with c#
here is my code
void Start()
{
debug.log(screen.width);
}
void Update()
{
debug.log(screen.width);
}
why the first output is wrong ,
I assume that’s meant to be “Screen.width” rather than “screen.width”, and “Debug.Log” rather than “debug.log”. If so, then presumably you’re using “Maximize on Play”, which is not working correctly in Unity 3. The first couple of frames use the screen width and height from the non-maximized game view. The options are 1) Don’t use maximize on play, or 2) Wait a few frames after game start before getting screen width and height, or 3) Wait for a new version of Unity which hopefully will have this fixed.
–Eric
sorry for the incorrect code,
i do not use maxmize on play,so i think the second option may become a good solution ,but how can i achieve it?
here is my solution
void Awake()
{
StartCoroutine(initial());
}
IEnumerator initial()
{
//for screen attribute will be wrong if initial immediately
yield return new WaitForEndOfFrame();
//do your stuff
}