美术资源更新
This commit is contained in:
parent
e1f7ea568b
commit
6381daccb8
@ -1,7 +0,0 @@
|
|||||||
fileFormatVersion: 2
|
|
||||||
guid: e168b1a777deef84c9bbfe80cf8d38b4
|
|
||||||
TextScriptImporter:
|
|
||||||
externalObjects: {}
|
|
||||||
userData:
|
|
||||||
assetBundleName:
|
|
||||||
assetBundleVariant:
|
|
||||||
@ -209,14 +209,6 @@
|
|||||||
"SpritePath": "Assets/Art_SubModule/Art_Resource/Art_UISprites/Head/testHead.jpg",
|
"SpritePath": "Assets/Art_SubModule/Art_Resource/Art_UISprites/Head/testHead.jpg",
|
||||||
"SpineAssetPath": "",
|
"SpineAssetPath": "",
|
||||||
"SpineAnimName": ""
|
"SpineAnimName": ""
|
||||||
},
|
|
||||||
{
|
|
||||||
"Id": 1035,
|
|
||||||
"Name": "新资源项_1035",
|
|
||||||
"Desc": "",
|
|
||||||
"SpritePath": "Assets/Art_SubModule/Art_Resource/Art_UISprites/test1.png",
|
|
||||||
"SpineAssetPath": "",
|
|
||||||
"SpineAnimName": ""
|
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
60
Art_Json/art_table_manifest.json
Normal file
60
Art_Json/art_table_manifest.json
Normal file
@ -0,0 +1,60 @@
|
|||||||
|
{
|
||||||
|
"tablePaths": [
|
||||||
|
"Assets/Art_SubModule/Art_Json/Collections/EmojiResource.json",
|
||||||
|
"Assets/Art_SubModule/Art_Json/Collections/HeadFrameResource.json",
|
||||||
|
"Assets/Art_SubModule/Art_Json/Collections/HeadResource.json",
|
||||||
|
"Assets/Art_SubModule/Art_Json/DecorateIcon/DecorateIconResource.json",
|
||||||
|
"Assets/Art_SubModule/Art_Json/DecorateScene/Scene10Resource.json",
|
||||||
|
"Assets/Art_SubModule/Art_Json/DecorateScene/Scene11Resource.json",
|
||||||
|
"Assets/Art_SubModule/Art_Json/DecorateScene/Scene12Resource.json",
|
||||||
|
"Assets/Art_SubModule/Art_Json/DecorateScene/Scene13Resource.json",
|
||||||
|
"Assets/Art_SubModule/Art_Json/DecorateScene/Scene14Resource.json",
|
||||||
|
"Assets/Art_SubModule/Art_Json/DecorateScene/Scene15Resource.json",
|
||||||
|
"Assets/Art_SubModule/Art_Json/DecorateScene/Scene16Resource.json",
|
||||||
|
"Assets/Art_SubModule/Art_Json/DecorateScene/Scene17Resource.json",
|
||||||
|
"Assets/Art_SubModule/Art_Json/DecorateScene/Scene18Resource.json",
|
||||||
|
"Assets/Art_SubModule/Art_Json/DecorateScene/Scene19Resource.json",
|
||||||
|
"Assets/Art_SubModule/Art_Json/DecorateScene/Scene20Resource.json",
|
||||||
|
"Assets/Art_SubModule/Art_Json/DecorateScene/Scene21Resource.json",
|
||||||
|
"Assets/Art_SubModule/Art_Json/DecorateScene/Scene22Resource.json",
|
||||||
|
"Assets/Art_SubModule/Art_Json/DecorateScene/Scene23Resource.json",
|
||||||
|
"Assets/Art_SubModule/Art_Json/DecorateScene/Scene24Resource.json",
|
||||||
|
"Assets/Art_SubModule/Art_Json/DecorateScene/Scene25Resource.json",
|
||||||
|
"Assets/Art_SubModule/Art_Json/DecorateScene/Scene26Resource.json",
|
||||||
|
"Assets/Art_SubModule/Art_Json/DecorateScene/Scene27Resource.json",
|
||||||
|
"Assets/Art_SubModule/Art_Json/DecorateScene/Scene28Resource.json",
|
||||||
|
"Assets/Art_SubModule/Art_Json/DecorateScene/Scene29Resource.json",
|
||||||
|
"Assets/Art_SubModule/Art_Json/DecorateScene/Scene2Resource.json",
|
||||||
|
"Assets/Art_SubModule/Art_Json/DecorateScene/Scene30Resource.json",
|
||||||
|
"Assets/Art_SubModule/Art_Json/DecorateScene/Scene31Resource.json",
|
||||||
|
"Assets/Art_SubModule/Art_Json/DecorateScene/Scene32Resource.json",
|
||||||
|
"Assets/Art_SubModule/Art_Json/DecorateScene/Scene33Resource.json",
|
||||||
|
"Assets/Art_SubModule/Art_Json/DecorateScene/Scene34Resource.json",
|
||||||
|
"Assets/Art_SubModule/Art_Json/DecorateScene/Scene35Resource.json",
|
||||||
|
"Assets/Art_SubModule/Art_Json/DecorateScene/Scene36Resource.json",
|
||||||
|
"Assets/Art_SubModule/Art_Json/DecorateScene/Scene37Resource.json",
|
||||||
|
"Assets/Art_SubModule/Art_Json/DecorateScene/Scene38Resource.json",
|
||||||
|
"Assets/Art_SubModule/Art_Json/DecorateScene/Scene39Resource.json",
|
||||||
|
"Assets/Art_SubModule/Art_Json/DecorateScene/Scene3Resource.json",
|
||||||
|
"Assets/Art_SubModule/Art_Json/DecorateScene/Scene40Resource.json",
|
||||||
|
"Assets/Art_SubModule/Art_Json/DecorateScene/Scene41Resource.json",
|
||||||
|
"Assets/Art_SubModule/Art_Json/DecorateScene/Scene42Resource.json",
|
||||||
|
"Assets/Art_SubModule/Art_Json/DecorateScene/Scene43Resource.json",
|
||||||
|
"Assets/Art_SubModule/Art_Json/DecorateScene/Scene44Resource.json",
|
||||||
|
"Assets/Art_SubModule/Art_Json/DecorateScene/Scene45Resource.json",
|
||||||
|
"Assets/Art_SubModule/Art_Json/DecorateScene/Scene46Resource.json",
|
||||||
|
"Assets/Art_SubModule/Art_Json/DecorateScene/Scene47Resource.json",
|
||||||
|
"Assets/Art_SubModule/Art_Json/DecorateScene/Scene48Resource.json",
|
||||||
|
"Assets/Art_SubModule/Art_Json/DecorateScene/Scene49Resource.json",
|
||||||
|
"Assets/Art_SubModule/Art_Json/DecorateScene/Scene4Resource.json",
|
||||||
|
"Assets/Art_SubModule/Art_Json/DecorateScene/Scene50Resource.json",
|
||||||
|
"Assets/Art_SubModule/Art_Json/DecorateScene/Scene5Resource.json",
|
||||||
|
"Assets/Art_SubModule/Art_Json/DecorateScene/Scene6Resource.json",
|
||||||
|
"Assets/Art_SubModule/Art_Json/DecorateScene/Scene7Resource.json",
|
||||||
|
"Assets/Art_SubModule/Art_Json/DecorateScene/Scene8Resource.json",
|
||||||
|
"Assets/Art_SubModule/Art_Json/DecorateScene/Scene9Resource.json",
|
||||||
|
"Assets/Art_SubModule/Art_Json/Shop/ShopBig.json",
|
||||||
|
"Assets/Art_SubModule/Art_Json/Shop/ShopOther.json"
|
||||||
|
],
|
||||||
|
"preloadTableIds": []
|
||||||
|
}
|
||||||
@ -1,5 +1,5 @@
|
|||||||
fileFormatVersion: 2
|
fileFormatVersion: 2
|
||||||
guid: fba7406f65a0efd479fdbe0401785d2a
|
guid: 59b49f5fd2d72a24b84d5927de0481c7
|
||||||
TextScriptImporter:
|
TextScriptImporter:
|
||||||
externalObjects: {}
|
externalObjects: {}
|
||||||
userData:
|
userData:
|
||||||
@ -223,11 +223,3 @@ MonoBehaviour:
|
|||||||
SpineAsset: {fileID: 0}
|
SpineAsset: {fileID: 0}
|
||||||
SpineAssetPath:
|
SpineAssetPath:
|
||||||
SpineAnimName:
|
SpineAnimName:
|
||||||
- Id: 1035
|
|
||||||
Name: "\u65B0\u8D44\u6E90\u9879_1035"
|
|
||||||
Desc:
|
|
||||||
Sprite: {fileID: 21300000, guid: 733315d1cf4a069438e2304ec523f0f5, type: 3}
|
|
||||||
SpritePath: Assets/Art_SubModule/Art_Resource/Art_UISprites/test1.png
|
|
||||||
SpineAsset: {fileID: 0}
|
|
||||||
SpineAssetPath:
|
|
||||||
SpineAnimName:
|
|
||||||
|
|||||||
@ -1308,21 +1308,23 @@ namespace EditorArt_Tools
|
|||||||
|
|
||||||
private void UpdateManifest()
|
private void UpdateManifest()
|
||||||
{
|
{
|
||||||
const string MANIFEST_PATH = "Assets/Art_SubModule/Art_SO/art_table_manifest.json";
|
const string MANIFEST_PATH = "Assets/Art_SubModule/Art_Json/art_table_manifest.json";
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
// 查找所有ArtTableSO文件
|
// 查找所有JSON文件(从JSON目录扫描)
|
||||||
string[] guids = AssetDatabase.FindAssets("t:ArtTableSO", new[] { SO_ROOT_PATH });
|
string[] jsonFiles = Directory.GetFiles(JSON_ROOT_PATH, "*.json", SearchOption.AllDirectories);
|
||||||
List<string> tablePaths = new List<string>();
|
List<string> tablePaths = new List<string>();
|
||||||
|
|
||||||
foreach (string guid in guids)
|
foreach (string fullPath in jsonFiles)
|
||||||
{
|
{
|
||||||
string path = AssetDatabase.GUIDToAssetPath(guid);
|
string relativePath = fullPath.Replace("\\", "/").Replace(Application.dataPath.Replace("/Assets", "").Replace("\\", "/") + "/", "");
|
||||||
if (!string.IsNullOrEmpty(path))
|
|
||||||
{
|
// 排除manifest文件本身
|
||||||
tablePaths.Add(path);
|
if (relativePath.EndsWith("art_table_manifest.json"))
|
||||||
}
|
continue;
|
||||||
|
|
||||||
|
tablePaths.Add(relativePath);
|
||||||
}
|
}
|
||||||
|
|
||||||
// 排序路径
|
// 排序路径
|
||||||
@ -1362,13 +1364,20 @@ namespace EditorArt_Tools
|
|||||||
// 清理预加载配置:移除已删除表的ID
|
// 清理预加载配置:移除已删除表的ID
|
||||||
// 获取所有当前存在的表的ID
|
// 获取所有当前存在的表的ID
|
||||||
List<int> validTableIds = new List<int>();
|
List<int> validTableIds = new List<int>();
|
||||||
foreach (string guid in guids)
|
foreach (string jsonPath in tablePaths)
|
||||||
{
|
{
|
||||||
string path = AssetDatabase.GUIDToAssetPath(guid);
|
try
|
||||||
var table = AssetDatabase.LoadAssetAtPath<ArtTableSO>(path);
|
|
||||||
if (table != null)
|
|
||||||
{
|
{
|
||||||
validTableIds.Add(table.TableId);
|
string jsonContent = File.ReadAllText(jsonPath);
|
||||||
|
var jsonData = JsonUtility.FromJson<ArtTableJsonData>(jsonContent);
|
||||||
|
if (jsonData != null)
|
||||||
|
{
|
||||||
|
validTableIds.Add(jsonData.TableId);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch
|
||||||
|
{
|
||||||
|
// 忽略无法解析的文件
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1400,7 +1409,7 @@ namespace EditorArt_Tools
|
|||||||
File.WriteAllText(MANIFEST_PATH, json);
|
File.WriteAllText(MANIFEST_PATH, json);
|
||||||
AssetDatabase.ImportAsset(MANIFEST_PATH);
|
AssetDatabase.ImportAsset(MANIFEST_PATH);
|
||||||
|
|
||||||
Debug.Log($"[ArtResourceConfigEditor] Manifest文件已更新: {MANIFEST_PATH}, 共 {tablePaths.Count} 个表");
|
Debug.Log($"[ArtResourceConfigEditor] Manifest文件已更新: {MANIFEST_PATH}, 共 {tablePaths.Count} 个JSON表");
|
||||||
}
|
}
|
||||||
catch (System.Exception ex)
|
catch (System.Exception ex)
|
||||||
{
|
{
|
||||||
|
|||||||
@ -3,6 +3,8 @@ using UnityEngine;
|
|||||||
using UnityEditor;
|
using UnityEditor;
|
||||||
using ArtResource;
|
using ArtResource;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
|
using System.IO;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
|
||||||
namespace ArtTools
|
namespace ArtTools
|
||||||
{
|
{
|
||||||
@ -12,6 +14,7 @@ namespace ArtTools
|
|||||||
/// 功能:
|
/// 功能:
|
||||||
/// 1. 在保存SO时自动填充SpritePath和SpineAssetPath
|
/// 1. 在保存SO时自动填充SpritePath和SpineAssetPath
|
||||||
/// 2. 提供手动批量更新所有SO的工具
|
/// 2. 提供手动批量更新所有SO的工具
|
||||||
|
/// 3. 同步更新JSON配置文件
|
||||||
///
|
///
|
||||||
/// 使用方法:
|
/// 使用方法:
|
||||||
/// - 自动:在ArtTableSO的OnValidate或保存时调用FillResourcePaths
|
/// - 自动:在ArtTableSO的OnValidate或保存时调用FillResourcePaths
|
||||||
@ -19,6 +22,8 @@ namespace ArtTools
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public static class ArtResourcePathFiller
|
public static class ArtResourcePathFiller
|
||||||
{
|
{
|
||||||
|
private const string SO_ROOT_PATH = "Assets/Art_SubModule/Art_SO";
|
||||||
|
private const string JSON_ROOT_PATH = "Assets/Art_SubModule/Art_Json";
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 自动填充单个SO的资源路径
|
/// 自动填充单个SO的资源路径
|
||||||
/// 应该在ArtTableSO保存时调用
|
/// 应该在ArtTableSO保存时调用
|
||||||
@ -77,6 +82,54 @@ namespace ArtTools
|
|||||||
{
|
{
|
||||||
EditorUtility.SetDirty(table);
|
EditorUtility.SetDirty(table);
|
||||||
Debug.Log($"[ArtResourcePathFiller] 已更新资源路径: {table.TableName} ({table.TableId})");
|
Debug.Log($"[ArtResourcePathFiller] 已更新资源路径: {table.TableName} ({table.TableId})");
|
||||||
|
|
||||||
|
// 同步到JSON
|
||||||
|
SyncToJson(table);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 同步SO数据到JSON文件
|
||||||
|
/// </summary>
|
||||||
|
private static void SyncToJson(ArtTableSO table)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
string soPath = AssetDatabase.GetAssetPath(table);
|
||||||
|
string relativePath = soPath.Replace(SO_ROOT_PATH, "").Replace(".asset", ".json");
|
||||||
|
string jsonPath = JSON_ROOT_PATH + relativePath;
|
||||||
|
|
||||||
|
// 确保目录存在
|
||||||
|
string directory = Path.GetDirectoryName(jsonPath);
|
||||||
|
if (!Directory.Exists(directory))
|
||||||
|
{
|
||||||
|
Directory.CreateDirectory(directory);
|
||||||
|
}
|
||||||
|
|
||||||
|
// 创建JSON数据
|
||||||
|
var jsonData = new ArtTableJsonData
|
||||||
|
{
|
||||||
|
TableId = table.TableId,
|
||||||
|
TableName = table.TableName,
|
||||||
|
Items = table.Items.Select(item => new ArtItemJsonData
|
||||||
|
{
|
||||||
|
Id = item.Id,
|
||||||
|
Name = item.Name,
|
||||||
|
Desc = item.Desc,
|
||||||
|
SpritePath = item.SpritePath,
|
||||||
|
SpineAssetPath = item.SpineAssetPath,
|
||||||
|
SpineAnimName = item.SpineAnimName
|
||||||
|
}).ToList()
|
||||||
|
};
|
||||||
|
|
||||||
|
string json = JsonUtility.ToJson(jsonData, true);
|
||||||
|
File.WriteAllText(jsonPath, json);
|
||||||
|
|
||||||
|
Debug.Log($"[ArtResourcePathFiller] JSON同步成功: {jsonPath}");
|
||||||
|
}
|
||||||
|
catch (System.Exception ex)
|
||||||
|
{
|
||||||
|
Debug.LogError($"[ArtResourcePathFiller] JSON同步失败: {ex.Message}");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -124,10 +177,10 @@ namespace ArtTools
|
|||||||
AssetDatabase.SaveAssets();
|
AssetDatabase.SaveAssets();
|
||||||
AssetDatabase.Refresh();
|
AssetDatabase.Refresh();
|
||||||
|
|
||||||
Debug.Log($"[ArtResourcePathFiller] ✓ 批量更新完成: 处理了 {updatedCount} 个ArtTableSO");
|
Debug.Log($"[ArtResourcePathFiller] ✓ 批量更新完成: 处理了 {updatedCount} 个ArtTableSO,已同步JSON配置");
|
||||||
EditorUtility.DisplayDialog(
|
EditorUtility.DisplayDialog(
|
||||||
"更新完成",
|
"更新完成",
|
||||||
$"已更新 {updatedCount} 个美术资源表的路径信息\n\n现在可以在Runtime模式下正常加载资源了",
|
$"已更新 {updatedCount} 个美术资源表的路径信息\n并同步更新了JSON配置文件\n\n现在可以在Runtime模式下正常加载资源了",
|
||||||
"确定"
|
"确定"
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@ -292,5 +345,27 @@ namespace ArtTools
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// JSON数据结构
|
||||||
|
/// </summary>
|
||||||
|
[System.Serializable]
|
||||||
|
public class ArtTableJsonData
|
||||||
|
{
|
||||||
|
public int TableId;
|
||||||
|
public string TableName;
|
||||||
|
public List<ArtItemJsonData> Items;
|
||||||
|
}
|
||||||
|
|
||||||
|
[System.Serializable]
|
||||||
|
public class ArtItemJsonData
|
||||||
|
{
|
||||||
|
public int Id;
|
||||||
|
public string Name;
|
||||||
|
public string Desc;
|
||||||
|
public string SpritePath;
|
||||||
|
public string SpineAssetPath;
|
||||||
|
public string SpineAnimName;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user