void Start() { //Create a mesh filter while also assigning it as a variable to get the mesh property MeshFilter meshFilter = gameObject.AddComponent <MeshFilter> (); //Create a mesh renderer so we can actually display the mesh gameObject.AddComponent <MeshRenderer> (); //Set the mesh object to be that of the mesh from the mesh filter mesh = meshFilter.mesh; //Set a random material Object[] loadedMaterials = Resources.LoadAll("Materials"); gameObject.GetComponent <Renderer> ().material = (Material)loadedMaterials [Random.Range(0, loadedMaterials.Length - 2)]; upwardFrontBumper = FindObjectOfType <Classic3UpwardFrontBumper> (); CreateMesh(); }
void Start() { //Create a mesh filter while also assigning it as a variable to get the mesh property MeshFilter meshFilter = gameObject.AddComponent <MeshFilter> (); //Create a mesh renderer so we can actually display the mesh gameObject.AddComponent <MeshRenderer> (); //Set the mesh object to be that of the mesh from the mesh filter mesh = meshFilter.mesh; //Set a random material Object[] loadedMaterials = Resources.LoadAll("Materials"); gameObject.GetComponent <Renderer> ().material = (Material)loadedMaterials [Random.Range(0, loadedMaterials.Length - 2)]; frontBumper = GameObject.Find("Classic1FrontBumper").GetComponent <Classic1FrontBumper> (); upwardFrontBumper = GameObject.Find("Classic3UpwardFrontBumper").GetComponent <Classic3UpwardFrontBumper> (); bonnetPartA = GameObject.Find("Classic4BonnetPartA").GetComponent <Classic4BonnetPartA> (); bonnetPartB = GameObject.Find("Classic4BonnetPartB").GetComponent <Classic4BonnetPartB> (); rearBody = GameObject.Find("Classic6RearBody").GetComponent <Classic6RearBody> (); rearBottom = GameObject.Find("Classic8RearBottom").GetComponent <Classic8RearBottom> (); CreateMesh(); }