本文主要是介绍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
}
这篇关于UGUI空白可点击组件,减少重绘的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!