当前位置: 首页 > news >正文

UGUI空白可点击组件,减少重绘

如果使用image alpha = 0,会导致overDraw,直接清空mesh,不绘制即可避免

#if UNITY_EDITOR
using UnityEditor;
#endif
using UnityEngine;
using UnityEngine.UI;

namespace UnityGameFramework
{
    [AddComponentMenu("Game/UI/GameEmpty4Raycast")]
    [RequireComponent(typeof(CanvasRenderer))]
    public class GameEmpty4Raycast : MaskableGraphic
    {
        protected GameEmpty4Raycast()
        {
            useLegacyMeshGeneration = false;
        }

        protected override void OnPopulateMesh(VertexHelper toFill)
        {
            toFill.Clear();
        }
    }
    
    
    #if UNITY_EDITOR
    [CustomEditor(typeof(GameEmpty4Raycast))]
    public class GameEmpty4RaycastEditor : Editor
    {
        private bool _showDetail;

        private void OnEnable()
        {
            _showDetail = false;
        }

        public override void OnInspectorGUI()
        {
            if (_showDetail)
            {
                base.OnInspectorGUI();    
            }
            
            using (new GUIColorScope(_showDetail ? Color.red : Color.green))
            {
                if (GUILayout.Button(_showDetail ? "隐藏详细信息":"显示详细信息"))
                {
                    _showDetail = !_showDetail;
                }
            }
        }
    }
    #endif
}


http://www.mrgr.cn/news/7356.html

相关文章:

  • 一拖二快充线市场需求 - LDR6020
  • VulnStack1-内网渗透记录
  • linux自定义命令
  • Python单例模式:深入解析与应用
  • 基于x86 平台opencv的图像采集和seetaface6的人脸检测功能
  • 软件工程造价师习题练习 16
  • C语言内存函数
  • 本地Docker部署开源Web相册图库Piwigo与在线远程访问实战方案
  • stm32-SD卡实验
  • 带有限制编辑的PDF文件怎么取消编辑限制
  • 微服务案例搭建
  • 实现MySQL的主从复制基础
  • Paimon Flink本地读取数据报错
  • redis-distributed-id-generator-start之id生成器压测的一些思考
  • GATK ReadsPathDataSource类介绍
  • lammps中有关能量的默认单位
  • 使用pdfrw更新PDF文件信息实现方法
  • 重构与领域驱动设计
  • Linux发送邮件:如何配置SMTP服务器发信?
  • 系统分析师4:数据库系统