Objects disappear on resolution change
I have a strange problem where GameObjects disappear when I change the resolution in the Game tab. All but one stay on the screen. I create the objects through a script and all of them appear when the resolution is 800x600. As soon as I try another resolution though, they go away besides one of them (if I change back to 800x600 they come back); however, if I switch back to Scene view, they are clearly there.
Screenshots:
800x600 Game View: http://imgur.com/vrRdUw5
16:9 Game View: http://imgur.com/q2XITDw
16:9 Scene View: http://imgur.com/C4oLmsk
This is how I create them (Enemy_Orange3):
public GameObject enemyPrefab;
void Start () {
// Spawn each enemy at a Position on screen
foreach(Transform child in transform)
{
GameObject enemy = Instantiate(enemyPrefab, child.transform.position, Quaternion.identity) as GameObject;
enemy.transform.SetParent(child.transform, true);
Debug.Log("Spawning enemy: " + enemyPrefab.name);
}
}
If you look on the left side, Enemy_Orange3 (Clone) is created and clearly there. Why do they disappear?
Answer by MyI · Aug 09, 2016 at 06:37 AM
Never mind, it was a stupid mistake. Some of my prefabs for the enemy ship ended up having a z axis that was lower than the camera's z axis. Camera is at -10 and the prefabs were at -90 for some reason (doesn't explain why they showed up on 800x600 resolution though).
Set them all higher than the camera and they don't disappear anymore.
$$anonymous$$y game flickered in and out of existence at different resolutions and I found when scaling the UI window it would flicker on each frame (some difference in division meaning it just rendered out of existence) - and yep, -4008 on the z axis. Thanks!