代码部分
- 目的:用于更改纹理的尺寸为4的倍数
- 操作方式:拖拽到指定位置,然后进行操作
/// <summary>
/// 用于更改纹理的尺寸
/// 操作方式:拖拽到指定位置,然后进行操作
/// </summary>
public class MenuItem_TextureEx : EditorWindow
{
private string tipName = "需要4化的文件夹路径/文件";
private List<string> _listPaths = new List<string>();
private bool IsToBig = true; //向着更大缩放
private bool IsFloder = false;
//背景资源宽高4倍处理
[MenuItem("Tools/背景4倍化处理", priority = 101)]
private static void TextureEx()
{
EditorWindow.GetWindowWithRect<MenuItem_TextureEx>(new Rect(Screen.width / 2, Screen.height / 2, 500, 500));
}
void OnGUI()
{
//实现拖拽
Rect drawRect = EditorGUILayout.BeginHorizontal();
GUILayout.Box(tipName, GUILayout.MinHeight(40), GUILayout.MinWidth(500));
EditorGUILayout.EndHorizontal();
for (int i = 0; i < _listPaths.Count; i++)
{
GUILayout.Label(_listPaths[i]);
}
UnityEngine.Event currentEvent = UnityEngine.Event.current;
//拖拽范围内
if (drawRect.Contains(currentEvent.mousePosition))
{
switch (currentEvent.ty