对战初步完成
This commit is contained in:
1 parent
b0c0890ca3
commit
509c309252
55 files changed
+7079
-6748
No files matched your search
@@ -0,0 +1,71 @@
|
||||
using System;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
|
||||
namespace Assets.Scripts.UI.Control
|
||||
{
|
||||
[RequireComponent(typeof(ScrollRect))]
|
||||
public class PFUIPageHelper : PFUIComponentBase
|
||||
{
|
||||
public Transform content;
|
||||
public GameObject preBtn;
|
||||
public GameObject nextBtn;
|
||||
public GameObject btnPrefab;
|
||||
public int PageIndex { get; set; }
|
||||
public int PageSize { get; set; } = 6;
|
||||
public int Total { get; set; }
|
||||
|
||||
private Action<int> CallBack { get; set; }
|
||||
|
||||
public void Register(Action<int> refresh)
|
||||
{
|
||||
CallBack = refresh;
|
||||
|
||||
UIManager.AddEvent(preBtn, UnityEngine.EventSystems.EventTriggerType.PointerClick, (e) =>
|
||||
{
|
||||
Previous();
|
||||
});
|
||||
UIManager.AddEvent(nextBtn, UnityEngine.EventSystems.EventTriggerType.PointerClick, (e) =>
|
||||
{
|
||||
Next();
|
||||
});
|
||||
}
|
||||
public void Build()
|
||||
{
|
||||
Utils.DestroyChildren(content);
|
||||
for (int i = 1; i <= Total; i++)
|
||||
{
|
||||
var g = Instantiate(btnPrefab, content);
|
||||
g.transform.Find("Text").GetComponent<Text>().text = i.ToString();
|
||||
}
|
||||
}
|
||||
//上一页
|
||||
private void Previous()
|
||||
{
|
||||
var newIndex = PageIndex - 1;
|
||||
var index = newIndex < 0 ? 0 : newIndex;
|
||||
if (index != PageIndex)
|
||||
{
|
||||
PageIndex = index;
|
||||
CallBack?.Invoke(PageIndex);
|
||||
}
|
||||
}
|
||||
//下一页
|
||||
private void Next()
|
||||
{
|
||||
var newIndex = PageIndex + 1;
|
||||
var index = newIndex >= Total ? Total-1 : newIndex;
|
||||
if (index != PageIndex)
|
||||
{
|
||||
PageIndex = index;
|
||||
CallBack?.Invoke(PageIndex);
|
||||
}
|
||||
}
|
||||
//指定到第几页
|
||||
private void Redirect(int index)
|
||||
{
|
||||
PageIndex = index;
|
||||
CallBack?.Invoke(PageIndex);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 284f6a5c33c31f14da608779c7797369
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
Reference in new issue
Block a user