2024-11-08 18:21:41 +08:00
|
|
|
using System;
|
|
|
|
using System.Collections;
|
|
|
|
using System.Collections.Generic;
|
|
|
|
using UnityEngine;
|
|
|
|
using UnityEngine.UI;
|
2024-11-13 16:56:37 +08:00
|
|
|
using Random = System.Random;
|
2024-11-08 18:21:41 +08:00
|
|
|
|
|
|
|
public class TourPanel : MonoBehaviour
|
|
|
|
{
|
|
|
|
[SerializeField] private Slider[] _sliders;
|
2024-11-13 16:56:37 +08:00
|
|
|
[SerializeField] private RectTransform[] _sliderTra;
|
|
|
|
[SerializeField] private RectTransform endTransform;
|
|
|
|
[SerializeField] private int testLangh;
|
2024-11-08 18:21:41 +08:00
|
|
|
|
2024-11-13 16:56:37 +08:00
|
|
|
[InspectorButton]
|
|
|
|
public void Test()
|
2024-11-08 18:21:41 +08:00
|
|
|
{
|
2024-11-13 16:56:37 +08:00
|
|
|
SetPanelData(testLangh);
|
|
|
|
}
|
|
|
|
void SetPanelData(float langh)
|
|
|
|
{
|
|
|
|
var newLangh = langh;
|
|
|
|
var index = 0;
|
|
|
|
for (var i = 0; i < _sliders.Length; i++)
|
2024-11-08 18:21:41 +08:00
|
|
|
{
|
2024-11-13 16:56:37 +08:00
|
|
|
if (newLangh > _sliders[i].maxValue)
|
|
|
|
{
|
|
|
|
newLangh -= _sliders[i].maxValue;
|
|
|
|
index++;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
break;
|
|
|
|
}
|
2024-11-08 18:21:41 +08:00
|
|
|
}
|
2024-11-13 16:56:37 +08:00
|
|
|
var endPoint = newLangh / _sliders[index].maxValue;
|
|
|
|
endTransform.parent = _sliderTra[index];
|
|
|
|
endTransform.rotation = Quaternion.identity;
|
|
|
|
endTransform.anchorMax = new Vector2(endPoint,1);
|
|
|
|
endTransform.anchorMin = new Vector2(endPoint, 0);
|
|
|
|
endTransform.anchoredPosition = new Vector2(0, 0);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
private void SetPanel(RectTransform point,float langh)
|
|
|
|
{
|
|
|
|
var newLangh = langh;
|
|
|
|
var index = 0;
|
|
|
|
for (var i = 0; i < _sliders.Length; i++)
|
|
|
|
{
|
|
|
|
if (newLangh > _sliders[i].maxValue)
|
|
|
|
{
|
|
|
|
newLangh -= _sliders[i].maxValue;
|
|
|
|
index++;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
var endPoint = newLangh / _sliders[index].maxValue;
|
|
|
|
point.parent = _sliderTra[index];
|
|
|
|
point.rotation = Quaternion.identity;
|
|
|
|
point.anchorMax = new Vector2(endPoint,1);
|
|
|
|
point.anchorMin = new Vector2(endPoint, 0);
|
|
|
|
point.anchoredPosition = new Vector2(0, 0);
|
2024-11-08 18:21:41 +08:00
|
|
|
}
|
|
|
|
private void Awake()
|
|
|
|
{
|
|
|
|
// JsonTab.Instance.tables.Level.Get()
|
|
|
|
}
|
|
|
|
// Start is called before the first frame update
|
|
|
|
void Start()
|
|
|
|
{
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
// Update is called once per frame
|
|
|
|
void Update()
|
|
|
|
{
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|