prefab工具

main
tengwei 2024-09-24 15:56:32 +08:00
parent 97ca4f57a3
commit d66cadeee9
2 changed files with 69 additions and 24 deletions

View File

@ -17,7 +17,7 @@ public class ConfigCheck : EditorWindow
List<VehicleItem> vehicleItems;
[MenuItem("Test/prefab工具/角色载具配置")]
[MenuItem("Test/prefab工具/角色载具配置")]
public static void ShowEditor()
{
var win = GetWindow<ConfigCheck>("토零쇱꿴");
@ -70,11 +70,11 @@ public class ConfigCheck : EditorWindow
view.Add(vehiclePane);
// 실<>죗깊
Label playerLabe = new Label() { text = "角色" };
Label playerLabe = new Label() { text = "CharacterDefault配置" };
playerLabe.style.unityTextAlign = TextAnchor.MiddleCenter;
playerLabe.style.fontSize = 20;
playerLabe.style.color = Color.green;
playerPane.Add(playerLabe);
playerPane.Add(playerLabe);
ListView playerListView = new ListView();
playerPane.Add(playerListView);
@ -83,7 +83,7 @@ public class ConfigCheck : EditorWindow
playerListView.bindItem = (item, index) =>
{
(item as Label).text = playerItems[index].id + " ==> " + playerItems[index].message;
if (playerItems[index].animationIsDone)
if (!playerItems[index].mainConfigIsDone && playerItems[index].ani00_isDone)
{
(item as Label).style.color = Color.yellow;
}
@ -91,11 +91,11 @@ public class ConfigCheck : EditorWindow
playerListView.itemsSource = playerItems;
// 潼야죗깊
Label vLabe = new Label() { text = "载具" };
Label vLabe = new Label() { text = "VehicleConfig配置" };
vLabe.style.unityTextAlign = TextAnchor.MiddleCenter;
vLabe.style.fontSize = 20;
vLabe.style.color = Color.green;
vehiclePane.Add(vLabe);
vehiclePane.Add(vLabe);
ListView vListView = new ListView();
vehiclePane.Add(vListView);
@ -143,46 +143,64 @@ public class PlayerItem
{
public string id;
private readonly List<CharacterBuildData> buildDataList;
public readonly bool animationIsDone;
public readonly bool skinIsDone;
public readonly bool configIsDone;
public readonly bool ani00_isDone;
public readonly bool ani01_isDone;
// public readonly bool skinIsDone;
public readonly bool mainConfigIsDone;
public readonly bool skinsConfigIsDone;
public readonly bool isBuild;
public bool AllDone => animationIsDone && skinIsDone && configIsDone && isBuild;
public bool AllDone => ani00_isDone && ani01_isDone && mainConfigIsDone && isBuild;
public string message;
public string message = "";
public PlayerItem(GameObject player, List<CharacterBuildData> buildDataList)
{
var asset = player.transform.GetChild(0);
this.id = asset.name;
string skin01Name = id.StartsWith("A0") ? id.Remove(2, 1).Insert(2, "1") : id.Remove(3, 1).Insert(3, "1");
this.buildDataList = buildDataList;
string path = $"Assets/Art/Animations/Battle/Skill/ani_{id}_skill01.fbx";
animationIsDone = AssetDatabase.LoadAssetAtPath<GameObject>(path);
skinIsDone = asset.Find("Root/Bip001");
// 查找是否已有配置
configIsDone = buildDataList.Any(a => a.mainConfig.NameID == id);
ani00_isDone = AssetDatabase.LoadAssetAtPath<GameObject>(path);
string path1 = $"Assets/Art/Animations/Battle/Skill/ani_{skin01Name}_skill01.fbx";
ani01_isDone = AssetDatabase.LoadAssetAtPath<GameObject>(path1);
// 是否存在AutoGen文件夹判断是否已构建
//skinIsDone = asset.Find("Root/Bip001");
// 查找配置
mainConfigIsDone = buildDataList.Any(a => a.mainConfig.NameID == id);
skinsConfigIsDone = buildDataList.Any(a => a.skins[1].NameID == skin01Name);
// 是否存在AutoGen文件夹, 判断是否已构建2个皮肤
string autoDir = $"Assets/Art/AutoGen/Characters/character_{id}/";
isBuild = AssetDatabase.IsValidFolder(autoDir);
string autoDir1 = $"Assets/Art/AutoGen/Characters/character_{skin01Name}/";
if (animationIsDone && skinIsDone)
isBuild = AssetDatabase.IsValidFolder(autoDir1); // 只检查皮肤2
if (ani00_isDone) // 技能动画完成
{
if (!isBuild)
if (!mainConfigIsDone)
{
this.message = "需要构建角色";
this.message = " 缺少mainConfig";
}
else
{
this.message = configIsDone ? "需要构建角色" : "CharacterDefault配置缺少或未解锁";
if (isBuild is false)
{
this.message = ani01_isDone ? "需要构建皮肤2" : "缺少技能动画2";
}
}
if (!skinsConfigIsDone && ani01_isDone)
{
this.message = this.message + $" 缺少{skin01Name}skinConfg";
}
}
else
{
this.message = skinIsDone ? "技能动画未完成" : "蒙皮制作未完成";
this.message = "缺少技能动画1";
}
}
}
public class VehicleItem
{
public string id;
@ -194,7 +212,7 @@ public class VehicleItem
{
this.id = vPrefab.name.Split('_')[1];
configIsDone = dataList.Any(a => a.vehicleConfig.ID.ToString() == id);
message = configIsDone ? "需要构建载具" : "VehicleConfig配置缺少或未解锁";
message = configIsDone ? "需要构建载具" : "缺少配置or未解锁";
string path = $"Assets/Art/AutoGen/Vehicle/{id}";
isBuild = AssetDatabase.IsValidFolder(path);
}

View File

@ -42,6 +42,10 @@ public class ShowAniTest : EditorWindow
rootVisualElement.Add(btn3);
btn3.RegisterCallback<ClickEvent>(ChangAni);
Button btn4 = new() { text = "play skill" };
rootVisualElement.Add(btn4);
btn4.RegisterCallback<ClickEvent>(PlaySkill);
points = GameObject.Find("Points");
}
@ -98,6 +102,29 @@ public class ShowAniTest : EditorWindow
animator.runtimeAnimatorController = AssetDatabase.LoadAssetAtPath<RuntimeAnimatorController>(acPath);
animator.Play(nextStateName);
Debug.Log(nextStateName);
}
}
public void PlaySkill(ClickEvent evt)
{
foreach (GameObject item in prefabList)
{
Transform assetTransform = item.transform.GetChild(0);
Animator animator = assetTransform.GetComponent<Animator>();
// ²éѯ¶¯×÷Ä£×é
string assetName = "";
assetName = assetTransform.name.Remove(2, 1);
assetName = assetName.Insert(2, "0");
string aniSet = persons.First(item => item.id == assetName).aniSet;
string acPath = $"Assets/Art/AutoGen/Characters/character_{assetName}/ov_{assetName}_{aniSet}.overrideController";
// config animator controller
var rac = AssetDatabase.LoadAssetAtPath<RuntimeAnimatorController>(acPath);
Debug.Log(rac.name);
animator.runtimeAnimatorController = AssetDatabase.LoadAssetAtPath<RuntimeAnimatorController>(acPath);
animator.Play($"skill");
}
}
}