Different GUITextures on rotation

I’m trying to get it so that when you have the iPhone in landscape it will show one image (as a GUI Texture) and if in Portrait it would show a different image (again GUI Texture)

If got this code so far,

var iPhoneTextureLeft : GUITexture;
var iPhoneTexturePortrait : GUITexture;

function FixedUpdate(){ 

if ((iPhoneInput.orientation == iPhoneOrientation.LandscapeLeft)  (iPhoneSettings.screenOrientation != iPhoneScreenOrientation.LandscapeLeft)){ 
iPhoneSettings.screenOrientation = iPhoneScreenOrientation.LandscapeLeft; 
} 
if ((iPhoneInput.orientation == iPhoneOrientation.LandscapeRight)  (iPhoneSettings.screenOrientation != iPhoneScreenOrientation.LandscapeRight)){ 
iPhoneSettings.screenOrientation = iPhoneScreenOrientation.LandscapeRight; 
} 
if ((iPhoneInput.orientation == iPhoneOrientation.Portrait)  (iPhoneSettings.screenOrientation != iPhoneScreenOrientation.Portrait)){ 
iPhoneSettings.screenOrientation = iPhoneScreenOrientation.Portrait; 
} 
if ((iPhoneInput.orientation == iPhoneOrientation.PortraitUpsideDown)  (iPhoneSettings.screenOrientation != iPhoneScreenOrientation.PortraitUpsideDown)){ 
iPhoneSettings.screenOrientation = iPhoneScreenOrientation.PortraitUpsideDown; 
} 
iPhoneKeyboard.autorotateToPortrait = false; 
iPhoneKeyboard.autorotateToPortraitUpsideDown = false;
iPhoneKeyboard.autorotateToLandscapeLeft = false;
iPhoneKeyboard.autorotateToLandscapeRight = false;
}

function Start()
{
	if (iPhoneOrientation.LandscapeLeft) guiTexture.texture = iPhoneTextureLeft;
	if (iPhoneOrientation.LandscapeRight) guiTexture.texture = iPhoneTextureLeft;
	if (iPhoneOrientation.Portrait) guiTexture.texture = iPhoneTexturePortrait;
	if (iPhoneOrientation.PortraitUpsideDown) guiTexture.texture = iPhoneTexturePortrait;
}

However if I then put the 2 GUI Texture’s in the scene and into the inspector they lay one on top of the other and if I build to a device it just crashes.

Hope someone can help :smile:

Try putting a print statement in the Start function and the FixedUpdate function. This should help you determine the point at which Unity crashes. This information should help narrow down what is causing the problem.

Thanks Andeee, :smile:

It only crashes on the device when I build it, and I get a Bad Exec error in xcode.

I think it’s me being stupid here. Coding isn’t a strong point. I think I can see what I want to do but i’m going about it the wrong way.