修复bug,重构yarn

This commit is contained in:
2024-12-12 16:58:45 +08:00
parent aee673a041
commit caf2d50e5e
14 changed files with 1072 additions and 349 deletions
@@ -2,6 +2,7 @@
using UnityEngine;
using UnityEngine.UI;
using Yarn.Unity;
using DG.Tweening;
public class HeatMapController : MonoBehaviour
{
@@ -65,38 +66,30 @@ public class HeatMapController : MonoBehaviour
public void SetDataToMaterial()
{
// uftempture=tempture;
// uftempture=Map(uftempture,0,3,1.5f,2.6f);
// backtemture=tempture;
// backtemture=Map(backtemture,0,3,1.5f,3.6f);
// modulesTempture=tempture;
// modulesTempture=Map(modulesTempture,0,3f,1.5f,2.3f);
if (tempture <= 1)
if (tempture >=0&&tempture<=1)
{
uftempture = Mathf.Lerp(1.5f, 2.4f, tempture ); // 线性插值
modulesTempture = Mathf.Lerp(1.5f, 2.1f, tempture)-tempNum;
backtemture = Mathf.Lerp(1.5f, 2.1f, tempture);
uftempture = Mathf.Lerp(1.5f, 2.8f, tempture ); // 线性插值
modulesTempture = Mathf.Lerp(1.5f, 1.8f, tempture);
backtemture = Mathf.Lerp(1.5f, 2.25f, tempture);
}
else if (tempture <= 2)
else if (tempture >= 1&&tempture<=2)
{
uftempture = Mathf.Lerp(2.4f, 2.7f, tempture - 1);
modulesTempture = Mathf.Lerp(2.1f, 2.3f, tempture - 1);
backtemture = Mathf.Lerp(2.1f, 3.6f, tempture - 1);
}
else
{
uftempture =2.7f;
modulesTempture = 2.6f;
backtemture = 3.8f;
uftempture = Mathf.Lerp(2.8f, 3.2f, tempture - 1);
modulesTempture = Mathf.Lerp(1.8f, 2.3f, tempture - 1);
backtemture = Mathf.Lerp(2.25f, 3.4f, tempture - 1);
}
// else if (tempture >= 2)
// {
// uftempture =3.2f;
// modulesTempture = 2.6f;
// backtemture = 3.8f;
// }
for (int i = 0; i < 7; i++)
{
RectTransform transform=Pos[i].GetComponent<RectTransform>();
Debug.Log($"Point {i}: {points[i]}");
if(i==0)
{
@@ -120,9 +113,19 @@ public class HeatMapController : MonoBehaviour
heatMaterial.SetVectorArray("_Properties", properties);
}
public void SetTemptureDirect(float value)
{
Tempture = value;
}
public void SetTemptureSmooth(float targetValue, float duration)
{
DOTween.To(() => tempture, x => Tempture = x, targetValue, duration);
}
float Map(float value, float minSource, float maxSource, float minTarget, float maxTarget)
{
return minTarget + (value - minSource) * (maxTarget - minTarget) / (maxSource - minSource);
}
{
return minTarget + (value - minSource) * (maxTarget - minTarget) / (maxSource - minSource);
}
}