三国卡牌客户端基础资源仓库
yyl
2025-05-13 346ca3658a3a2c6c48a7ca2f11bdf03ee59ffc11
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
using System;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEditor;
using UnityEngine.UI;
 
public class UIUtility
{
    [UnityEditor.MenuItem("Assets/PSDTOUGUI后处理")]
    public static void BaseSettings()
    {   
        GameObject go = Selection.activeGameObject;
        if (go == null)
        {
            return;
        }
 
        // go.AddMissingComponent<Canvas>();
        // go.AddMissingComponent<Canvas>();
        // go.AddMissingComponent<Canvas>();
    }
 
    [UnityEditor.MenuItem("Assets/新UI处理")]
    public static void NewUIHandle()
    {
        GameObject go = Selection.activeGameObject;
        if (go == null)
        {
            return;
        }
 
        if (!go.name.EndsWith("Win"))
        {
            Debug.LogError("请选择正确的UI UI应该以Win结尾");
            return;
        }
 
        go.AddMissingComponent<Canvas>();
        go.AddMissingComponent<CanvasGroup>();
        go.AddMissingComponent<CanvasScaler>();
 
        var graphics = go.GetComponentsInChildren<Graphic>(true);
 
        foreach (Graphic g in graphics)
        {
            g.raycastTarget = false;
        }
    }
}