using UnityEngine;
using System.Collections;

public class MaterialRepeaterThing : MonoBehaviour
{

    void Start()
    {
        ManualUpdate();
    }   


    public void ManualUpdate()
    {
        GameObject[] horizontalBlocks = GameObject.FindGameObjectsWithTag("HorizontalBlock");
        foreach(GameObject gObj in horizontalBlocks)
        {
            Vector2 textureScale = new Vector2(gObj.transform.lossyScale.x / 10.0f, gObj.transform.lossyScale.z / 10.0f);
            gObj.renderer.material.SetTextureScale("_Underlay", textureScale);
            gObj.renderer.material.SetTextureScale("_Overlay", textureScale);
            gObj.renderer.material.SetTextureScale("_Normal", textureScale);
            gObj.renderer.material.SetTextureScale("_Emissive", textureScale);
        }

        GameObject[] verticalBlocks = GameObject.FindGameObjectsWithTag("VerticalBlock");
        foreach (GameObject gObj in verticalBlocks)
        {
            Vector2 textureScale = new Vector2(gObj.transform.lossyScale.x / 10.0f, gObj.transform.lossyScale.y / 10.0f);
            gObj.renderer.material.SetTextureScale("_Underlay", textureScale);
            gObj.renderer.material.SetTextureScale("_Overlay", textureScale);
            gObj.renderer.material.SetTextureScale("_Normal", textureScale);
            gObj.renderer.material.SetTextureScale("_Emissive", textureScale);
        }
    }
}