using System; using System.Collections; using System.Collections.Generic; using UnityEngine; using UnityEngine.UI; using Random = System.Random; public class TourPanel : MonoBehaviour { [SerializeField] private Slider[] _sliders; [SerializeField] private RectTransform[] _sliderTra; [SerializeField] private RectTransform endTransform; [SerializeField] private int testLangh; [InspectorButton] public void Test() { SetPanelData(testLangh); } void SetPanelData(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; 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); } 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() { } }