I am trying to make a texture tile through a script based on my object’s scale, in Unity 2018.30f2 it works great but the same code does nothing in Unity 2019.2 using the LWRP.
As mentioned the code below works in Unity 2018.30f2 but not in Unity 2019.2 using the LWRP.
and according to the documentation, this is the way to do it?
This is my code:
cube.GetComponent<Renderer>().material.mainTextureScale = new Vector2( 1.5f, 1.5f);
This is the documentation Code:
using UnityEngine;
public class Example : MonoBehaviour
{
Renderer rend;
void Start()
{
rend = GetComponent<Renderer>();
}
void Update()
{
// Animates main texture scale in a funky way!
float scaleX = Mathf.Cos(Time.time) * 0.5f + 1;
float scaleY = Mathf.Sin(Time.time) * 0.5f + 1;
rend.material.mainTextureScale = new Vector2(scaleX, scaleY);
}
}