feat: add reusable virtual hud input
This commit is contained in:
@@ -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();
|
||||
|
||||
Reference in New Issue
Block a user