Start to integrate the artwork
This commit is contained in:
@@ -0,0 +1,66 @@
|
||||
using UnityEngine;
|
||||
|
||||
[RequireComponent(typeof(Renderer))]
|
||||
public class TextureTiler : MonoBehaviour
|
||||
{
|
||||
[SerializeField]
|
||||
private float textureWorldSize = 1f;
|
||||
|
||||
public enum Surface
|
||||
{
|
||||
Floor, // X × Z
|
||||
WallX, // Y × Z
|
||||
WallZ // X × Y
|
||||
}
|
||||
|
||||
[SerializeField]
|
||||
private Surface surface = Surface.Floor;
|
||||
|
||||
private Renderer rend;
|
||||
|
||||
private void Start()
|
||||
{
|
||||
rend = GetComponent<Renderer>();
|
||||
UpdateTiling();
|
||||
}
|
||||
|
||||
private void UpdateTiling()
|
||||
{
|
||||
Vector3 size = transform.lossyScale;
|
||||
|
||||
float width;
|
||||
float height;
|
||||
|
||||
switch (surface)
|
||||
{
|
||||
case Surface.Floor:
|
||||
width = size.x;
|
||||
height = size.z;
|
||||
break;
|
||||
|
||||
case Surface.WallX:
|
||||
width = size.z;
|
||||
height = size.y;
|
||||
break;
|
||||
|
||||
case Surface.WallZ:
|
||||
width = size.x;
|
||||
height = size.y;
|
||||
break;
|
||||
|
||||
default:
|
||||
width = size.x;
|
||||
height = size.y;
|
||||
break;
|
||||
}
|
||||
|
||||
float tilesX = width / textureWorldSize;
|
||||
float tilesY = height / textureWorldSize;
|
||||
|
||||
// URP
|
||||
rend.material.SetTextureScale(
|
||||
"_BaseMap",
|
||||
new Vector2(tilesX, tilesY)
|
||||
);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user