Maya objects not GameObjects?

Hi folks,

I’ve been testing a bunch of scripts with scenes populated just with cubes etc.

Got them working and decided to import a maya object to see how everything works. Exported from Maya using Maya’s own FBX exporter, single object.

Got rid of the cubes, pulled in the Maya objects and set the Tags as I wanted them. Now it’s saying;

NullReferenceException: Object reference not set to an instance of an object

I haven’t changed the script at all;

var FstFloor : GameObject[];
FstFloor = GameObject.FindGameObjectsWithTag("firstfloor");

function Start () {
for (var i = 0; i < FstFloor.length; i++) {
			FstFloor[i].GetComponent(MeshRenderer).enabled = false;
		}
}

Anyone know why it’s suddenly stopped working? Does the GameObject need changing? Am I using wrong FBX export settings? (tried importing the .mb and .ma files and letting Unity do the importing, but it just crashed out)

Thanks folks!

  • Jon

If I am thinking of this right… Add the maya model to a prefab then populate the scene with that prefab, re add your tags and retry your script.

You should move the assignment of FstFloor into Start() to ensure everything is initialized before you call it.