106 lines
4.0 KiB
C#
106 lines
4.0 KiB
C#
using UnityEditor;
|
||
using UnityEngine;
|
||
using System.Collections.Generic;
|
||
using System.Linq;
|
||
using Logic.Action;
|
||
|
||
|
||
public class TechToTechAtomDataAssetFiller
|
||
{
|
||
[MenuItem("填表脚本/Tech所有Action转化为TechAtom")]
|
||
public static void FillMissingCivSprites()
|
||
{
|
||
string assetPath = "Assets/Resources/DataAssets/TechDataAssets.asset";
|
||
var asset = AssetDatabase.LoadAssetAtPath<TechDataAssets>(assetPath);
|
||
string actionAssetPath = "Assets/Resources/DataAssets/ActionDataAssets.asset";
|
||
var actionAsset = AssetDatabase.LoadAssetAtPath<ActionDataAssets>(actionAssetPath);
|
||
|
||
if (asset == null)
|
||
{
|
||
Debug.LogError("❌ 找不到 UnitTypeDataAssets.asset,请确认路径正确!");
|
||
return;
|
||
}
|
||
|
||
int addCount = 0;
|
||
|
||
|
||
|
||
foreach (var techInfo in asset.TechList)
|
||
{
|
||
foreach (var action in techInfo.techActions)
|
||
{
|
||
if (action.ActionType is CommonActionType.UnitSkill or CommonActionType.UnitAction
|
||
or CommonActionType.TrainUnit or CommonActionType.BuildWonder or CommonActionType.StartWonder)
|
||
{
|
||
//Debug.Log(action.SkillType);
|
||
var str = "";
|
||
if(action.ActionType is CommonActionType.UnitSkill)
|
||
str = "UnitSkill" + action.SkillType.ToString();
|
||
if(action.ActionType is CommonActionType.UnitAction)
|
||
str = "UnitAction" + action.UnitActionType.ToString();
|
||
if(action.ActionType is CommonActionType.TrainUnit)
|
||
str = "TrainUnit" + action.UnitType.ToString();
|
||
if(action.ActionType is CommonActionType.StartWonder)
|
||
str = "StartWonder" + action.WonderType.ToString();
|
||
if(action.ActionType is CommonActionType.BuildWonder)
|
||
str = "BuildWonder" + action.WonderType.ToString();
|
||
var has = false;
|
||
foreach(var techAtom in asset.TechAtomList)
|
||
if (techAtom.TechAtom.ToString() == str)
|
||
{
|
||
has = true;
|
||
break;
|
||
}
|
||
|
||
if (!has)
|
||
{
|
||
var info = new TechAtomInfo();
|
||
if (TechAtom.TryParse(str, out info.TechAtom))
|
||
{
|
||
foreach (var actionInfo in actionAsset.ActionList)
|
||
{
|
||
if (actionInfo.ActionId == action)
|
||
{
|
||
info.TechAtomName = actionInfo.ActionName;
|
||
info.Desc = actionInfo.NeedTechDesc ? actionInfo.TechDesc : actionInfo.Desc;
|
||
}
|
||
}
|
||
asset.TechAtomList.Add(info);
|
||
addCount++;
|
||
}
|
||
}
|
||
|
||
if (TechAtom.TryParse(str, out TechAtom techAtom2))
|
||
{
|
||
bool alreadyHas = false;
|
||
foreach(var techAtom in techInfo.TechAtomList)
|
||
if (techAtom == techAtom2)
|
||
{
|
||
alreadyHas = true;
|
||
break;
|
||
}
|
||
|
||
if (!alreadyHas)
|
||
{
|
||
techInfo.TechAtomList.Add(techAtom2);
|
||
}
|
||
}
|
||
|
||
|
||
|
||
|
||
}
|
||
|
||
|
||
|
||
|
||
}
|
||
}
|
||
|
||
EditorUtility.SetDirty(asset);
|
||
AssetDatabase.SaveAssets();
|
||
AssetDatabase.Refresh();
|
||
|
||
Debug.Log($"✅ 补全完成:共添加了 {addCount} 个 TechAtom 条目。");
|
||
}
|
||
} |