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)];

        //Get script of previous mesh
        bumperUnderside = GameObject.Find("Van1BumperUnderside").GetComponent <Van1BumperUnderside>();
        bumperInward    = GameObject.Find("Van3BumperInward").GetComponent <Van3BumperInward>();
        grillSlant      = GameObject.Find("Van5GrillSlant").GetComponent <Van5GrillSlant> ();
        bonnet          = GameObject.Find("Van6Bonnet").GetComponent <Van6Bonnet> ();
        rearEnd         = GameObject.Find("Van10RearEnd").GetComponent <Van10RearEnd> ();
        rearBumper      = GameObject.Find("Van11RearBumper").GetComponent <Van11RearBumper> ();
        rearBumperDown  = GameObject.Find("Van12RearBumperDown").GetComponent <Van12RearBumperDown> ();

        //Create the mesh
        CreateMesh();
    }
Beispiel #2
0
    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)];

        //Get script of previous mesh
        bumperUnderside = FindObjectOfType <Van1BumperUnderside>();

        //Create the mesh
        CreateMesh();
    }