UI左右切换数据
来源:互联网 发布:新开淘宝店如何刷信誉 编辑:程序博客网 时间:2024/06/03 04:15
using System.Collections.Generic;
using UnityEngine;
public class Select : MonoBehaviour {
protected int currentIndex = 0, totalCount;
public int CurrentIndex { get { return currentIndex; } }
public void OnNextClick(GameObject go){
currentIndex++;
OnIndexChange();
}
public void OnPreviousClick(GameObject go){
currentIndex--;
OnIndexChange();
}
protected void OnIndexChange(){
HandleBounds();
AssignByIndex();
}
protected void HandleBounds(){
if (currentIndex < 0){
currentIndex = totalCount - 1;
}
if (currentIndex >= totalCount){
currentIndex = 0;
}
}
protected virtual void AssignByIndex() { }
}
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class ModleSelect : Select {
public DetailList infos;
public GameObject nextButton, previousButton;
private void Start(){
UGUIEventListener.Get(nextButton).onClick += OnNextClick;
UGUIEventListener.Get(previousButton).onClick += OnPreviousClick;
}
protected override void AssignByIndex()
{
DetailInfo info = infos.GetDetails(CurrentIndex);
ShowInfos(info);
}
void ShowInfos(DetailInfo info) { }
}
using System.Reflection;
using UnityEngine;
using UnityEngine.EventSystems;
public class UGUIEventListener : EventTrigger
{
public delegate void VoidDelegate(GameObject go);
public VoidDelegate onClick;
public VoidDelegate onDown;
public VoidDelegate onEnter;
public VoidDelegate onExit;
public VoidDelegate onUp;
public VoidDelegate onSelect;
public VoidDelegate onUpdateSelect;
static public UGUIEventListener Get(GameObject go)
{
UGUIEventListener listener = go.GetComponent<UGUIEventListener>();
if (listener == null) listener = go.AddComponent<UGUIEventListener>();
return listener;
}
public override void OnPointerClick(PointerEventData eventData)
{
if (onClick != null) onClick(gameObject);
}
public override void OnPointerDown(PointerEventData eventData)
{
if (onDown != null) onDown(gameObject);
}
public override void OnPointerEnter(PointerEventData eventData)
{
if (onEnter != null) onEnter(gameObject);
}
public override void OnPointerExit(PointerEventData eventData)
{
if (onExit != null) onExit(gameObject);
}
public override void OnPointerUp(PointerEventData eventData)
{
if (onUp != null) onUp(gameObject);
}
public override void OnSelect(BaseEventData eventData)
{
if (onSelect != null) onSelect(gameObject);
}
public override void OnUpdateSelected(BaseEventData eventData)
{
if (onUpdateSelect != null) onUpdateSelect(gameObject);
}
public void ClearClickEvent()
{
if (onClick != null)
{
foreach (VoidDelegate item in onClick.GetInvocationList())
{
MethodInfo m = item.Method;
if (!m.Name.Contains("ChangeButtonState"))
{
onClick -= item;
}
}
}
}
}
- UI左右切换数据
- js中前台数据左右切换移动
- Android高级UI ViewFlipper左右滑屏切换页面
- 左右切换
- 实现左右屏切换
- jQuery---左右切换内容
- 左右切换动画
- 左右图片切换
- Fragment 左右切换
- ViewFlipperDemo左右切换
- 图片左右切换
- MY_GEEK_MYMENU--左右切换菜单
- 左右滑动切换图片
- 左右切换Activity
- 左右滑动切换Activity
- js左右控制切换
- 图片的左右切换
- jquery 轮播图,左右切换
- web缓存学习+H5自定义属性+observe
- javascript深度拷贝
- Linux例行性工作调度---crontab与at
- 从neutron/setup.cfg 的[entry_points] 可以知道组成neutron个个子系统的源码路径
- HDU 1863 畅通工程
- UI左右切换数据
- 前端学科笔记分享——vue.js
- Markdown简易教程
- Ubuntu shadowsocks_命令行运行_开机自动启动_Chrome
- [LeetCode]258. Add Digits
- CAD版本转换怎么转?
- 需要写哪里不能为空的时候,不想用TP的自动验证,就用H5的这个属性
- python调用openstack的api,create_instance的程序解析
- 五 iOS之 Core Animation(核心动画)