feat: add reusable virtual hud input

This commit is contained in:
ud18010
2026-07-30 11:14:56 +08:00
parent 3546d16632
commit 5853c5bd83
26 changed files with 6403 additions and 31 deletions
@@ -95,20 +95,31 @@ namespace XGame.EditorTools
}
}
public static void BuildVirtualInputFromCommandLine()
{
string jsonRoot = ResolveCommandLineJsonRoot();
string[] files =
{
"UI_VirtualJoystick.json",
"UI_VirtualActionPad.json"
};
int built = 0;
foreach (string file in files)
{
string output = BuildFromJsonFile(Path.Combine(jsonRoot, file));
if (string.IsNullOrEmpty(output))
{
throw new Exception("[UIGen] " + file + " build failed.");
}
built++;
}
Debug.Log("[UIGen] virtual input prefabs built: " + built);
}
public static void BuildAllFromCommandLine()
{
string jsonRoot = GetCommandLineValue("-uiJsonRoot");
if (string.IsNullOrEmpty(jsonRoot))
{
jsonRoot = ResolveJsonRoot();
}
else if (!Path.IsPathRooted(jsonRoot))
{
string projectDir = Directory.GetParent(Application.dataPath).FullName;
string repoDir = Directory.GetParent(projectDir)?.FullName ?? projectDir;
jsonRoot = Path.Combine(repoDir, jsonRoot);
}
string jsonRoot = ResolveCommandLineJsonRoot();
IReadOnlyList<string> outputs = BuildAll(jsonRoot);
if (outputs.Count == 0)
{
@@ -116,6 +127,24 @@ namespace XGame.EditorTools
}
}
private static string ResolveCommandLineJsonRoot()
{
string jsonRoot = GetCommandLineValue("-uiJsonRoot");
if (string.IsNullOrEmpty(jsonRoot))
{
return ResolveJsonRoot();
}
if (Path.IsPathRooted(jsonRoot))
{
return jsonRoot;
}
string projectDir = Directory.GetParent(Application.dataPath).FullName;
string repoDir = Directory.GetParent(projectDir)?.FullName ?? projectDir;
return Path.Combine(repoDir, jsonRoot);
}
public static ValidationResult Validate(string jsonPath)
{
ValidationResult vr = new ValidationResult();