1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130
| using System.Collections; using System.Collections.Generic; using DG.Tweening; using DSFramework; using UnityEngine; using UnityEngine.Serialization; using UnityEngine.UI;
public enum FileDataType { NONE, SAVE, LOAD, }
/// <summary> /// 存读档类 /// </summary> public class FileDataPageView : PageViewBase { private const uint PageCount = 5; private const uint Spacing = 35;
private FileDataType type;
[FormerlySerializedAs("m_HorizontalLayoutGroups")] [SerializeField] private HorizontalLayoutGroup m_HorizontalLayoutGroups;
[FormerlySerializedAs("m_ContentSizeFitter")] [SerializeField] private ContentSizeFitter m_ContentSizeFitter;
[FormerlySerializedAs("m_ScrollRect")] [SerializeField] private ScrollRect m_ScrollRect;
[SerializeField] private RectTransform m_ContentRect;
private DSImageButton m_ColseButton; private DSFadeButton m_LeftPageButton; private DSFadeButton m_RightPageButton;
private bool PageMoveing;
private void ContentSizeFitterInit(bool value) { m_ContentSizeFitter.horizontalFit = ContentSizeFitter.FitMode.PreferredSize; m_ContentSizeFitter.verticalFit = ContentSizeFitter.FitMode.Unconstrained;
m_ContentSizeFitter.enabled = value; }
private void HorizontalLayoutGroupInit() { m_HorizontalLayoutGroups.spacing = Spacing; m_HorizontalLayoutGroups.childAlignment = TextAnchor.MiddleCenter; }
private void ScrollRectInit() { m_ScrollRect.horizontal = true; m_ScrollRect.vertical = false; m_ScrollRect.movementType = ScrollRect.MovementType.Elastic; m_ScrollRect.elasticity = 0.1f; m_ScrollRect.inertia = true; m_ScrollRect.decelerationRate = 0.135f; m_ScrollRect.scrollSensitivity = 1; }
public override void Init(params object[] option) { // RegisterUIEvent(); base.Init(option);
ScrollRectInit(); HorizontalLayoutGroupInit(); ContentSizeFitterInit(m_ScrollRect.content.childCount >= PageCount);
m_ColseButton = transform.Find("Content/ButtonGroup/CloseButton").GetComponent<DSImageButton>(); m_LeftPageButton = transform.Find("Content/ButtonGroup/LeftPageButton").GetComponent<DSFadeButton>(); m_RightPageButton = transform.Find("Content/ButtonGroup/RightPageButton").GetComponent<DSFadeButton>();
m_LeftPageButton.OnClick.AddListener(() => { if (PageMoveing) return;
float anchoredPositionX = m_ContentRect.anchoredPosition.x + 2500 <= 0 ? m_ContentRect.anchoredPosition.x + 2500 : 0;
PageMoveing = true; m_ContentRect.DOAnchorPos(new Vector2(anchoredPositionX, m_ContentRect.anchoredPosition.y), 0.8f).SetEase(Ease.OutExpo) .OnComplete( () => { PageMoveing = false; }); });
m_RightPageButton.OnClick.AddListener(() => { if (PageMoveing) return; float anchoredPositionX = m_ContentRect.anchoredPosition.x - 2500 >= -m_ContentRect.sizeDelta.x ? m_ContentRect.anchoredPosition.x - 2500 : -m_ContentRect.sizeDelta.x; PageMoveing = true; m_ContentRect.DOAnchorPos(new Vector2(anchoredPositionX, m_ContentRect.anchoredPosition.y), 0.8f).SetEase(Ease.OutExpo) .OnComplete( () => { PageMoveing = false; }); });
m_ColseButton.OnClick.AddListener(() => { m_GameEntry.UI.ClosePage(); }); }
public override void OnDestroy() { m_ColseButton.OnClick.RemoveAllListeners(); base.OnDestory(); }
protected override void SetKeyUI() { if (Input.GetKeyDown(KeyCode.Escape)) { m_GameEntry.UI.ClosePage(); } } }
|