Here is the script which takes care of what you need. Just attach to the game object where the material is assigned. You may remove this script when you are done editing the level, it wont be needed at all.
Added a few more optimization
- Update only on change in transform
- Update only if it is Unity editor and not in play mode
- Scale factor
TextureResize.cs
using UnityEngine;
using System.Collections;
[ExecuteInEditMode]
public class TextureResize : MonoBehaviour
{
public float scaleFactor = 5.0f;
Material mat;
// Use this for initialization
void Start ()
{
Debug.Log("Start");
GetComponent<Renderer>().material.mainTextureScale = new Vector2 (transform.localScale.x / scaleFactor , transform.localScale.z / scaleFactor);
}
// Update is called once per frame
void Update ()
{
#if UNITY_EDITOR
if (transform.hasChanged && Application.isEditor && !Application.isPlaying)
{
Debug.Log("The transform has changed!");
GetComponent<Renderer>().material.mainTextureScale = new Vector2 (transform.localScale.x / scaleFactor , transform.localScale.z / scaleFactor);
transform.hasChanged = false;
}
#endif
}
}
Edit:- All these things are going to be pretty straight forward with unity's upcoming updates. Hopefully it will be out soon :)