using UnityEngine; using UnityEngine.Events; using UnityEditor; using System.Linq; using System.Collections.Generic; public class NormalConvertWarning : EditorWindow { private static List normalList; private static List fullList; private static UnityAction> confirmCallback; public static void OpenWindow(List normalList, List fullList, UnityAction> confirmCallback) { NormalConvertWarning.normalList = normalList; NormalConvertWarning.fullList = fullList; NormalConvertWarning.confirmCallback = confirmCallback; var window = GetWindow(); window.Show(); } private void OnGUI() { GUILayout.Label("警告:以下图片不是法线贴图", EditorStyles.boldLabel); var exceptList = fullList.Except(normalList).OrderBy(a => a); foreach (var except in exceptList) GUILayout.Label(" " + except); GUILayout.Space(20f); if (fullList.Count > 0) { GUILayout.Label("强制转换为法线贴图?"); GUILayout.BeginHorizontal(); if (GUILayout.Button("全部转换", GUILayout.Width(100f))) { confirmCallback(fullList); Close(); } GUILayout.Space(30f); if (GUILayout.Button("仅法线贴图", GUILayout.Width(100f))) { confirmCallback(normalList); Close(); } GUILayout.Space(30f); if (GUILayout.Button("取消转换", GUILayout.Width(100f))) Close(); GUILayout.EndHorizontal(); } } private void OnDisable() { normalList = null; fullList = null; confirmCallback = null; } }