using UnityEngine; using UnityEngine.UI; using System.Collections; using System.Collections.Generic; using System; using Module.Log; using UnityEngine.Events; public class UIContainerBlog : UIContainerBase { public GameObject _LoadNextBtn; public RectTransform _MoveObj; public int _LoadMoreLeastItemCnt = 10; [Serializable] public class LoadMore : UnityEvent { public LoadMore() { } } [SerializeField] public LoadMore _LoadMore; private Vector2 _ScollSize = Vector2.zero; private bool _IsLoadAllItems = false; public bool IsLoadAllItems { get { return _IsLoadAllItems; } set { _IsLoadAllItems = value; if (_IsLoadAllItems) { _LoadNextBtn.SetActive(false); } } } public void OnEnable() { IsLoadAllItems = false; } public void Update() { if (_IsLoadAllItems) return; if (_ScollSize == Vector2.zero) { _ScollSize = gameObject.GetComponent().sizeDelta; LogModule.DebugLog("ScollSize:" + _ScollSize); } if (_MoveObj == null) { _MoveObj = _ContainerObj; } if (_LoadNextBtn != null) { if (_ValueList.Count < _LoadMoreLeastItemCnt) { _LoadNextBtn.SetActive(false); } else if (_MoveObj.sizeDelta.y < _ScollSize.y) { _LoadNextBtn.SetActive(false); } else if (_MoveObj.anchoredPosition.y + _ScollSize.y > _MoveObj.sizeDelta.y - 20) { _LoadNextBtn.SetActive(true); } else { _LoadNextBtn.SetActive(false); } } } public void BtnLoadMore() { if(_LoadMore != null) _LoadMore.Invoke(); } }