I have different sized objects that have the same material attached to them (wood, metal, etc). So if i have the tiling of the material look great on a cube but then scale the cube out the material stretches and I want to know if there is an easy way for the texture tile to remain the same size throughout all the game objects (no matter what their size)? Or if there is a way for the material tiling to auto-update as I scale an object bigger or smaller?
This is not a nice method but you could add a script that changes the tiling of the instance of material that is set to the gameobject based on the gameobjects format (width to height).
I don’t know if there is something that does i automatically for you but thats what i’d do.
This might be what you’re looking for.
This is an official page from Unity that talks about scaling textures through code in both C# and Javascript.
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class AdjustTiling : MonoBehaviour
{
public float z_scale = 1;
void Start()
{
for (int i = 0; i < transform.childCount; i++)
{
GameObject wall = transform.GetChild(i).gameObject;
Renderer wall_renderer = wall.GetComponent<Renderer>();
wall_renderer.material = new Material(wall_renderer.material);
Vector3 scale = wall.transform.localScale;
wall_renderer.material.mainTextureScale = new Vector2(scale.z* z_scale,
wall_renderer.material.mainTextureScale.y);
}
}
}
I connected this script to an empty object parent of all the objects that had the tiling problem. Additionaly the only side that changed in my objects was the Z, so I modified the z only