NewN_UAVPlane/Assets/Temp/Scripts/Pluginweather.cs

81 lines
2.6 KiB
C#

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
namespace Tenkoku.Demo
{
public class Pluginweather : MonoBehaviour
{
public float uiScale = 1.0f;
private Tenkoku.Core.TenkokuModule tenkokuObject;
private UnityEngine.UI.CanvasScaler uiCanvasScale;
private Slider sunshine;//阳光的亮度
public Button Therain1;//雨的按钮
public Button Therain2;
public Button Therain3;
public Button Therain4;
public Button Therain5;
public Button snow1;//雪的按钮
public Button snow2;
public Button snow3;
public Button snow4;
public Button snow5;
public float currentTODVal = -1.0f;
void Start()
{
tenkokuObject = (Tenkoku.Core.TenkokuModule)FindObjectOfType(typeof(Tenkoku.Core.TenkokuModule));
uiCanvasScale = this.transform.GetComponent<UnityEngine.UI.CanvasScaler>() as UnityEngine.UI.CanvasScaler;
sunshine = GameObject.Find("Canvas/Contingency_editing_panl").transform.GetChild(6).transform.GetChild(0).transform.GetChild(10).GetComponent<Slider>();
Therain1.onClick.AddListener(() =>
{
tenkokuObject.weather_RainAmt = 0.0f;
});
Therain2.onClick.AddListener(() =>
{
tenkokuObject.weather_RainAmt = 0.25f;
});
Therain3.onClick.AddListener(() =>
{
tenkokuObject.weather_RainAmt = 0.5f;
});
Therain4.onClick.AddListener(() =>
{
tenkokuObject.weather_RainAmt = 0.75f;
});
Therain5.onClick.AddListener(() =>
{
tenkokuObject.weather_RainAmt = 1.0f;
});
snow1.onClick.AddListener(() =>
{
tenkokuObject.weather_SnowAmt = 0.0f;
});
snow2.onClick.AddListener(() =>
{
tenkokuObject.weather_SnowAmt = 0.25f;
});
snow3.onClick.AddListener(() =>
{
tenkokuObject.weather_SnowAmt = 0.5f;
});
snow4.onClick.AddListener(() =>
{
tenkokuObject.weather_SnowAmt = 0.75f;
});
snow5.onClick.AddListener(() =>
{
tenkokuObject.weather_SnowAmt = 1.0f;
});
}
void LateUpdate()
{
uiCanvasScale.scaleFactor =uiScale;
tenkokuObject.weather_SnowAmt = Mathf.Lerp(0.0f,1.0f, sunshine.value);
}
}
}