Unity NGUI.Button使用

在菜单栏中打开

  • NGUI->Open->Widget Wizard使用工具生成Button

截屏2023-08-24 13.10.32.png

或者在Project中搜索Control
截屏2023-08-24 13.16.21.png

几个设置需要注意的地方:

WeChate261a47172663d594a6d6815230cf83d.jpg
WeChat8db3cf8b034f44f79a0fd8e2f655f3e3.jpg

挂载脚本处理逻辑:


WeChat1bf8c712561122c27b1eab5cf24b226c.jpg
using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class UIMainController : MonoBehaviour
{
    // Start is called before the first frame update

    [SerializeField]
    public UIButton loginButton;

    [SerializeField]
    public UIButton logoutButton;

    private void Awake()
    {
        UIEventListener.Get(loginButton.gameObject).onClick = OnClick;
        UIEventListener.Get(logoutButton.gameObject).onClick = OnClick;
    }

    void Start()
    {
        
    }

    public void OnClick(GameObject gameObject)
    {

    }

    // Update is called once per frame
    void Update()
    {
        
    }
}

Button动画

在button上挂载Button Rotation等脚本
设置Duration和旋转方向

©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容