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;
|
}
|
}
|
}
|