46 lines
1.0 KiB
C#
46 lines
1.0 KiB
C#
using UnityEngine;
|
|
|
|
public class IceEditor : MonoBehaviour
|
|
{
|
|
public GameObject iceTop;
|
|
|
|
public GameObject iceBottom;
|
|
|
|
public Vector2 tilingFactorMain = Vector2.one;
|
|
|
|
public Vector2 tilingFactorSecondary = Vector2.one;
|
|
|
|
private void Start()
|
|
{
|
|
UpdateTiling();
|
|
if ((bool)FisheryEditor.Instance)
|
|
{
|
|
iceBottom.gameObject.SetActive(false);
|
|
}
|
|
}
|
|
|
|
private void LateUpdate()
|
|
{
|
|
if ((bool)FisheryEditor.Instance)
|
|
{
|
|
UpdateTiling();
|
|
}
|
|
}
|
|
|
|
public void UpdateTiling()
|
|
{
|
|
Material material = null;
|
|
for (int i = 0; i < 2; i++)
|
|
{
|
|
material = ((i != 0) ? iceBottom.GetComponent<MeshRenderer>().material : iceTop.GetComponent<MeshRenderer>().material);
|
|
Vector2 one = Vector2.one;
|
|
one.x = base.transform.localScale.x * tilingFactorMain.x;
|
|
one.y = base.transform.localScale.z * tilingFactorMain.y;
|
|
material.mainTextureScale = one;
|
|
one.x = base.transform.localScale.x * tilingFactorSecondary.x;
|
|
one.y = base.transform.localScale.z * tilingFactorSecondary.y;
|
|
material.SetTextureScale("_DetailAlbedoMap", one);
|
|
}
|
|
}
|
|
}
|