150人加入学习
(16人评价)
Unity中级案例 - 单机斗地主

制作完成于 2018-07-18 基于Unity2017.2

价格 ¥ 312.00

只使用一个左键点击的方案

类:LearnButton

<

using UnityEngine;
using UnityEngine.UI;
using System;
using UnityEngine.EventSystems;

public class LearnButton : MonoBehaviour,IPointerClickHandler,IPointerExitHandler,IPointerUpHandler,IPointerDownHandler,IPointerEnterHandler{

    /// <summary>
    /// 划过选中
    /// </summary>
    public event Action HighlightedBtn;
    /// <summary>
    /// 点击选中
    /// </summary>
    public event Action<PointerEventData> PressedBtn;

    public void OnPointerClick(PointerEventData eventData)
    {
        if (PressedBtn != null)
            PressedBtn(eventData);
    }

    public void OnPointerEnter(PointerEventData eventData)
    {
        
    }

    public void OnPointerExit(PointerEventData eventData)
    {
        if (HighlightedBtn != null)
            HighlightedBtn();
    }

    public void OnPointerDown(PointerEventData eventData)
    {

    }

    public void OnPointerUp(PointerEventData eventData)
    {
        
    }
}

>

类:CardUI

<

private void Btn_HighlightedBtn()
    {
        if (Input.GetMouseButton(0))
        {
            if (card.BelongTo == CharacterType.Player)
                IsSelected = !IsSelected;
        }
    }

    private void Btn_PressedBtn(PointerEventData eventData)
    {
        if (card.BelongTo == CharacterType.Player && eventData.button == PointerEventData.InputButton.Left)
            IsSelected = !IsSelected;
    }

>

[展开全文]

授课教师

SIKI学院老师

课程特色

下载资料(2)
视频(105)