Ejemplo n.º 1
0
 // Use this for initialization
 void Start()
 {
     transform       = this.GetComponent <Transform>();
     LightsBehaviour = gameObject.GetComponentInParent <LightsBehaviour>();
     textTransform   = transform.Find("Text");
     textTransform.gameObject.SetActive(false);
     audioSource = this.GetComponent <AudioSource>();
 }
Ejemplo n.º 2
0
    private void SetComponents(GameObject go, int i, int j)
    {
        // add a mesh filter, a mesh renderer, a mesh collider and then construct the mesh (also pass the iteration steps for reference)
        BuildMesh(go.AddComponent <MeshFilter>(), go.AddComponent <MeshRenderer>(), go.AddComponent <MeshCollider>(), i, j);

        // add the script for lights and set up the variables
        LightsBehaviour lb = go.AddComponent <LightsBehaviour>();

        lb.onMaterial    = blockMaterialLight;
        lb.offMaterial   = blockMaterialDark;
        lb.connectedGrid = grid;
        // perform a light switch back and forth so the object picks up the newly assigned materials (kind of messy, but harmless enough)
        lb.SwitchLights();
        lb.SwitchLights();
    }