using System.Collections; using System.Collections.Generic; using UnityEngine; //============================================================ //支持中文,文件使用UTF-8编码 //@author Adam //@create 20240607 //@company Adam // //@description: //============================================================ namespace Components { public class LadderCtr : MonoBehaviour { private SkinnedMeshRenderer smr; public List ladders = new List(); public float minValue = 0f; public float maxValue = 100f; public float t = 0.08f; public float interpolatedValue; public bool isPlay = false; // Use this for initialization public Transform playerPos; public void SwitchLadder(string ladderName) { if (ladderName != "") { gameObject.SetActive(true); isPlay = true; GameObject ladder = null; for (int i = 0; i < ladders.Count; i++) { int index = i; ladders[index].SetActive(false); if (ladders[index].name.Equals(ladderName)) { ladders[index].SetActive(true); ladder = ladders[index]; } } smr = ladder.GetComponentInChildren(); } else { isPlay = false; smr.SetBlendShapeWeight(0, 0); gameObject.SetActive(false); } } private void Update() { if (!isPlay) return; interpolatedValue = Mathf.Lerp(interpolatedValue, maxValue, t); smr.SetBlendShapeWeight(0, interpolatedValue); if (interpolatedValue > (maxValue - 8f)) { isPlay = false; } } } }