| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950 |
- using System.Collections;
- using System.Collections.Generic;
- using UnityEngine;
- using UnityEngine.UI;
- public class DebugFor9AxisCameraLerp : MonoBehaviour
- {
- static bool openLerp = true;
- static float lerpValue = 15f;
- Slider slider;
- Text text;
- Button btn;
- void Start()
- {
- slider = transform.Find("BG/Slider").GetComponent<Slider>();
- text = transform.Find("BG/Text").GetComponent<Text>();
- btn = transform.Find("BG/Button").GetComponent<Button>();
- slider.onValueChanged.AddListener((float v) => {
- lerpValue = v;
- SetText();
- AimHandler.ins.lerpTimeRate = lerpValue;
- });
- btn.onClick.AddListener(() => {
- openLerp = !openLerp;
- SetBtnText();
- AimHandler.ins.lerpForRotation = openLerp;
- });
- Init();
- }
- void Init() {
- slider.SetValueWithoutNotify(lerpValue);
- SetText();
- SetBtnText();
- AimHandler.ins.lerpForRotation = openLerp;
- AimHandler.ins.lerpTimeRate = lerpValue;
- }
- void SetText() {
- text.text = "插值率:" + lerpValue;
- }
- void SetBtnText() {
- btn.GetComponentInChildren<Text>().text = openLerp ? "插值已开启" : "插值已关闭";
- btn.GetComponentInChildren<Text>().color = openLerp ? Color.green : Color.black;
- }
- }
|