NLDClient-yudde/ProjectNLD/Assets/Art/temp/Editor/PlayerBrowser/PlayerInfo.cs

230 lines
7.5 KiB
C#
Raw Normal View History

2024-06-25 18:49:09 +08:00
using NPOI.OpenXmlFormats.Dml;
2024-06-25 16:13:00 +08:00
using UnityEditor;
using UnityEngine;
namespace PersonBrowser
{
public class PlayerInfo
{
private string m_Name;
2024-06-25 18:49:09 +08:00
private Transform m_Asset
{
get
{
try { return Player.transform.GetChild(0); }
catch { return null; }
}
}
2024-06-25 19:35:07 +08:00
public GameObject Player { get; set; }
2024-06-25 16:13:00 +08:00
public GameObject Skill { get; }
2024-06-25 19:35:07 +08:00
public Object Player_ac
{
get
{
try
{
return m_Asset.GetComponent<Animator>().runtimeAnimatorController;
}
catch
{
return null;
}
}
}
2024-06-25 18:49:09 +08:00
public GameObject Emoji
{
get
{
try
{
return m_Asset.Find("Root/Bip001/Bip001 Spine/Bip001 Spine1/Bip001 Neck/Bip001 Head/G_emoji/").gameObject;
}
catch
{
return null;
}
}
}
public GameObject Gun
{
get
{
try
{
Transform grip = m_Asset.Find("Root/Bip001/Bip001 Spine/Bip001 Spine1/Bip001 R Clavicle/Bip001 R UpperArm/Bip001 R Forearm/Bip001 R Hand/Grip_point01/");
return grip.GetChild(0).gameObject;
}
catch
{
return null;
}
}
}
public GameObject Bag
{
get
2024-06-27 13:39:10 +08:00
{
2024-06-25 18:49:09 +08:00
try
{
Transform point1 = m_Asset.Find("Root/Bip001/Bip001 Spine/Mount_point01/");
return point1.GetChild(0).gameObject;
}
catch
{
return null;
}
}
}
2024-06-25 16:13:00 +08:00
public GameObject Display { get; }
public Object Display_ac { get; }
public GameObject AutoGen { get; }
public Texture2D MainTex { get; }
2024-07-01 18:49:24 +08:00
public string ModelFile { get; }
public string SkinFile { get; }
public string AniFile { get; }
public Color State { get; }
2024-06-25 16:13:00 +08:00
public PlayerInfo(string id)
{
m_Name = id;
// Player 初始值在Assets中获取可写。
2024-06-25 16:13:00 +08:00
try
{
string path = $"Assets/Art/Character/Prefabs/Players/P_{m_Name}.prefab";
Player = AssetDatabase.LoadAssetAtPath<GameObject>(path);
}
catch
{
Player = null;
}
// Skill 只在Assets中获取不可写。
2024-06-25 16:13:00 +08:00
try
{
string path = $"Assets/Art/Animations/Battle/Skill/ani_{m_Name}_skill01.fbx";
Skill = AssetDatabase.LoadAssetAtPath<GameObject>(path);
}
catch
{
Skill = null;
}
// Player_S 只在Assets中获取不可写。
2024-06-25 16:13:00 +08:00
try
{
string path = $"Assets/Art/Character/Prefabs/Players_S/P_S_{m_Name}.prefab";
Display = AssetDatabase.LoadAssetAtPath<GameObject>(path);
}
catch
{
Display = null;
}
// Player_S Animator Controller 只在Assets中获取不可写。
2024-06-25 16:13:00 +08:00
try
{
Display_ac = Display.transform.GetChild(0).GetComponent<Animator>().runtimeAnimatorController;
}
catch
{
Display_ac = null;
}
// AutoGen 只在Assets中获取不可写。
string directory = $"Assets/Art_Out/AutoGen/Characters/character_{m_Name}/";
2024-06-25 16:13:00 +08:00
if (AssetDatabase.IsValidFolder(directory))
{
try
{
string[] guids = AssetDatabase.FindAssets("character", new string[] { directory });
string path = AssetDatabase.GUIDToAssetPath(guids[0]);
AutoGen = AssetDatabase.LoadAssetAtPath<GameObject>(path);
}
catch
{
AutoGen = null;
}
try
{
string path = $"Assets/Art_Out/AutoGen/Characters/character_{m_Name}/_MainTex.png";
2024-06-25 16:13:00 +08:00
MainTex = AssetDatabase.LoadAssetAtPath<Texture2D>(path);
}
catch
{
MainTex = null;
}
}
else
{
// Debug.Log($"character_{m_Name} 路径不存在, 需要先构建角色");
2024-06-25 16:13:00 +08:00
AutoGen = null;
MainTex = null;
};
2024-07-01 18:49:24 +08:00
// project_A assets
2024-09-14 16:54:20 +08:00
ModelFile = null;
SkinFile = null;
AniFile = null;
2024-07-01 18:49:24 +08:00
if (!System.IO.Directory.Exists($@"\\192.168.2.222\project_A"))
{
Debug.Log(@"无法链接:\\192.168.2.222\\project_A");
2024-07-01 18:49:24 +08:00
}
else
{
2024-09-14 16:54:20 +08:00
string str = "";
string modelPath1 = "";
string modelPath2 = "";
string skinPath = "";
if (m_Name.StartsWith("AA"))
2024-07-01 18:49:24 +08:00
{
2024-09-14 16:54:20 +08:00
str = m_Name.Remove(3, 1).Insert(3, "0");
modelPath1 = $@"\\192.168.2.222\project_A\02_模型\Players\{str.Remove(0, 1)}\{m_Name}\{m_Name}.max";
modelPath2 = $@"\\192.168.2.222\project_A\02_模型\Players\{str.Remove(0, 1)}\{m_Name}.max";
skinPath = $@"\\192.168.2.222\project_A\03_动作\角色蒙皮\异格\{str}\{m_Name}\{m_Name}_skin.max";
2024-07-01 18:49:24 +08:00
}
else
{
2024-09-14 16:54:20 +08:00
str = m_Name.Remove(2, 1).Insert(2, "0");
modelPath1 = $@"\\192.168.2.222\project_A\02_模型\Players\{str}\{m_Name}\{m_Name}.max";
modelPath2 = $@"\\192.168.2.222\project_A\02_模型\Players\{str}\{m_Name}.max";
skinPath = $@"\\192.168.2.222\project_A\03_动作\角色蒙皮\Player\{str}\{m_Name}\{m_Name}_skin.max";
2024-07-01 18:49:24 +08:00
}
2024-09-14 16:54:20 +08:00
if (System.IO.File.Exists(modelPath1) || System.IO.File.Exists(modelPath2))
2024-07-01 18:49:24 +08:00
{
2024-09-14 16:54:20 +08:00
ModelFile = m_Name + ".max";
2024-07-01 18:49:24 +08:00
}
2024-09-14 16:54:20 +08:00
if (System.IO.File.Exists(skinPath))
2024-07-01 18:49:24 +08:00
{
2024-09-14 16:54:20 +08:00
SkinFile = m_Name + "_skin.max";
2024-07-01 18:49:24 +08:00
}
2024-09-14 16:54:20 +08:00
string aniPath = $@"\\192.168.2.222\project_A\03_动作\角色技能\max\{m_Name}_skill01.max";
2024-09-14 16:54:20 +08:00
if (System.IO.File.Exists(aniPath))
2024-07-01 18:49:24 +08:00
{
AniFile = $"{m_Name}_skill01.max";
}
}
// 灰色:啥都没有
// 黄色:至少缺一项
// 绿色:齐全
// 红色:文件齐全但未构建角色
2024-07-01 18:49:24 +08:00
if (AniFile == null && ModelFile == null && SkinFile == null)
{
State = Color.gray;
}
else if (AniFile == null || ModelFile == null || SkinFile == null)
{
State = Color.yellow;
}
else if (AniFile != null && ModelFile != null && SkinFile != null)
{
State = AutoGen == null ? Color.red : Color.green;
}
else State = Color.white;
2024-06-25 16:13:00 +08:00
}
}
}