增加资源检查窗口

main
刘涛 2024-03-06 14:45:58 +08:00
parent e9121b4cc5
commit b7de22b7d3
6 changed files with 173 additions and 5 deletions

View File

@ -12,7 +12,19 @@ namespace Framework
public class TableManager : Singlenton<TableManager>, IInitable, ILoadable
{
private Tables _tables;
public Tables Tables => _tables;
public Tables Tables
{
get
{
#if UNITY_EDITOR
if (_tables == null)
{
_tables = EditorTableManager.instance.tables;
}
#endif
return _tables;
}
}
public void Init()
{

View File

@ -8,9 +8,9 @@ namespace CharacterBuilder
public class CharacterExTools
{
[MenuItem("Tools/构建器/打印缺失的SPlayer")]
public static void PrintNoSPlayers()
public static string PrintNoSPlayers()
{
var resultStr = "";
var allPlayers = EditorTableManager.instance.tables.CharacterAttri.DataList;
for (int i = 0; i < allPlayers.Count; i++)
{
@ -19,9 +19,10 @@ namespace CharacterBuilder
var path = PathEx.GetCharacterDisplayModelPath(skinData.NameID);
if (AssetDatabase.LoadAssetAtPath<GameObject>(path) == null)
{
Debug.LogError("缺失的SPlayer: " + player.RoleID);
resultStr += player.RoleID + ",";
}
}
return resultStr;
}
}

View File

@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: 34b2cf2288524e5ea221fd49667d70d4
timeCreated: 1709706135

View File

@ -0,0 +1,149 @@
using System;
using Framework;
using Gameplay;
using Gameplay.Utils;
using UnityEditor;
using UnityEngine;
namespace ResCheck
{
public class ResCheckWindow : EditorWindow
{
[MenuItem("Tools/资源检查")]
public static void ShowWindow()
{
_style_normal = new GUIStyle();
_style_normal.normal.textColor = Color.green;
_style_error = new GUIStyle();
_style_error.normal.textColor = Color.red;
var window = GetWindow<ResCheckWindow>();
window.titleContent = new UnityEngine.GUIContent("资源检查");
window.Show();
window.minSize = new Vector2(600, 300);
window._DoCheck();
}
private static GUIStyle _style_normal;
private static GUIStyle _style_error;
private string _sPlayersCheckResult = "";
private void _ShowSPlayers()
{
GUILayout.Label("角色展示模型检查:");
var checkPath = "Assets/Art/Character/Prefabs/Players_S";
GUILayout.Label(checkPath);
if (string.IsNullOrEmpty(_sPlayersCheckResult))
{
GUILayout.Label("检查结果:一切正常", _style_normal);
}
else
{
GUILayout.Label("检查结果:" + _sPlayersCheckResult, _style_error);
}
}
private string _playerIconCheckResult = "";
private void _ShowPlayerIcon()
{
GUILayout.Label("角色头像检查:");
var checkPath = "Assets/Art/UI/Texture/Icon/HeadPic/";
GUILayout.Label(checkPath);
if (string.IsNullOrEmpty(_playerIconCheckResult))
{
GUILayout.Label("检查结果:一切正常", _style_normal);
}
else
{
GUILayout.Label("检查结果:" + _playerIconCheckResult, _style_error);
}
}
private string _playerPosterCheckResult = "";
private void _ShowPlayerPoster()
{
GUILayout.Label("角色海报检查:");
var checkPath = "Assets/Art/UI/Texture/Poster";
GUILayout.Label(checkPath);
if (string.IsNullOrEmpty(_playerPosterCheckResult))
{
GUILayout.Label("检查结果:一切正常", _style_normal);
}
else
{
GUILayout.Label("检查结果:" + _playerPosterCheckResult, _style_error);
}
}
private void _DoCheck()
{
_sPlayersCheckResult = "";
_playerIconCheckResult = "";
_playerPosterCheckResult = "";
var allPlayers = EditorTableManager.instance.tables.CharacterAttri.DataList;
for (int i = 0; i < allPlayers.Count; i++)
{
var player = allPlayers[i];
// 检查SPlayer
{
var skinData = EditorTableManager.instance.tables.SkinCfg.Get(Constants.DEFULT_SKINID, player.RoleID);
var path = PathEx.GetCharacterDisplayModelPath(skinData.NameID);
if (AssetDatabase.LoadAssetAtPath<GameObject>(path) == null)
{
_sPlayersCheckResult += player.RoleID + ",";
}
}
// 检查Icon
{
var iconPath = CommonUtils.GetDefaultHeadPathByUid((uint)player.RoleID);
if (AssetDatabase.LoadAssetAtPath<Sprite>(iconPath) == null)
{
_playerIconCheckResult += player.RoleID + ",";
}
}
// 检查Poster
{
var posterPath = CommonUtils.GetCharacterPicPath(player.RoleID, CommonUtils.ECharacterPicPathType.Poster);
if (AssetDatabase.LoadAssetAtPath<Sprite>(posterPath) == null)
{
_playerPosterCheckResult += player.RoleID + ",";
}
}
}
if (_sPlayersCheckResult.Length > 0)
{
_sPlayersCheckResult = _sPlayersCheckResult.Substring(0, _sPlayersCheckResult.Length - 1);
}
if (_playerIconCheckResult.Length > 0)
{
_playerIconCheckResult = _playerIconCheckResult.Substring(0, _playerIconCheckResult.Length - 1);
}
if (_playerPosterCheckResult.Length > 0)
{
_playerPosterCheckResult = _playerPosterCheckResult.Substring(0, _playerPosterCheckResult.Length - 1);
}
}
private void OnGUI()
{
EditorGUILayout.HelpBox("此工具用于检查资源是否缺失,请在检查结果中找到对应的资源并处理", MessageType.Warning);
_ShowSPlayers();
GUILayout.Space(10);
_ShowPlayerIcon();
GUILayout.Space(10);
_ShowPlayerPoster();
if (GUILayout.Button("刷新"))
{
_DoCheck();
}
}
}
}

View File

@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: fc1d4652fdab4fdab7b731ab4ab7b2c4
timeCreated: 1709706143

@ -1 +1 @@
Subproject commit 4430b32865241f084bfa613e4f662105287a7a88
Subproject commit feb2c1e5dd32cd4156b860e4afbd3384686a3354