Using Scripts in AssetBundles

Hi!

I’ve created a project where when buttons are pressed, a different model comes up, this is a cut down version of my script:

#pragma strict

private var ray: Ray;
private var hit: RaycastHit;

private var bombard : GameObject;
private var constrict : GameObject;

function Start () {

bombard = GameObject.Find("ImageTarget/GameObject/Bombarding machine");
constrict = GameObject.Find("ImageTarget/GameObject/Constrictor");

bombard.SetActive(false);
constrict.SetActive(false);
}

function Update () {

if(Input.GetMouseButtonDown(0)){
	ray=Camera.main.ScreenPointToRay(Input.mousePosition);
	if(Physics.Raycast(ray, hit)){
	if(hit.transform.name == "Bom HL"){
	bombard.SetActive(true);
	constrict.SetActive(false);
	
	}
	if(hit.transform.name == "Cons HL"){
	bombard.SetActive(false);
	constrict.SetActive(true);
}
}
}
}

The script was originally on the Empty GameObject, within the ImageTarget (Augmented Reality) but when I created an AssetBundle out of the Empty GameObject (and it’s contents) the script wouldn’t work, thus all the models were active on start up instead of only when clicked. Basically, the script isn’t working.

I then tried to go back and put the script on the Image Target, which isn’t in the AssetBundle, and re-bundle it. However, it did the same thing. On both occasions, when I clicked the buttons, it came up with a NullReferenceException.

Is there a bit of script I need to put in in order to tell the AssetBundle to apply the script? And should it go in the AssetBundle or remain outside of it?

For anyone else who’s struggling with this, I found that scripts can be used within asset bundles but they must be built directly into them.
Also if using the GameObject.Find function, don’t do a long path through your project; try and put it on the parent object so you only have to reference the name of the asset you need to find. This then prevents the NullReferenceException