Switching from Main Camera to String Augmented Reality Camera

Hey everyone,

I am developing an application that is using string for Augmented Reality. A brief background is that a student will be able to take an Ipad and reconstruct a wall with different materials such as if they wanted to change the pre-existing glass of the wall to be brick or copper or even stone they would be able to do so and then view that model that they have been working on in Augmented Reality. I am trying to do this by using 2 different cameras. The one camera is of course the main camera that holds the script for the drawing interface with the model that they are working on. The second camera will of course hold the script for String.

I have tried researching multiple posts about switching Cameras and have not been able to find one that works. My issue is that on load the camera of choice is always String, where as it should be the mainCamera until the user selects the View Model Button.

Does anyone have any idea of what I am doing wrong? Below is code as to what I have written that does not seem to work:

Thank you very much :o

function Start()
{
mainCamera.enabled = true;
mainCameraEnabled = true;
stringCameraEnabled = false;
stringCamera.enabled = false;
}
function Update()
{
	if(mainCameraEnabled == true)
	{
	mainCamera.enabled = true;
	stringCamera.enabled = false;
	}
	if(stringCameraEnabled == true)
	{
	stringCamera.enabled = true;
	mainCamera.enabled = false;
	}
}
function OnGUI()
{
if(GUILayout.Button("View Model", GUILayout.Height(backButtonSpacing)))
		{
			stringCameraEnabled = true;
			
			if(stringCameraEnabled == true)
			{
			stringCamera.enabled = true;
			mainCamera.enabled = false;
			}
			
		}
}

have you tried stripping away all code and simply puttin gthis in update

mainCamera.enabled = true;
stringCamera.enabled = false;

make sure mainCameraEnabled is not public in case another script is referencing it and changing its value, same for the other camera of course

I have, I think I have found the root cause. This all is in UnityScript, but String provides a whole script in itself for the application that just needs minor tweaking. What I was thinking the reason it is going straight to String is with the Function Awake() within the Script that String provides. This script is in C# so I feel that if I just write a simple C# script with the code provided above and tweek the other script, possibly this will fix my situation.

Thank you though for the response!

ya mixing the 2 might be an issue,
i know that depending on where your scripts are there is a way to control what script gets compiled before the other one. so make sure the script you trying to refrence gets compiled first.

that or use sendmessage or some sort of event msgg