一些修复和优化
This commit is contained in:
@@ -41,7 +41,7 @@ public static class PackagingResetTool
|
||||
"2.5 歌曲:游玩次数、累计时长、各难度成绩记录清零(歌曲解锁/谱面配置不动)\n" +
|
||||
"3. 装备:删除 " + GeneratedEquipmentFolder + " 下所有生成装备,清除英雄已装备引用\n" +
|
||||
"4. 商店:所有物品 purchasedCount、user_has_read 清零(限购配置 itemPurchaseQuota 不动)\n" +
|
||||
"5. 清理本机测试存档(.cache_bridge 货币/成长/经验瓶/突破材料/装备消耗品、player_rks、player_experience、装备/商店存档,不含拥有权账本)与相关 PlayerPrefs\n\n" +
|
||||
"5. 清理本机测试存档(.cache_bridge 货币/成长/经验瓶/突破材料/装备消耗品、player_rks、player_experience、player_skills、装备/商店存档,不含拥有权账本)与相关 PlayerPrefs\n\n" +
|
||||
"此操作会修改并保存资产文件,建议在版本控制下执行。是否继续?",
|
||||
"执行重置",
|
||||
"取消");
|
||||
@@ -65,6 +65,7 @@ public static class PackagingResetTool
|
||||
AssetDatabase.StartAssetEditing();
|
||||
|
||||
errors += ResetPlayers(report);
|
||||
errors += ResetPlayerSkills(report);
|
||||
errors += ResetHeroes(report);
|
||||
errors += ResetSongs(report);
|
||||
errors += DeleteGeneratedEquipmentAssets(report);
|
||||
@@ -129,9 +130,53 @@ public static class PackagingResetTool
|
||||
}
|
||||
|
||||
report.AppendLine("玩家资产已重置:" + count + " 个 Player_SO。");
|
||||
try
|
||||
{
|
||||
SecureSaveVault.Delete("player_skills", "runtime");
|
||||
PlayerProgressBackupService.ClearPlayerSkillBackup();
|
||||
report.AppendLine("已清理 player_skills 运行时存档与备份(player_skills/runtime)。");
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
errors++;
|
||||
report.AppendLine("清理 player_skills 存档失败:" + ex.Message);
|
||||
}
|
||||
|
||||
return errors;
|
||||
}
|
||||
|
||||
private static int ResetPlayerSkills(StringBuilder report)
|
||||
{
|
||||
int count = 0;
|
||||
foreach (var guid in AssetDatabase.FindAssets("t:userLevel_skills_SO"))
|
||||
{
|
||||
string path = AssetDatabase.GUIDToAssetPath(guid);
|
||||
var so = AssetDatabase.LoadAssetAtPath<userLevel_skills_SO>(path);
|
||||
if (so == null || so.skills == null || so.skills.Count == 0)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
var serialized = new SerializedObject(so);
|
||||
var skills = serialized.FindProperty("skills");
|
||||
if (skills != null && skills.isArray)
|
||||
{
|
||||
for (int i = 0; i < skills.arraySize; i++)
|
||||
{
|
||||
var entry = skills.GetArrayElementAtIndex(i);
|
||||
SetChildBool(entry, "isEnabled", i == 0);
|
||||
}
|
||||
}
|
||||
|
||||
serialized.ApplyModifiedPropertiesWithoutUndo();
|
||||
EditorUtility.SetDirty(so);
|
||||
count++;
|
||||
}
|
||||
|
||||
report.AppendLine("玩家技能资产已重置:" + count + " 个 userLevel_skills_SO(仅启用第 0 个技能)。");
|
||||
return 0;
|
||||
}
|
||||
|
||||
private static int ResetHeroes(StringBuilder report)
|
||||
{
|
||||
int count = 0;
|
||||
@@ -237,6 +282,15 @@ public static class PackagingResetTool
|
||||
}
|
||||
}
|
||||
|
||||
private static void SetChildBool(SerializedProperty parent, string field, bool value)
|
||||
{
|
||||
var prop = parent.FindPropertyRelative(field);
|
||||
if (prop != null)
|
||||
{
|
||||
prop.boolValue = value;
|
||||
}
|
||||
}
|
||||
|
||||
private static int DeleteGeneratedEquipmentAssets(StringBuilder report)
|
||||
{
|
||||
if (!AssetDatabase.IsValidFolder(GeneratedEquipmentFolder))
|
||||
@@ -383,6 +437,7 @@ public static class PackagingResetTool
|
||||
{
|
||||
string legacyExpPath = Path.Combine(Application.persistentDataPath, "player_experience.json");
|
||||
SecureSaveVault.Delete("player_experience", "runtime", legacyExpPath);
|
||||
PlayerProgressBackupService.ClearPlayerExperienceBackup();
|
||||
report.AppendLine("已清理 player_experience 运行时存档(player_experience/runtime)。");
|
||||
}
|
||||
catch (Exception ex)
|
||||
|
||||
Reference in New Issue
Block a user