using System; using System.Collections; using System.Collections.Generic; using UnityEngine; public class WaterRangeCtrlTool : MonoBehaviour { public static WaterRangeCtrlTool _Instance; public GameObject[] FxObjects; public Material waterRangeMat; public AnimationCurve waterCurveSZ; public AnimationCurve waterCurveVZ; public AnimationCurve waterCurve_65000; public int waterCurveIndex { private set; get; } private void Awake() { _Instance = this; FxObjects = new GameObject[this.transform.childCount]; for (int i = 0; i < FxObjects.Length; i++) { FxObjects[i] = this.gameObject.transform.GetChild(i).gameObject; FxObjects[i].SetActive(true); } waterRangeMat = this.transform.Find("NeiHe_FenQu").GetComponent().material; ChangeWaterCurve(0); } public void ShowFx(bool reSetValue) { if (reSetValue) { SetRangeValue(1); } for (int i = 0; i < FxObjects.Length; i++) { FxObjects[i].SetActive(true); } } public void HideFx() { for (int i = 0; i < FxObjects.Length; i++) { FxObjects[i].SetActive(false); } } public void SetRangeValue(float value) { float rangeValue=0; switch (waterCurveIndex) { case 0 : rangeValue = waterCurve_65000.Evaluate(value); break; case 1 : rangeValue = waterCurve_65000.Evaluate(value); break; } waterRangeMat.SetFloat("_ClipLength",rangeValue); } public void ChangeWaterCurve(int index) { waterCurveIndex = index; } }