Editor/BuildSettingsEditor.cs
/// <summary>
/// Inserts arguments to the batch file and returns in as string.
/// </summary>
/// <param name="batchFile">Batch file to insert arguments into.</param>
/// <param name="args">Arguments for the batch file.</param>
/// <returns>Batch script with inserted arguments.</returns>
Inserts arguments to the batch file and returns in as string.
Inserts arguments to the batch file and returns in as string .
private string CompileBatFile(Object batchFile, IReadOnlyList<string> args)
        {
            var folders = Application.dataPath.Split(Path.DirectorySeparatorChar, Path.AltDirectorySeparatorChar).ToList();
            folders.RemoveAt(folders.Count - 1);
            var assetsPath = string.Join(Path.DirectorySeparatorChar.ToString(), folders);
            var batchFilePath = AssetDatabase.GetAssetPath(batchFile);
            var filePath = $"{assetsPath}/{batchFilePath}";
            var batch = File.ReadAllText(filePath);
            var parsedArguments = (target as BuildSettings).ParseArguments(args);
            for (var i = 0; i < parsedArguments.Length; i++)
            {
                batch = batch.Replace($"%{(i + 1).ToString()}",
                    string.IsNullOrEmpty(parsedArguments[i]) ? args[i] : parsedArguments[i]);
            }
            return batch;
        }
private string CompileBatFile ( Object batchFile , IReadOnlyList < string > args ) { var folders = Application . dataPath . Split ( Path . DirectorySeparatorChar , Path . AltDirectorySeparatorChar ) . ToList ( ) ; folders . RemoveAt ( folders . Count - 1 ) ; var assetsPath = string . Join ( Path . DirectorySeparatorChar . ToString ( ) , folders ) ; var batchFilePath = AssetDatabase . GetAssetPath ( batchFile ) ; var filePath = $" { assetsPath } / { batchFilePath } " ; var batch = File . ReadAllText ( filePath ) ; var parsedArguments = ( target as BuildSettings ) . ParseArguments ( args ) ; for ( var i = 0 ; i < parsedArguments . Length ; i ++ ) { batch = batch . Replace ( $" % { ( i + 1 ) . ToString ( ) } " , string . IsNullOrEmpty ( parsedArguments [ i ] ) ? args [ i ] : parsedArguments [ i ] ) ; } return batch ; }
Inserts arguments to the batch file and returns in as string.
Inserts arguments to the batch file and returns in as string .
Batch script with inserted arguments.
Batch script with inserted arguments .
batchFile
Object
Batch file to insert arguments into.
Batch file to insert arguments into .
args
IReadOnlyList<string>
Arguments for the batch file.
Arguments for the batch file .