prefab工具

main
tengwei 2024-06-25 19:35:07 +08:00
parent d01a82ad70
commit 192db9c8a1
4 changed files with 60 additions and 36 deletions

View File

@ -37,7 +37,7 @@ namespace PersonBrowser
playerPane.Add(A00Pane);
playerPane.Add(A01Pane);
var allObjects = JsonData.GetData();
listPane.makeItem = () => new Label();
listPane.bindItem = (item, index) =>
@ -79,16 +79,37 @@ namespace PersonBrowser
skillField.value = info.Skill;
box1.Add(skillField);
ObjectField emojiField = new("----emoji");
emojiField.value = info.Emoji;
TextField emojiField = new("----emoji");
try
{
emojiField.value = info.Emoji.name;
}
catch
{
emojiField.value = null;
}
box1.Add(emojiField);
ObjectField gunField = new("----gun");
gunField.value = info.Gun;
TextField gunField = new("----gun");
try
{
gunField.value = info.Gun.name;
}
catch
{
gunField.value = null;
}
box1.Add(gunField);
ObjectField bagField = new("----bag");
bagField.value = info.Bag;
TextField bagField = new("----bag");
try
{
bagField.value = info.Bag.name;
}
catch
{
bagField.value = null;
}
box1.Add(bagField);
ObjectField player_ac_field = new("----controller");

View File

@ -15,9 +15,22 @@ namespace PersonBrowser
catch { return null; }
}
}
public GameObject Player { get; set; } // zheli;
public GameObject Player { get; set; }
public GameObject Skill { get; }
public Object Player_ac { get; }
public Object Player_ac
{
get
{
try
{
return m_Asset.GetComponent<Animator>().runtimeAnimatorController;
}
catch
{
return null;
}
}
}
public GameObject Emoji
{
get
@ -36,7 +49,6 @@ namespace PersonBrowser
{
get
{
// Get gun
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/");
@ -51,7 +63,7 @@ namespace PersonBrowser
public GameObject Bag
{
get
{ // Get bag
{
try
{
Transform point1 = m_Asset.Find("Root/Bip001/Bip001 Spine/Mount_point01/");
@ -98,7 +110,7 @@ namespace PersonBrowser
public PlayerInfo(string id)
{
m_Name = id;
// Get Player prefab
// Player 初始值在Assets中获取可写。
try
{
string path = $"Assets/Art/Character/Prefabs/Players/P_{m_Name}.prefab";
@ -109,7 +121,7 @@ namespace PersonBrowser
Player = null;
}
// Get skill animation
// Skill 只在Assets中获取不可写。
try
{
string path = $"Assets/Art/Animations/Battle/Skill/ani_{m_Name}_skill01.fbx";
@ -120,17 +132,7 @@ namespace PersonBrowser
Skill = null;
}
// Get player animator controller
try
{
Player_ac = m_Asset.GetComponent<Animator>().runtimeAnimatorController;
}
catch
{
Player_ac = null;
}
// Get player_s prefab
// Player_S 只在Assets中获取不可写。
try
{
string path = $"Assets/Art/Character/Prefabs/Players_S/P_S_{m_Name}.prefab";
@ -141,7 +143,7 @@ namespace PersonBrowser
Display = null;
}
// Get player_s animator controller
// Player_S Animator Controller 只在Assets中获取不可写。
try
{
Display_ac = Display.transform.GetChild(0).GetComponent<Animator>().runtimeAnimatorController;
@ -151,8 +153,7 @@ namespace PersonBrowser
Display_ac = null;
}
// Get AutoGen character prefab
// AutoGen 只在Assets中获取不可写。
string directory = $"Assets/Art/AutoGen/Characters/character_{m_Name}/";
if (AssetDatabase.IsValidFolder(directory))
{

View File

@ -1,4 +1,3 @@
Box {
margin : 1%;
border-color: dimgrey;
margin-top : 10px;
}

View File

@ -24,31 +24,34 @@ namespace PersonBrowser
public void CreateGUI()
{
VisualElement root = rootVisualElement;
Box box = new Box();
box.style.marginTop = 10;
root.Add(box);
Label label1 = new Label("Edit Player");
root.Add(label1);
box.Add(label1);
charaField = new ObjectField("player prefab") { objectType = typeof(GameObject), allowSceneObjects = false };
root.Add(charaField);
box.Add(charaField);
gunField = new ObjectField("add gun") { objectType = typeof(GameObject), allowSceneObjects = false };
root.Add(gunField);
box.Add(gunField);
bagField = new ObjectField("add bag") { objectType = typeof(GameObject), allowSceneObjects = false };
root.Add(bagField);
box.Add(bagField);
Button button1 = new()
{
name = "button1",
text = "applay"
};
root.Add(button1);
box.Add(button1);
button1.RegisterCallback<ClickEvent>(EditPlayer);
TextElement textElement = new() { text = "µ÷ÕûºÃ±³°üλÖúó, Apply Overrides" };
root.Add(textElement);
box.Add(textElement);
box1 = new Box();
box1.style.marginTop = 60;
root.Add(box1);
}
public void OnSelectionChange()