I am trying to swap an object in a scene using code. I have successfully done it with materials but some objects require the whole mesh to be changed. can someone help me please my code so far is:
public var chairs : Mesh[];
function ChangeChair(inx : int){
var meshf : Mesh = GetComponent(MeshFilter).mesh;
meshf.MeshFilter.mesh = chairs[inx];
}
function OnGUI(){
if (GUI.Button (Rect (20,100,80,20), "Chair 1")) {
ChangeChair(0);
}
if (GUI.Button (Rect (20,120,80,20), "Chair 2")) {
ChangeChair(1);
}
}