Renderer.enabled not working on build

Hi all, this is my first request on these forums. I’ve already gotten so much good information from silently browsing, but now I need to actually ask a question.

I am using “renderer.enabled” on a mesh to hide/show it. It should default to off, but if the user clicks the “on” button, it should turn on. It should be super simple, and it is.

Everything works perfectly in Unity, but once I compile for iPhone, the button no longer works. If I set the default setting to true, the item appears, and won’t shut off, if it’s set to off, it won’t turn on.

Anyone have an idea why this would be happening on iPhone and not in Unity?

Not off the top of my head, do you have some sample code?

Note: it’s best to post iPhone specific questions in iPhone Development as that’s where folks look for these sorts of questions. I’ll move your thread there now. :slight_smile:

Thanks for your help, Tom. I have tried many solutions. Here are the relevant parts of the code that should be working:

function Update () {
	if (hasPigtails == 1) {
		pigtailsModel.renderer.enabled = true;
	} else { 
		pigtailsModel.renderer.enabled = false;
	};
}

function pigtailsOn () {
	pigtailsModel.renderer.enabled = true;
	hasPigtails = 1;
}	

function pigtailsOff () {
	pigtailsModel.renderer.enabled = false;
	hasPigtails = 0;
}

if (GUI.Button( Rect( 120, 40, 40, 40), "Pigtails"))
	{
		if (hasPigtails == 1) {
			hasPigtails = 0;
			pigtailsOff ();
		} else {
			hasPigtails = 1;
			pigtailsOn ();
		}
	}

I know there is some redundancy in here, that’s intentional. I’ve been trying to break it down to it’s simplest forms, and trying everything I can think of. I HAVE TRIED each of these individually as well. In Unity, it worked without being called in Update, and without the function. Simply using the gui button to click on/off renderer.enabled worked perfectly. But on the phone, none of them work, not Update, not calling it from within a function…

Funny thing is, if I set it to 1 outside the button code, it displays, but then the button won’t turn it off. If I set it to 0, it won’t turn on. At least this proves to me that the mesh CAN be displayed on the phone.

Ok, I admit a silly mistake, but I’ll chalk it up to experience and being a Unity n00b.

In case this happens to anyone else, make sure you drag the model from the hierarchy pane, NOT the project pane! Now it works perfectly on the iphone!