unity ImageBotton不使用Imgae怎么使用button

unity ImageBotton不使用Imgae怎么使用button

很多人在创建button时用很多不可见的Image作为交互响应的控件,这些image虽然被alpha被设置为0不可见,但是DrawCall依然存在

解决办法实现一个只在逻辑上响应Raycast但是不参与绘制的组件即可

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
namespace UnityEngine.UI
{
    
    
    public class Empty4Raycast : MaskableGraphic
    {
    
    
        protected Empty4Raycast()
        {
    
    
            useLegacyMeshGeneration = false;
        }

        protected override void OnPopulateMesh(VertexHelper toFill)
        {
    
    

            toFill.Clear();
        }

    }
}

猜你喜欢

转载自blog.csdn.net/Allure_Lo/article/details/123871453