├── BuildScripts.meta ├── BuildScripts ├── Unity-Hub.meta └── Unity-Hub │ ├── build.bat │ ├── build.bat.meta │ ├── build.ps1 │ ├── build.ps1.meta │ ├── build.sh │ ├── build.sh.meta │ ├── unity.ps1 │ ├── unity.ps1.meta │ ├── unity.sh │ └── unity.sh.meta ├── Editor.meta ├── Editor ├── BatchMode.meta ├── BatchMode │ ├── BatchModeBuilder.cs │ ├── BatchModeBuilder.cs.meta │ ├── CommandLineParser.cs │ └── CommandLineParser.cs.meta ├── CliTools.meta ├── CliTools │ ├── CustomEditors.meta │ ├── CustomEditors │ │ ├── CliToolEditorPresenter.cs │ │ ├── CliToolEditorPresenter.cs.meta │ │ ├── CliToolsProjectSettingsProvider.cs │ │ └── CliToolsProjectSettingsProvider.cs.meta │ ├── Runtime.meta │ └── Runtime │ │ ├── Base.meta │ │ ├── Base │ │ ├── Attributes.meta │ │ ├── Attributes │ │ │ ├── BaseCliToolAttribute.cs │ │ │ ├── BaseCliToolAttribute.cs.meta │ │ │ ├── ReflectionHelper.cs │ │ │ └── ReflectionHelper.cs.meta │ │ ├── Tools.meta │ │ └── Tools │ │ │ ├── BaseCliTool.cs │ │ │ ├── BaseCliTool.cs.meta │ │ │ ├── ICliToolFriendlyName.cs │ │ │ ├── ICliToolFriendlyName.cs.meta │ │ │ ├── ICliToolHelpLink.cs │ │ │ ├── ICliToolHelpLink.cs.meta │ │ │ ├── ICliToolInstalled.cs │ │ │ ├── ICliToolInstalled.cs.meta │ │ │ ├── ICliToolPath.cs │ │ │ ├── ICliToolPath.cs.meta │ │ │ ├── ICliToolVersion.cs │ │ │ ├── ICliToolVersion.cs.meta │ │ │ ├── ToolResult.cs │ │ │ └── ToolResult.cs.meta │ │ ├── Cli.cs │ │ ├── Cli.cs.meta │ │ ├── CommandLine.meta │ │ ├── CommandLine │ │ ├── CommandLine.cs │ │ ├── CommandLine.cs.meta │ │ ├── OsxTerminal.meta │ │ ├── OsxTerminal │ │ │ ├── OsxTerminal.cs │ │ │ └── OsxTerminal.cs.meta │ │ ├── WindowsCmd.meta │ │ └── WindowsCmd │ │ │ ├── WindowsCmd.cs │ │ │ └── WindowsCmd.cs.meta │ │ ├── GenericTool.meta │ │ ├── GenericTool │ │ ├── CliToolAttribute.cs │ │ ├── CliToolAttribute.cs.meta │ │ ├── CliToolPathAttribute.cs │ │ ├── CliToolPathAttribute.cs.meta │ │ ├── GenericTool.cs │ │ └── GenericTool.cs.meta │ │ ├── PathResolver.meta │ │ ├── PathResolver │ │ ├── OsxTerminal.meta │ │ ├── OsxTerminal │ │ │ ├── OsxWhich.cs │ │ │ └── OsxWhich.cs.meta │ │ ├── PathResolver.cs │ │ ├── PathResolver.cs.meta │ │ ├── WindowsCmd.meta │ │ └── WindowsCmd │ │ │ ├── WindowsWhere.cs │ │ │ └── WindowsWhere.cs.meta │ │ ├── Tar.meta │ │ ├── Tar │ │ ├── Tar.cs │ │ ├── Tar.cs.meta │ │ ├── TarAttribute.cs │ │ └── TarAttribute.cs.meta │ │ ├── ToolNotInstalledException.cs │ │ ├── ToolNotInstalledException.cs.meta │ │ ├── XCodeBuild.meta │ │ ├── XCodeBuild │ │ ├── XCodeBuild.cs │ │ ├── XCodeBuild.cs.meta │ │ ├── XCodeBuildAttribute.cs │ │ └── XCodeBuildAttribute.cs.meta │ │ ├── Zip.meta │ │ └── Zip │ │ ├── Zip.cs │ │ ├── Zip.cs.meta │ │ ├── ZipAttribute.cs │ │ └── ZipAttribute.cs.meta ├── Core.meta ├── Core │ ├── Parameters.meta │ ├── Parameters │ │ ├── BuildParameterPresenter.cs │ │ ├── BuildParameterPresenter.cs.meta │ │ ├── Int.meta │ │ ├── Int │ │ │ ├── IntBuildParameter.cs │ │ │ ├── IntBuildParameter.cs.meta │ │ │ ├── IntBuildParameterEditor.cs │ │ │ ├── IntBuildParameterEditor.cs.meta │ │ │ ├── IntBuildParameterPresenter.cs │ │ │ └── IntBuildParameterPresenter.cs.meta │ │ ├── ScriptableBuildParameter.cs │ │ ├── ScriptableBuildParameter.cs.meta │ │ ├── String.meta │ │ └── String │ │ │ ├── StringBuildParameter.cs │ │ │ ├── StringBuildParameter.cs.meta │ │ │ ├── StringBuildParameterEditor.cs │ │ │ ├── StringBuildParameterEditor.cs.meta │ │ │ ├── StringBuildParameterPresenter.cs │ │ │ └── StringBuildParameterPresenter.cs.meta │ ├── Pipelines.meta │ ├── Pipelines │ │ ├── BuildPipeline.cs │ │ ├── BuildPipeline.cs.meta │ │ ├── CustomEditors.meta │ │ └── CustomEditors │ │ │ ├── BuildPipelinePresenter.cs │ │ │ ├── BuildPipelinePresenter.cs.meta │ │ │ ├── BuildPipelinesProjectSettingsProvider.cs │ │ │ └── BuildPipelinesProjectSettingsProvider.cs.meta │ ├── Steps.meta │ └── Steps │ │ ├── Build.meta │ │ ├── Build │ │ ├── UnityBuildStep.cs │ │ ├── UnityBuildStep.cs.meta │ │ ├── UnityBuildStepWithOptions.cs │ │ └── UnityBuildStepWithOptions.cs.meta │ │ ├── Custom.meta │ │ ├── Custom │ │ ├── BuildStep.cs │ │ └── BuildStep.cs.meta │ │ ├── Exceptions.meta │ │ └── Exceptions │ │ ├── BuildStepFailedException.cs │ │ └── BuildStepFailedException.cs.meta ├── Defines.meta ├── Defines │ ├── ApplyDefines.cs │ ├── ApplyDefines.cs.meta │ ├── DefineSymbolPropertyDrawer.cs │ ├── DefineSymbolPropertyDrawer.cs.meta │ ├── ScriptingDefineSymbols.cs │ ├── ScriptingDefineSymbols.cs.meta │ ├── ScriptingDefineSymbolsEditor.cs │ ├── ScriptingDefineSymbolsEditor.cs.meta │ ├── ScriptingDefineSymbolsPresenter.cs │ └── ScriptingDefineSymbolsPresenter.cs.meta ├── IO.meta ├── IO │ ├── Archive.meta │ ├── Archive │ │ ├── CreateZipArchiveStep.cs │ │ └── CreateZipArchiveStep.cs.meta │ ├── CustomEditors.meta │ ├── CustomEditors │ │ ├── CompositeScriptablePathEditor.cs │ │ ├── CompositeScriptablePathEditor.cs.meta │ │ ├── EnsureDirectoryEmptyEditor.cs │ │ ├── EnsureDirectoryEmptyEditor.cs.meta │ │ ├── EnsureDirectoryExistsEditor.cs │ │ └── EnsureDirectoryExistsEditor.cs.meta │ ├── Directory.meta │ ├── Directory │ │ ├── CopyDirectory.cs │ │ ├── CopyDirectory.cs.meta │ │ ├── EnsureDirectoryEmpty.cs │ │ ├── EnsureDirectoryEmpty.cs.meta │ │ ├── EnsureDirectoryExists.cs │ │ └── EnsureDirectoryExists.cs.meta │ ├── Files.meta │ ├── Files │ │ ├── CopyFileToDirectory.cs │ │ ├── CopyFileToDirectory.cs.meta │ │ ├── DeleteFileOrDirectory.cs │ │ └── DeleteFileOrDirectory.cs.meta │ ├── Path.meta │ └── Path │ │ ├── BaseScriptablePath.cs │ │ ├── BaseScriptablePath.cs.meta │ │ ├── CompositeScriptablePath.cs │ │ ├── CompositeScriptablePath.cs.meta │ │ ├── Core.meta │ │ ├── Core │ │ ├── PathProperty.cs │ │ ├── PathProperty.cs.meta │ │ ├── PathPropertyDrawer.cs │ │ ├── PathPropertyDrawer.cs.meta │ │ ├── PathTypes.cs │ │ ├── PathTypes.cs.meta │ │ ├── ProjectPath.cs │ │ └── ProjectPath.cs.meta │ │ ├── ScriptablePath.cs │ │ ├── ScriptablePath.cs.meta │ │ ├── Steps.meta │ │ └── Steps │ │ ├── GenerateRandomPath.cs │ │ └── GenerateRandomPath.cs.meta ├── MenuPaths.cs ├── MenuPaths.cs.meta ├── Platforms.meta ├── Platforms │ ├── Android.meta │ ├── Android │ │ ├── Build.meta │ │ ├── Build │ │ │ ├── BuildAab.cs │ │ │ ├── BuildAab.cs.meta │ │ │ ├── BuildApk.cs │ │ │ └── BuildApk.cs.meta │ │ ├── CustomEditors.meta │ │ ├── CustomEditors │ │ │ ├── SetAliasEditor.cs │ │ │ ├── SetAliasEditor.cs.meta │ │ │ ├── SetKeystorePasswordEditor.cs │ │ │ └── SetKeystorePasswordEditor.cs.meta │ │ ├── Pre.meta │ │ └── Pre │ │ │ ├── SetAlias.cs │ │ │ ├── SetAlias.cs.meta │ │ │ ├── SetDebugKeystore.cs │ │ │ ├── SetDebugKeystore.cs.meta │ │ │ ├── SetKeystorePassword.cs │ │ │ └── SetKeystorePassword.cs.meta │ ├── Standalone.meta │ ├── Standalone │ │ ├── Build.meta │ │ └── Build │ │ │ ├── BuildMacOS.cs │ │ │ ├── BuildMacOS.cs.meta │ │ │ ├── BuildWindows.cs │ │ │ ├── BuildWindows.cs.meta │ │ │ ├── BuildWindows64.cs │ │ │ └── BuildWindows64.cs.meta │ ├── WebGL.meta │ ├── WebGL │ │ ├── BuildWebGL.cs │ │ └── BuildWebGL.cs.meta │ ├── iOS.meta │ └── iOS │ │ ├── CustomEditors.meta │ │ ├── CustomEditors │ │ ├── Archive.meta │ │ ├── Archive │ │ │ ├── ArchiveEditor.cs │ │ │ └── ArchiveEditor.cs.meta │ │ ├── Distribute.meta │ │ ├── Distribute │ │ │ ├── DistributeIosApplicationStepEditor.cs │ │ │ ├── DistributeIosApplicationStepEditor.cs.meta │ │ │ ├── ExportIpaEditor.cs │ │ │ ├── ExportIpaEditor.cs.meta │ │ │ ├── UploadToAppStoreEditor.cs │ │ │ └── UploadToAppStoreEditor.cs.meta │ │ ├── Plist.meta │ │ ├── Plist │ │ │ ├── ModifyInfoPlistEditor.cs │ │ │ └── ModifyInfoPlistEditor.cs.meta │ │ ├── Signing.meta │ │ └── Signing │ │ │ ├── SetManualProvisionProfileEditor.cs │ │ │ ├── SetManualProvisionProfileEditor.cs.meta │ │ │ ├── SetTeamIdEditor.cs │ │ │ └── SetTeamIdEditor.cs.meta │ │ ├── Models.meta │ │ ├── Models │ │ ├── ProvisioningProfile.cs │ │ └── ProvisioningProfile.cs.meta │ │ ├── Steps.meta │ │ └── Steps │ │ ├── Archive.meta │ │ ├── Archive │ │ ├── Archive.cs │ │ ├── Archive.cs.meta │ │ ├── ArchiveProject.cs │ │ ├── ArchiveProject.cs.meta │ │ ├── ArchiveWorkspace.cs │ │ └── ArchiveWorkspace.cs.meta │ │ ├── Build.meta │ │ ├── Build │ │ ├── BuildXCode.cs │ │ └── BuildXCode.cs.meta │ │ ├── Distribute.meta │ │ ├── Distribute │ │ ├── DistributeIosApplicationStep.cs │ │ ├── DistributeIosApplicationStep.cs.meta │ │ ├── ExportIpa.cs │ │ ├── ExportIpa.cs.meta │ │ ├── ExportMethods.cs │ │ ├── ExportMethods.cs.meta │ │ ├── UploadToAppStore.cs │ │ └── UploadToAppStore.cs.meta │ │ ├── Plist.meta │ │ ├── Plist │ │ ├── Elements.meta │ │ ├── Elements │ │ │ ├── BoolPlistElement.cs │ │ │ ├── BoolPlistElement.cs.meta │ │ │ ├── FloatPlistElement.cs │ │ │ ├── FloatPlistElement.cs.meta │ │ │ ├── IPlistElement.cs │ │ │ ├── IPlistElement.cs.meta │ │ │ ├── IntPlistElement.cs │ │ │ ├── IntPlistElement.cs.meta │ │ │ ├── SerializablePlistElement.cs │ │ │ ├── SerializablePlistElement.cs.meta │ │ │ ├── StringPlistElement.cs │ │ │ └── StringPlistElement.cs.meta │ │ ├── ModifyInfoPlist.cs │ │ └── ModifyInfoPlist.cs.meta │ │ ├── Signing.meta │ │ └── Signing │ │ ├── SetAutomaticSigning.cs │ │ ├── SetAutomaticSigning.cs.meta │ │ ├── SetManualProvisionProfile.cs │ │ ├── SetManualProvisionProfile.cs.meta │ │ ├── SetTeamId.cs │ │ └── SetTeamId.cs.meta ├── Styles.meta ├── Styles │ ├── Styles.cs │ └── Styles.cs.meta ├── UniTools.Build.asmdef ├── UniTools.Build.asmdef.meta ├── UnityEnvironment.meta ├── UnityEnvironment │ ├── CustomEditors.meta │ ├── CustomEditors │ │ ├── UnityEnvironmentVariableEditorPresenter.cs │ │ ├── UnityEnvironmentVariableEditorPresenter.cs.meta │ │ ├── UnityEnvironmentVariablesHeaderPresenter.cs │ │ ├── UnityEnvironmentVariablesHeaderPresenter.cs.meta │ │ ├── UnityEnvironmentWindow.cs │ │ └── UnityEnvironmentWindow.cs.meta │ ├── Runtime.meta │ └── Runtime │ │ ├── PathVariableAttribute.cs │ │ ├── PathVariableAttribute.cs.meta │ │ ├── UnityEnvironment.cs │ │ ├── UnityEnvironment.cs.meta │ │ ├── UnityEnvironmentVariableModel.cs │ │ └── UnityEnvironmentVariableModel.cs.meta ├── Versioning.meta └── Versioning │ ├── Semantic.meta │ └── Semantic │ ├── Exceptions.meta │ ├── Exceptions │ ├── VersionIsNotSemanticException.cs │ └── VersionIsNotSemanticException.cs.meta │ ├── Steps.meta │ ├── Steps │ ├── Pre.meta │ └── Pre │ │ ├── BumpSemanticBuildValue.cs │ │ ├── BumpSemanticBuildValue.cs.meta │ │ ├── BumpSemanticMajorValue.cs │ │ ├── BumpSemanticMajorValue.cs.meta │ │ ├── BumpSemanticMinorValue.cs │ │ ├── BumpSemanticMinorValue.cs.meta │ │ ├── BumpSemanticRevisionValue.cs │ │ ├── BumpSemanticRevisionValue.cs.meta │ │ ├── ChangeSemanticVersionStep.cs │ │ ├── ChangeSemanticVersionStep.cs.meta │ │ ├── IncrementSemanticVersionStep.cs │ │ └── IncrementSemanticVersionStep.cs.meta │ ├── Variables.meta │ └── Variables │ ├── ApplicationVersion.cs │ ├── ApplicationVersion.cs.meta │ ├── ApplicationVersionEditor.cs │ └── ApplicationVersionEditor.cs.meta ├── LICENSE ├── LICENSE.meta ├── README.md ├── README.md.meta ├── package.json └── package.json.meta /BuildScripts.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 1a0ec2e43bf2f4451b4eb2441eaddf3f 3 | folderAsset: yes 4 | DefaultImporter: 5 | externalObjects: {} 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /BuildScripts/Unity-Hub.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 54fe9e9d43ac241bf88b7d2140bf3e89 3 | folderAsset: yes 4 | DefaultImporter: 5 | externalObjects: {} 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /BuildScripts/Unity-Hub/build.bat: -------------------------------------------------------------------------------- 1 | @echo off 2 | echo TODO CallPSHere -------------------------------------------------------------------------------- /BuildScripts/Unity-Hub/build.bat.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 14f84e7e9132e49d28cbfd2938d08f22 3 | DefaultImporter: 4 | externalObjects: {} 5 | userData: 6 | assetBundleName: 7 | assetBundleVariant: 8 | -------------------------------------------------------------------------------- /BuildScripts/Unity-Hub/build.ps1: -------------------------------------------------------------------------------- 1 | Write-Output "PowerShell $($PSVersionTable.PSEdition) version $($PSVersionTable.PSVersion)" 2 | #The default quit timeout is 300 seconds (5 mins). The full build process could take more time, that's why we set this value bigger 3 | $QuitTimeout=86400 4 | #Define the project path 5 | $ProjectPath=$(pwd) 6 | #Parse UnityVersion from the version file 7 | $UnityVersion = Get-Content "$ProjectPath/ProjectSettings/ProjectVersion.txt" -Raw 8 | $UnityVersion = $UnityVersion -split " " 9 | $UnityVersion = $UnityVersion[1] 10 | $UnityVersion = $UnityVersion -split "\n" 11 | $UnityVersion = $UnityVersion[0] 12 | $UnityVersion = $UnityVersion.Trim() 13 | #Create a path to the Unity Folder 14 | $UnityPath="$Env:Programfiles\Unity\Hub\Editor\$UnityVersion\Editor\Unity.exe" 15 | #Path to log file 16 | $BuildLog="PipelineResults.log" 17 | 18 | 19 | # Remove previous Editor.log. 20 | Remove-Item "$BuildLog" -Recurse -ErrorAction Ignore 21 | # Start the Unity process in background thread. 22 | Start-Process -FilePath "$UnityPath" -ArgumentList "-quit -quitTimeout $QuitTimeout -batchmode -projectPath $ProjectPath -executeMethod UniTools.Build.BatchModeBuilder.Execute -logFile $BuildLog $args" 23 | # Wait for Editor.log to be created. 24 | while (!(Test-Path "$BuildLog")) { 25 | Start-Sleep -m 10 26 | } 27 | # Output Editor.log until Unity is done. 28 | Get-Content -Path "$BuildLog" -Tail 1 -Wait | Where-Object { 29 | Write-Host $_ 30 | 31 | if ($_ -match "Application will terminate with return code") { 32 | [int]$exitCode = $_.Substring($_.get_Length()-1) 33 | Write-Host "Exit code is: " 34 | Write-Host $exitCode 35 | exit $exitCode 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /BuildScripts/Unity-Hub/build.ps1.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 4dc9052cbe57f4ffea76a23eff905277 3 | DefaultImporter: 4 | externalObjects: {} 5 | userData: 6 | assetBundleName: 7 | assetBundleVariant: 8 | -------------------------------------------------------------------------------- /BuildScripts/Unity-Hub/build.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | #This file must be located at the project root. 3 | 4 | #The default quit timeout is 300 seconds (5 mins). The full build process could take more time, that's why we set this value bigger 5 | QUIT_TIMEOUT=86400 6 | #This is a current project directory. 7 | PROJECT_PATH=$(pwd) 8 | 9 | #Checking if the Unity Path was delivered with from CLI 10 | UNITY_PATH="$1" 11 | if [ -f "$UNITY_PATH" ] 12 | then 13 | echo "The Unity Editor is found at Path $UNITY_PATH from CLI" 14 | else 15 | echo "Unity path is not assigned from the CLI. Going to generate it based on the project version" 16 | #Parse the Unity version from the ProjectVersion.txt file 17 | UNITY_VERSION=$(awk '{ print $2 ; exit}' "$PROJECT_PATH/ProjectSettings/ProjectVersion.txt") 18 | if [[ "$OSTYPE" == "darwin"* ]] 19 | then 20 | echo "The platform is OSX" 21 | #Path to the Unity Editor executable 22 | UNITY_PATH="/Applications/Unity/Hub/Editor/$UNITY_VERSION/Unity.app/Contents/MacOS/Unity" 23 | else 24 | echo "This is Windows. Should be Windows :)" 25 | UNITY_PATH="C:/Program Files/Unity/Hub/Editor/$UNITY_VERSION/Editor/Unity.exe" 26 | fi 27 | fi 28 | 29 | echo "Unity path is $UNITY_PATH" 30 | 31 | $UNITY_PATH -quit -quitTimeout $QUIT_TIMEOUT -batchmode -projectPath $PROJECT_PATH -executeMethod UniTools.Build.BatchModeBuilder.Execute -logFile - "$@" 32 | 33 | #TODO For the future 34 | # -stackTraceLogType None 35 | -------------------------------------------------------------------------------- /BuildScripts/Unity-Hub/build.sh.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 427c3c06ef1ab436cb96382583cbff5d 3 | DefaultImporter: 4 | externalObjects: {} 5 | userData: 6 | assetBundleName: 7 | assetBundleVariant: 8 | -------------------------------------------------------------------------------- /BuildScripts/Unity-Hub/unity.ps1: -------------------------------------------------------------------------------- 1 | Write-Output "PowerShell $($PSVersionTable.PSEdition) version $($PSVersionTable.PSVersion)" 2 | #The default quit timeout is 300 seconds (5 mins). The full build process could take more time, that's why we set this value bigger 3 | $QuitTimeout=86400 4 | #Define the project path 5 | $ProjectPath=$(pwd) 6 | #Parse UnityVersion from the version file 7 | $UnityVersion = Get-Content "$ProjectPath/ProjectSettings/ProjectVersion.txt" -Raw 8 | $UnityVersion = $UnityVersion -split " " 9 | $UnityVersion = $UnityVersion[1] 10 | $UnityVersion = $UnityVersion -split "\n" 11 | $UnityVersion = $UnityVersion[0] 12 | $UnityVersion = $UnityVersion.Trim() 13 | #Create a path to the Unity Folder 14 | $UnityPath="$Env:Programfiles\Unity\Hub\Editor\$UnityVersion\Editor\Unity.exe" 15 | #Path to log file 16 | $BuildLog="PipelineResults.log" 17 | 18 | 19 | # Remove previous Editor.log. 20 | Remove-Item "$BuildLog" -Recurse -ErrorAction Ignore 21 | # Start the Unity process in background thread. 22 | Start-Process -FilePath "$UnityPath" -ArgumentList "-quit -quitTimeout $QuitTimeout -batchmode -projectPath $ProjectPath -executeMethod UniTools.Build.BatchModeBuilder.Execute -logFile $BuildLog $args" 23 | # Wait for Editor.log to be created. 24 | while (!(Test-Path "$BuildLog")) { 25 | Start-Sleep -m 10 26 | } 27 | # Output Editor.log until Unity is done. 28 | Get-Content -Path "$BuildLog" -Tail 1 -Wait | Where-Object { 29 | Write-Host $_ 30 | 31 | if ($_ -match "Application will terminate with return code") { 32 | [int]$exitCode = $_.Substring($_.get_Length()-1) 33 | Write-Host "Exit code is: " 34 | Write-Host $exitCode 35 | exit $exitCode 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /BuildScripts/Unity-Hub/unity.ps1.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: bdc72c3ac11a3401c9d499ae77a3ed23 3 | DefaultImporter: 4 | externalObjects: {} 5 | userData: 6 | assetBundleName: 7 | assetBundleVariant: 8 | -------------------------------------------------------------------------------- /BuildScripts/Unity-Hub/unity.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | #This script is usefull to run Unity CLI commands 3 | 4 | #Read a Unity Version as a first arg (can be empty) in this case the version will be defined from the Project settings. 5 | UNITY_VERSION="$1" 6 | #Build Unity Path according to the OS 7 | if [[ "$OSTYPE" == "darwin"* ]] 8 | then 9 | echo "The platform is OSX" 10 | #Path to the Unity Editor executable 11 | UNITY_PATH="/Applications/Unity/Hub/Editor/$UNITY_VERSION/Unity.app/Contents/MacOS/Unity" 12 | else 13 | echo "This is Windows. Should be Windows :)" 14 | UNITY_PATH="C:/Program Files/Unity/Hub/Editor/$UNITY_VERSION/Editor/Unity.exe" 15 | fi 16 | #Checking if the Unity Path 17 | echo "Checking if Unity is available at path $UNITY_PATH" 18 | if [ -f "$UNITY_PATH" ] 19 | then 20 | echo "The Unity Editor is found at Path $UNITY_PATH" 21 | else 22 | echo "Unity is not found. Going to generate it based on the project version" 23 | #This is a current project directory. 24 | PROJECT_PATH=$(pwd) 25 | #Parse the Unity version from the ProjectVersion.txt file 26 | UNITY_VERSION=$(awk '{ print $2 ; exit}' "$PROJECT_PATH/ProjectSettings/ProjectVersion.txt") 27 | if [[ "$OSTYPE" == "darwin"* ]] 28 | then 29 | echo "The platform is OSX" 30 | #Path to the Unity Editor executable 31 | UNITY_PATH="/Applications/Unity/Hub/Editor/$UNITY_VERSION/Unity.app/Contents/MacOS/Unity" 32 | else 33 | echo "This is Windows. Should be Windows :)" 34 | UNITY_PATH="C:/Program Files/Unity/Hub/Editor/$UNITY_VERSION/Editor/Unity.exe" 35 | fi 36 | fi 37 | 38 | echo "Unity path is $UNITY_PATH" 39 | 40 | #Execute the command 41 | "$UNITY_PATH" "$@" 42 | -------------------------------------------------------------------------------- /BuildScripts/Unity-Hub/unity.sh.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: c64da54ab99b34bed856abe127ab322f 3 | DefaultImporter: 4 | externalObjects: {} 5 | userData: 6 | assetBundleName: 7 | assetBundleVariant: 8 | -------------------------------------------------------------------------------- /Editor.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 13015269488b44188a4fe7f1f09b5628 3 | folderAsset: yes 4 | DefaultImporter: 5 | externalObjects: {} 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Editor/BatchMode.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 3ebd90862a084b719e09303fea82a630 3 | timeCreated: 1623332807 -------------------------------------------------------------------------------- /Editor/BatchMode/BatchModeBuilder.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Threading.Tasks; 3 | using UnityEditor; 4 | using UnityEngine; 5 | 6 | namespace UniTools.Build 7 | { 8 | public static class BatchModeBuilder 9 | { 10 | public static async void Execute() 11 | { 12 | if (!Application.isBatchMode) 13 | { 14 | throw new Exception($"{nameof(BatchModeBuilder)}: can be run only from the BatchMode!"); 15 | } 16 | 17 | const string key = "--pipeline"; 18 | string pipeline = string.Empty; 19 | 20 | if (!CommandLineParser.TryToParseValue(Environment.CommandLine, key, out object v)) 21 | { 22 | throw new Exception($"The pipeline is not assigned from the CommandLine. Use {key} to define a pipeline for execution."); 23 | } 24 | 25 | pipeline = v.ToString(); 26 | 27 | if (Find(pipeline) != null) 28 | { 29 | await RunBuildPipeline(pipeline); 30 | } 31 | else 32 | { 33 | throw new Exception($"Failed to find a pipeline with name {pipeline}!"); 34 | } 35 | } 36 | 37 | private static BuildPipeline Find(string pipelineName) 38 | { 39 | string[] guids = AssetDatabase.FindAssets($"t:{nameof(BuildPipeline)}"); 40 | 41 | foreach (string guid in guids) 42 | { 43 | string path = AssetDatabase.GUIDToAssetPath(guid); 44 | BuildPipeline pipeline = AssetDatabase.LoadAssetAtPath(path); 45 | if (pipeline == null) 46 | { 47 | continue; 48 | } 49 | 50 | if (pipeline.name.Equals(pipelineName)) 51 | { 52 | return pipeline; 53 | } 54 | } 55 | 56 | return null; 57 | } 58 | 59 | private static async Task RunBuildPipeline(string name) 60 | { 61 | BuildPipeline pipeline = Find(name); 62 | if (pipeline == null) 63 | { 64 | throw new Exception($"Failed to find a pipeline with name {name}!"); 65 | } 66 | 67 | int stepsCount = pipeline.Count; 68 | for (int i = 0; i < stepsCount; i++) 69 | { 70 | await pipeline.RunStep(i); 71 | pipeline = Find(name); 72 | if (pipeline == null) 73 | { 74 | throw new Exception($"Failed to find a pipeline with name {name}!"); 75 | } 76 | } 77 | } 78 | } 79 | } -------------------------------------------------------------------------------- /Editor/BatchMode/BatchModeBuilder.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 57cae2cd2587447db5b33f4117623788 3 | timeCreated: 1623152029 -------------------------------------------------------------------------------- /Editor/BatchMode/CommandLineParser.cs: -------------------------------------------------------------------------------- 1 | namespace UniTools.Build 2 | { 3 | public static class CommandLineParser 4 | { 5 | private const string KeyStart = "-"; 6 | 7 | public static bool TryToParseValue(string commandLine, string key, out object val) 8 | { 9 | string[] args = commandLine.Split(' '); 10 | for (int i = 0; i < args.Length; i++) 11 | { 12 | if (IsKey(args[i]) && args[i].Equals(key)) 13 | { 14 | int next = i + 1; 15 | if (next < args.Length && !IsKey(args[next])) 16 | { 17 | val = args[next]; 18 | 19 | return true; 20 | } 21 | } 22 | } 23 | 24 | val = null; 25 | 26 | return false; 27 | } 28 | 29 | private static bool IsKey(string param) 30 | { 31 | return !string.IsNullOrEmpty(param) && param.StartsWith(KeyStart); 32 | } 33 | } 34 | } -------------------------------------------------------------------------------- /Editor/BatchMode/CommandLineParser.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: e1c418349a694d048017439e62f53e8e 3 | timeCreated: 1623335794 -------------------------------------------------------------------------------- /Editor/CliTools.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: edda783bc5af43b096259d8a543816b2 3 | folderAsset: yes 4 | DefaultImporter: 5 | externalObjects: {} 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Editor/CliTools/CustomEditors.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: bd8a444bf8d84dd3baa5f3e46e0c32fc 3 | timeCreated: 1589525119 -------------------------------------------------------------------------------- /Editor/CliTools/CustomEditors/CliToolEditorPresenter.cs: -------------------------------------------------------------------------------- 1 | using UnityEditor; 2 | using UnityEngine; 3 | 4 | namespace UniTools.Build 5 | { 6 | public sealed class CliToolEditorPresenter 7 | { 8 | private readonly BaseCliTool m_model = default; 9 | private readonly string m_name = default; 10 | private readonly string m_version = string.Empty; 11 | private readonly string m_helpLink = string.Empty; 12 | 13 | public CliToolEditorPresenter(BaseCliTool model) 14 | { 15 | m_model = model; 16 | m_name = model.GetType().Name; 17 | if (model is ICliToolFriendlyName name) 18 | { 19 | m_name = name.Name; 20 | } 21 | 22 | 23 | if (model.IsInstalled) 24 | { 25 | if (model is ICliToolVersion version) 26 | { 27 | m_version = version.Version; 28 | } 29 | } 30 | 31 | if (model is ICliToolHelpLink help) 32 | { 33 | m_helpLink = help.Link; 34 | } 35 | } 36 | 37 | private bool m_foldout = false; 38 | private const int MinHeight = 25; 39 | 40 | public void Draw() 41 | { 42 | if (!m_model.IsInstalled) 43 | { 44 | Color c = GUI.color; 45 | bool help = false; 46 | EditorGUILayout.BeginHorizontal("box"); 47 | { 48 | GUI.color = Color.red; 49 | EditorGUILayout.LabelField($"{m_name} is not found!", GUILayout.MinHeight(MinHeight)); 50 | GUI.color = c; 51 | 52 | if (!string.IsNullOrEmpty(m_helpLink)) 53 | { 54 | help = GUILayout.Button("Help", GUILayout.Width(100)); 55 | } 56 | } 57 | EditorGUILayout.EndHorizontal(); 58 | 59 | if (help) 60 | { 61 | Application.OpenURL(m_helpLink); 62 | } 63 | 64 | return; 65 | } 66 | 67 | if (m_foldout) 68 | { 69 | EditorGUILayout.BeginVertical("box"); 70 | { 71 | m_foldout = EditorGUILayout.Foldout(m_foldout, m_name); 72 | EditorGUILayout.LabelField($"{nameof(BaseCliTool.Path)}: {m_model.Path}", GUILayout.MinHeight(MinHeight)); 73 | 74 | if (!string.IsNullOrEmpty(m_version)) 75 | { 76 | EditorGUILayout.LabelField($"{nameof(ICliToolVersion.Version)}: {m_version}", GUILayout.MinHeight(MinHeight)); 77 | } 78 | } 79 | EditorGUILayout.EndVertical(); 80 | } 81 | else 82 | { 83 | EditorGUILayout.BeginHorizontal("box"); 84 | { 85 | m_foldout = EditorGUILayout.Foldout(m_foldout, m_name); 86 | } 87 | EditorGUILayout.EndHorizontal(); 88 | } 89 | } 90 | } 91 | } -------------------------------------------------------------------------------- /Editor/CliTools/CustomEditors/CliToolEditorPresenter.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 397e9b61afdf4350b1819a4d867f6308 3 | timeCreated: 1589525554 -------------------------------------------------------------------------------- /Editor/CliTools/CustomEditors/CliToolsProjectSettingsProvider.cs: -------------------------------------------------------------------------------- 1 | using System.Collections.Generic; 2 | using UnityEditor; 3 | using UnityEngine; 4 | using UnityEngine.UIElements; 5 | 6 | namespace UniTools.Build 7 | { 8 | public sealed class CliToolsProjectSettingsProvider : SettingsProvider 9 | { 10 | [SettingsProvider] 11 | public static SettingsProvider Register() => 12 | new CliToolsProjectSettingsProvider($"Project/{nameof(UniTools)}/CLI"); 13 | 14 | private readonly List m_presenters = new List(); 15 | 16 | private CliToolsProjectSettingsProvider(string path) 17 | : base(path, SettingsScope.Project) 18 | { 19 | } 20 | 21 | public override void OnActivate(string searchContext, VisualElement rootElement) 22 | { 23 | Show(); 24 | } 25 | 26 | public override void OnGUI(string searchContext) 27 | { 28 | foreach (CliToolEditorPresenter presenter in m_presenters) 29 | { 30 | presenter.Draw(); 31 | EditorGUILayout.Space(1); 32 | } 33 | 34 | EditorGUILayout.HelpBox("If the CLI tool is installed but not visible, try to: \n-recompile the code base or restart Unity Editor\n-check the PATH in the \"Tools/CLI/UnityEnvironment\".", MessageType.Info); 35 | #if UNITY_2021_1_OR_NEWER 36 | if (EditorGUILayout.LinkButton("How to change PATH in UnityEnvironment?")) 37 | { 38 | Application.OpenURL("https://github.com/UniToolsTeam/unitools-cli#unity-enviroment"); 39 | } 40 | #endif 41 | } 42 | 43 | public override void OnDeactivate() 44 | { 45 | m_presenters.Clear(); 46 | base.OnDeactivate(); 47 | } 48 | 49 | private void Show() 50 | { 51 | IEnumerable tools = Cli.All; 52 | m_presenters.Clear(); 53 | foreach (BaseCliTool tool in tools) 54 | { 55 | m_presenters.Add(new CliToolEditorPresenter(tool)); 56 | } 57 | } 58 | } 59 | } -------------------------------------------------------------------------------- /Editor/CliTools/CustomEditors/CliToolsProjectSettingsProvider.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: c0b59e3bb7fa4ddc85d4a79f301d9496 3 | timeCreated: 1611756497 -------------------------------------------------------------------------------- /Editor/CliTools/Runtime.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 60dd6e8e50ca43ee8dfa7ea0d1b673bf 3 | timeCreated: 1589522919 -------------------------------------------------------------------------------- /Editor/CliTools/Runtime/Base.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: f4f0afc2007949489d1f1729693e032f 3 | timeCreated: 1589523764 -------------------------------------------------------------------------------- /Editor/CliTools/Runtime/Base/Attributes.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 819bdfd240d14a629b15d6bee32a70ac 3 | timeCreated: 1604840620 -------------------------------------------------------------------------------- /Editor/CliTools/Runtime/Base/Attributes/BaseCliToolAttribute.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace UniTools.Build 4 | { 5 | [AttributeUsage(AttributeTargets.Assembly, AllowMultiple = true)] 6 | public abstract class BaseCliToolAttribute : Attribute 7 | { 8 | public readonly string Executable = default; 9 | 10 | protected BaseCliToolAttribute(string executable) 11 | { 12 | Executable = executable; 13 | } 14 | 15 | public override string ToString() 16 | { 17 | return $"{nameof(Executable)}={Executable}"; 18 | } 19 | 20 | public abstract BaseCliTool Create(); 21 | } 22 | } -------------------------------------------------------------------------------- /Editor/CliTools/Runtime/Base/Attributes/BaseCliToolAttribute.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: b0e52ed644da4127a6eab72c0257ace3 3 | timeCreated: 1604841314 -------------------------------------------------------------------------------- /Editor/CliTools/Runtime/Base/Attributes/ReflectionHelper.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | 5 | namespace UniTools.Build 6 | { 7 | public static class ReflectionHelper 8 | { 9 | public static IEnumerable Find() where TAttribute : Attribute 10 | { 11 | return AppDomain 12 | .CurrentDomain 13 | .GetAssemblies() 14 | .SelectMany(x => x.GetCustomAttributes(typeof(TAttribute), true)).Cast() 15 | .ToList(); 16 | } 17 | } 18 | } -------------------------------------------------------------------------------- /Editor/CliTools/Runtime/Base/Attributes/ReflectionHelper.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: f22e218b670d47459d50182fd816633a 3 | timeCreated: 1604842421 -------------------------------------------------------------------------------- /Editor/CliTools/Runtime/Base/Tools.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 778695bd95504ffa9951aa3184e2b862 3 | timeCreated: 1589540525 -------------------------------------------------------------------------------- /Editor/CliTools/Runtime/Base/Tools/BaseCliTool.cs: -------------------------------------------------------------------------------- 1 | namespace UniTools.Build 2 | { 3 | public abstract class BaseCliTool : 4 | ICliToolPath 5 | , ICliToolInstalled 6 | { 7 | public bool IsInstalled 8 | { 9 | get 10 | { 11 | try 12 | { 13 | return System.IO.Path.IsPathRooted(Path); 14 | } 15 | catch 16 | { 17 | return false; 18 | } 19 | } 20 | } 21 | 22 | public abstract string Path { get; } 23 | public abstract ToolResult Execute(string arguments = null, string workingDirectory = null); 24 | } 25 | } -------------------------------------------------------------------------------- /Editor/CliTools/Runtime/Base/Tools/BaseCliTool.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 97a64402388c4466ba7e1a0faac94193 3 | timeCreated: 1591643109 -------------------------------------------------------------------------------- /Editor/CliTools/Runtime/Base/Tools/ICliToolFriendlyName.cs: -------------------------------------------------------------------------------- 1 | namespace UniTools.Build 2 | { 3 | public interface ICliToolFriendlyName 4 | { 5 | string Name { get; } 6 | } 7 | } -------------------------------------------------------------------------------- /Editor/CliTools/Runtime/Base/Tools/ICliToolFriendlyName.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 9b45a5229d7a44e78fe2d133cee48863 3 | timeCreated: 1589528883 -------------------------------------------------------------------------------- /Editor/CliTools/Runtime/Base/Tools/ICliToolHelpLink.cs: -------------------------------------------------------------------------------- 1 | namespace UniTools.Build 2 | { 3 | public interface ICliToolHelpLink 4 | { 5 | string Link { get; } 6 | } 7 | } -------------------------------------------------------------------------------- /Editor/CliTools/Runtime/Base/Tools/ICliToolHelpLink.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: ce83b2e6d2464b2f9ad7bb63a0a49d49 3 | timeCreated: 1611755534 -------------------------------------------------------------------------------- /Editor/CliTools/Runtime/Base/Tools/ICliToolInstalled.cs: -------------------------------------------------------------------------------- 1 | namespace UniTools.Build 2 | { 3 | public interface ICliToolInstalled 4 | { 5 | bool IsInstalled { get; } 6 | } 7 | } -------------------------------------------------------------------------------- /Editor/CliTools/Runtime/Base/Tools/ICliToolInstalled.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: d17d719b30b3442a89169f17969377d2 3 | timeCreated: 1591642942 -------------------------------------------------------------------------------- /Editor/CliTools/Runtime/Base/Tools/ICliToolPath.cs: -------------------------------------------------------------------------------- 1 | namespace UniTools.Build 2 | { 3 | public interface ICliToolPath 4 | { 5 | string Path { get; } 6 | } 7 | } -------------------------------------------------------------------------------- /Editor/CliTools/Runtime/Base/Tools/ICliToolPath.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: ab5d933e7f7e4c6aa29278a9ef3bcb7e 3 | timeCreated: 1589522946 -------------------------------------------------------------------------------- /Editor/CliTools/Runtime/Base/Tools/ICliToolVersion.cs: -------------------------------------------------------------------------------- 1 | namespace UniTools.Build 2 | { 3 | public interface ICliToolVersion 4 | { 5 | string Version { get; } 6 | } 7 | } -------------------------------------------------------------------------------- /Editor/CliTools/Runtime/Base/Tools/ICliToolVersion.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 8e087b4cab09413c8095cea96b7377e0 3 | timeCreated: 1589545622 -------------------------------------------------------------------------------- /Editor/CliTools/Runtime/Base/Tools/ToolResult.cs: -------------------------------------------------------------------------------- 1 | using System.Text; 2 | 3 | namespace UniTools.Build 4 | { 5 | public sealed class ToolResult 6 | { 7 | public readonly string Output; 8 | public readonly string Error; 9 | public readonly int ExitCode; 10 | 11 | public ToolResult(string output, string error, int exitCode) 12 | { 13 | Output = output; 14 | Error = error; 15 | ExitCode = exitCode; 16 | } 17 | 18 | public override string ToString() 19 | { 20 | StringBuilder builder = new StringBuilder(); 21 | builder.AppendLine($"{nameof(ExitCode)}={ExitCode}"); 22 | if (!string.IsNullOrEmpty(Error)) 23 | { 24 | builder.AppendLine($"{nameof(Error)}={Error}"); 25 | } 26 | 27 | builder.AppendLine($"{nameof(Output)}={Output}"); 28 | 29 | return builder.ToString(); 30 | } 31 | } 32 | } -------------------------------------------------------------------------------- /Editor/CliTools/Runtime/Base/Tools/ToolResult.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 7a5c62294a7a401eba38c5de3c10c301 3 | timeCreated: 1610020490 -------------------------------------------------------------------------------- /Editor/CliTools/Runtime/Cli.cs: -------------------------------------------------------------------------------- 1 | using System.Collections.Generic; 2 | using System.Linq; 3 | 4 | namespace UniTools.Build 5 | { 6 | public static class Cli 7 | { 8 | static Cli() 9 | { 10 | AllTools = new Dictionary(); 11 | Refresh(); 12 | } 13 | 14 | private static readonly Dictionary AllTools = default; 15 | 16 | public static IEnumerable All => AllTools.Values; 17 | 18 | public static BaseCliTool Tool(string executable) 19 | { 20 | return AllTools[executable]; 21 | } 22 | 23 | public static TTool Tool() where TTool : BaseCliTool 24 | { 25 | return AllTools.Values.OfType().FirstOrDefault(); 26 | } 27 | 28 | public static void Refresh() 29 | { 30 | AllTools.Clear(); 31 | 32 | AllTools.Add(nameof(CommandLine), CommandLine.Default); 33 | AllTools.Add(nameof(PathResolver), PathResolver.Default); 34 | 35 | List declared = ReflectionHelper.Find().ToList(); 36 | foreach (BaseCliToolAttribute attribute in declared) 37 | { 38 | AllTools.Add(attribute.Executable, attribute.Create()); 39 | } 40 | } 41 | } 42 | } -------------------------------------------------------------------------------- /Editor/CliTools/Runtime/Cli.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 1a92cb581fbe4742a104a366205e7024 3 | timeCreated: 1589524247 -------------------------------------------------------------------------------- /Editor/CliTools/Runtime/CommandLine.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: c6918dbf9d1143538db52d67780a0173 3 | timeCreated: 1589528984 -------------------------------------------------------------------------------- /Editor/CliTools/Runtime/CommandLine/CommandLine.cs: -------------------------------------------------------------------------------- 1 | namespace UniTools.Build 2 | { 3 | public abstract class CommandLine : BaseCliTool 4 | { 5 | public static readonly CommandLine Default = 6 | #if UNITY_EDITOR_OSX 7 | new OsxTerminal(); 8 | 9 | #elif UNITY_EDITOR_WIN 10 | new WindowsCmd(); 11 | #else 12 | //TODO Create Unsupported tool! 13 | default; 14 | #endif 15 | } 16 | } -------------------------------------------------------------------------------- /Editor/CliTools/Runtime/CommandLine/CommandLine.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 8eb504c3629f4661a96f8a01fc0bae3b 3 | timeCreated: 1589529174 -------------------------------------------------------------------------------- /Editor/CliTools/Runtime/CommandLine/OsxTerminal.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 30755ec01f7840f99ace488a80361f6e 3 | timeCreated: 1589523788 -------------------------------------------------------------------------------- /Editor/CliTools/Runtime/CommandLine/OsxTerminal/OsxTerminal.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Diagnostics; 3 | using System.Text; 4 | using Debug = UnityEngine.Debug; 5 | 6 | namespace UniTools.Build 7 | { 8 | public sealed class OsxTerminal : CommandLine 9 | , ICliToolVersion 10 | , ICliToolFriendlyName 11 | { 12 | private string m_version = string.Empty; 13 | 14 | public OsxTerminal() 15 | { 16 | UnityEnvironmentVariableModel shell = UnityEnvironment.Get("SHELL"); 17 | if (shell != null) 18 | { 19 | Path = shell.Value; 20 | } 21 | else 22 | { 23 | Debug.LogWarning($"{nameof(OsxTerminal)}: failed to find SHELL path!"); 24 | } 25 | } 26 | 27 | public string Version 28 | { 29 | get 30 | { 31 | if (!IsInstalled) 32 | { 33 | throw new Exception($"{nameof(OsxTerminal)}: Failed to get version due to tool is not installed!"); 34 | } 35 | 36 | if (string.IsNullOrEmpty(m_version)) 37 | { 38 | m_version = Execute("--version").Output; 39 | } 40 | 41 | return m_version; 42 | } 43 | } 44 | 45 | public override string Path { get; } 46 | 47 | public string Name => nameof(OsxTerminal); 48 | 49 | public override ToolResult Execute(string arguments = null, string workingDirectory = null) 50 | { 51 | if (string.IsNullOrEmpty(arguments)) 52 | { 53 | arguments = string.Empty; 54 | } 55 | 56 | if (string.IsNullOrEmpty(workingDirectory)) 57 | { 58 | workingDirectory = string.Empty; 59 | } 60 | 61 | string escapedArgs = arguments.Replace("\"", "\\\""); 62 | Process process = new Process 63 | { 64 | StartInfo = new ProcessStartInfo 65 | { 66 | WorkingDirectory = workingDirectory, 67 | FileName = Path, 68 | Arguments = $"-c \"{escapedArgs}\"", 69 | RedirectStandardOutput = true, 70 | UseShellExecute = false, 71 | CreateNoWindow = true, 72 | RedirectStandardError = true, 73 | StandardErrorEncoding = Encoding.UTF8, 74 | StandardOutputEncoding = Encoding.UTF8 75 | } 76 | }; 77 | 78 | process.Start(); 79 | string output = process.StandardOutput.ReadToEnd(); 80 | string error = process.StandardError.ReadToEnd(); 81 | 82 | process.WaitForExit(); 83 | int exitCode = process.ExitCode; 84 | 85 | return new ToolResult( 86 | output, 87 | error, 88 | exitCode); 89 | } 90 | } 91 | } -------------------------------------------------------------------------------- /Editor/CliTools/Runtime/CommandLine/OsxTerminal/OsxTerminal.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 007bce97b3934667b6a68497a03874c2 3 | timeCreated: 1589523822 -------------------------------------------------------------------------------- /Editor/CliTools/Runtime/CommandLine/WindowsCmd.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 2e548ccc740a41149808441311f91454 3 | timeCreated: 1589549807 -------------------------------------------------------------------------------- /Editor/CliTools/Runtime/CommandLine/WindowsCmd/WindowsCmd.cs: -------------------------------------------------------------------------------- 1 | using System.Diagnostics; 2 | 3 | namespace UniTools.Build 4 | { 5 | public sealed class WindowsCmd : CommandLine 6 | , ICliToolVersion 7 | , ICliToolFriendlyName 8 | { 9 | private string m_version = string.Empty; 10 | private string m_path = string.Empty; 11 | 12 | public WindowsCmd() 13 | { 14 | UnityEnvironmentVariableModel comSpec = UnityEnvironment.Get("ComSpec"); 15 | if (comSpec != null) 16 | { 17 | m_path = comSpec.Value; 18 | } 19 | else 20 | { 21 | UnityEngine.Debug.LogWarning($"{nameof(WindowsCmd)}: failed to find ComSpec path!"); 22 | } 23 | } 24 | 25 | public string Version 26 | { 27 | get 28 | { 29 | if (string.IsNullOrEmpty(m_version)) 30 | { 31 | m_version = Execute("ver").Output; 32 | } 33 | 34 | return m_version; 35 | } 36 | } 37 | 38 | public override string Path => m_path; 39 | 40 | public string Name => nameof(WindowsCmd); 41 | 42 | public override ToolResult Execute(string arguments = null, string workingDirectory = null) 43 | { 44 | if (string.IsNullOrEmpty(arguments)) 45 | { 46 | arguments = string.Empty; 47 | } 48 | 49 | if (string.IsNullOrEmpty(workingDirectory)) 50 | { 51 | workingDirectory = string.Empty; 52 | } 53 | 54 | string escapedArgs = arguments.Replace("\"", "\\\""); 55 | Process process = new Process 56 | { 57 | StartInfo = new ProcessStartInfo 58 | { 59 | WorkingDirectory = workingDirectory, 60 | FileName = Path, 61 | Arguments = $"/c \"{escapedArgs}\"", 62 | RedirectStandardOutput = true, 63 | UseShellExecute = false, 64 | CreateNoWindow = true, 65 | RedirectStandardError = true, 66 | StandardErrorEncoding = System.Text.Encoding.UTF8, 67 | StandardOutputEncoding = System.Text.Encoding.UTF8 68 | } 69 | }; 70 | process.Start(); 71 | string output = process.StandardOutput.ReadToEnd(); 72 | string error = process.StandardError.ReadToEnd(); 73 | 74 | process.WaitForExit(); 75 | int exitCode = process.ExitCode; 76 | 77 | return new ToolResult( 78 | output, 79 | error, 80 | exitCode); 81 | } 82 | } 83 | } -------------------------------------------------------------------------------- /Editor/CliTools/Runtime/CommandLine/WindowsCmd/WindowsCmd.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 9c5da0240b654b799580868912b2d24c 3 | timeCreated: 1589549823 -------------------------------------------------------------------------------- /Editor/CliTools/Runtime/GenericTool.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: e4bc9d22b874413ba2032bf285acf03a 3 | timeCreated: 1609251562 -------------------------------------------------------------------------------- /Editor/CliTools/Runtime/GenericTool/CliToolAttribute.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace UniTools.Build 4 | { 5 | public sealed class CliToolAttribute : BaseCliToolAttribute 6 | { 7 | public CliToolAttribute(string executable) : base(executable) 8 | { 9 | } 10 | 11 | public override BaseCliTool Create() 12 | { 13 | string path = PathResolver.Default.Execute(Executable).Output.Replace(Environment.NewLine, string.Empty); 14 | 15 | return new GenericTool(Executable, path, CommandLine.Default); 16 | } 17 | } 18 | } -------------------------------------------------------------------------------- /Editor/CliTools/Runtime/GenericTool/CliToolAttribute.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: a13af8527b1b4d30ba8ed782af05050d 3 | timeCreated: 1609262912 -------------------------------------------------------------------------------- /Editor/CliTools/Runtime/GenericTool/CliToolPathAttribute.cs: -------------------------------------------------------------------------------- 1 | using System.IO; 2 | 3 | namespace UniTools.Build 4 | { 5 | public sealed class CliToolPathAttribute : BaseCliToolAttribute 6 | { 7 | private readonly string m_path = default; 8 | public CliToolPathAttribute(string executable, string path) : base(executable) 9 | { 10 | m_path = path; 11 | } 12 | 13 | public override BaseCliTool Create() 14 | { 15 | return new GenericTool(Executable, m_path, CommandLine.Default); 16 | } 17 | } 18 | } -------------------------------------------------------------------------------- /Editor/CliTools/Runtime/GenericTool/CliToolPathAttribute.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: e2dd65a767e44188b7842f77cccc39cd 3 | timeCreated: 1653562011 -------------------------------------------------------------------------------- /Editor/CliTools/Runtime/GenericTool/GenericTool.cs: -------------------------------------------------------------------------------- 1 | namespace UniTools.Build 2 | { 3 | public sealed class GenericTool : BaseCliTool 4 | , ICliToolFriendlyName 5 | { 6 | private readonly CommandLine m_commandLine = default; 7 | 8 | // public GenericTool(string executable, CommandLine commandLine) 9 | public GenericTool(string executable, string path, CommandLine commandLine) 10 | { 11 | Name = executable; 12 | Path = path; 13 | m_commandLine = commandLine; 14 | } 15 | 16 | public string Name { get; private set; } 17 | 18 | public override string Path { get; } 19 | 20 | public override ToolResult Execute(string arguments = null, string workingDirectory = null) 21 | { 22 | if (string.IsNullOrEmpty(arguments)) 23 | { 24 | arguments = string.Empty; 25 | } 26 | 27 | if (string.IsNullOrEmpty(workingDirectory)) 28 | { 29 | workingDirectory = string.Empty; 30 | } 31 | 32 | return m_commandLine.Execute($"{Path} {arguments}", workingDirectory); 33 | } 34 | 35 | public override string ToString() 36 | { 37 | return $"{nameof(GenericTool)}: {Path}"; 38 | } 39 | } 40 | } -------------------------------------------------------------------------------- /Editor/CliTools/Runtime/GenericTool/GenericTool.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 1ba7dbca914e47938b76110400afb0c8 3 | timeCreated: 1604842752 -------------------------------------------------------------------------------- /Editor/CliTools/Runtime/PathResolver.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 21eac84793eb404da5a30a96f7354ab6 3 | timeCreated: 1589530737 -------------------------------------------------------------------------------- /Editor/CliTools/Runtime/PathResolver/OsxTerminal.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 15b9ed679f55428d93bf24dfbe99675f 3 | timeCreated: 1589530759 -------------------------------------------------------------------------------- /Editor/CliTools/Runtime/PathResolver/OsxTerminal/OsxWhich.cs: -------------------------------------------------------------------------------- 1 | namespace UniTools.Build 2 | { 3 | public sealed class OsxWhich : PathResolver 4 | , ICliToolFriendlyName 5 | { 6 | public string Name => nameof(OsxWhich); 7 | public override string Path => "/usr/bin/which"; 8 | 9 | public OsxWhich(CommandLine commandLine) : base(commandLine) 10 | { 11 | } 12 | 13 | public override ToolResult Execute(string arguments = null, string workingDirectory = null) 14 | { 15 | if (string.IsNullOrEmpty(arguments)) 16 | { 17 | arguments = string.Empty; 18 | } 19 | 20 | if (string.IsNullOrEmpty(workingDirectory)) 21 | { 22 | workingDirectory = string.Empty; 23 | } 24 | 25 | return CommandLine.Execute($"{Path} {arguments}", workingDirectory); 26 | } 27 | } 28 | } -------------------------------------------------------------------------------- /Editor/CliTools/Runtime/PathResolver/OsxTerminal/OsxWhich.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 5de29982f8624399a9a9b5d07bcd4ac1 3 | timeCreated: 1589524781 -------------------------------------------------------------------------------- /Editor/CliTools/Runtime/PathResolver/PathResolver.cs: -------------------------------------------------------------------------------- 1 | namespace UniTools.Build 2 | { 3 | public abstract class PathResolver : BaseCliTool 4 | { 5 | public static readonly PathResolver Default = 6 | #if UNITY_EDITOR_OSX 7 | new OsxWhich(CommandLine.Default); 8 | 9 | #elif UNITY_EDITOR_WIN 10 | new WindowsWhere(CommandLine.Default); 11 | #else 12 | //TODO Create Unsupported tool! 13 | default; 14 | #endif 15 | 16 | protected readonly CommandLine CommandLine = default; 17 | 18 | protected PathResolver(CommandLine commandLine) 19 | { 20 | CommandLine = commandLine; 21 | } 22 | } 23 | } -------------------------------------------------------------------------------- /Editor/CliTools/Runtime/PathResolver/PathResolver.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: ad6e41ced4624385ae5ebb940c71866a 3 | timeCreated: 1589530726 -------------------------------------------------------------------------------- /Editor/CliTools/Runtime/PathResolver/WindowsCmd.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 5f0ef43e27f94ecd9ccfbb0ada728ab3 3 | timeCreated: 1589551799 -------------------------------------------------------------------------------- /Editor/CliTools/Runtime/PathResolver/WindowsCmd/WindowsWhere.cs: -------------------------------------------------------------------------------- 1 | namespace UniTools.Build 2 | { 3 | public sealed class WindowsWhere : PathResolver 4 | , ICliToolFriendlyName 5 | { 6 | public string Name => nameof(WindowsWhere); 7 | public override string Path => @"C:\Windows\System32\where.exe"; 8 | 9 | public override ToolResult Execute(string arguments = null, string workingDirectory = null) 10 | { 11 | if (string.IsNullOrEmpty(arguments)) 12 | { 13 | arguments = string.Empty; 14 | } 15 | 16 | if (string.IsNullOrEmpty(workingDirectory)) 17 | { 18 | workingDirectory = string.Empty; 19 | } 20 | 21 | return CommandLine.Execute($"{Path} {arguments}", workingDirectory); 22 | } 23 | 24 | public WindowsWhere(CommandLine commandLine) : base(commandLine) 25 | { 26 | } 27 | } 28 | } -------------------------------------------------------------------------------- /Editor/CliTools/Runtime/PathResolver/WindowsCmd/WindowsWhere.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: c87cce7178b749c08c7ccf48e712aff8 3 | timeCreated: 1589551813 -------------------------------------------------------------------------------- /Editor/CliTools/Runtime/Tar.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: c307888616394d8fb6c5a45de2a123b5 3 | timeCreated: 1642146151 -------------------------------------------------------------------------------- /Editor/CliTools/Runtime/Tar/Tar.cs: -------------------------------------------------------------------------------- 1 | using UniTools.Build; 2 | 3 | [assembly: Tar] 4 | 5 | namespace UniTools.Build 6 | { 7 | public sealed class Tar : BaseCliTool 8 | , ICliToolVersion 9 | , ICliToolFriendlyName 10 | { 11 | private readonly CommandLine m_commandLine = default; 12 | private string m_version = string.Empty; 13 | 14 | public override string Path { get; } = default; 15 | 16 | public string Version 17 | { 18 | get 19 | { 20 | if (string.IsNullOrEmpty(m_version)) 21 | { 22 | m_version = Execute("--version").Output; 23 | } 24 | 25 | return m_version; 26 | } 27 | } 28 | 29 | public string Name => $"{nameof(Tar)} (archive tool)"; 30 | 31 | public Tar(string path, CommandLine commandLine) 32 | { 33 | Path = path; 34 | m_commandLine = commandLine; 35 | } 36 | 37 | public override ToolResult Execute(string arguments = null, string workingDirectory = null) 38 | { 39 | if (!IsInstalled) 40 | { 41 | throw new ToolNotInstalledException(); 42 | } 43 | 44 | if (string.IsNullOrEmpty(arguments)) 45 | { 46 | arguments = string.Empty; 47 | } 48 | 49 | if (string.IsNullOrEmpty(workingDirectory)) 50 | { 51 | workingDirectory = string.Empty; 52 | } 53 | 54 | return m_commandLine.Execute($"{Path} {arguments}", workingDirectory); 55 | } 56 | } 57 | } -------------------------------------------------------------------------------- /Editor/CliTools/Runtime/Tar/Tar.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: dc3d57fefe234348bc343403ae2f9440 3 | timeCreated: 1642146423 -------------------------------------------------------------------------------- /Editor/CliTools/Runtime/Tar/TarAttribute.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace UniTools.Build 4 | { 5 | public sealed class TarAttribute : BaseCliToolAttribute 6 | { 7 | private const string ToolName = "tar"; 8 | 9 | public TarAttribute() : base(ToolName) 10 | { 11 | } 12 | 13 | public override BaseCliTool Create() 14 | { 15 | return new Tar( 16 | PathResolver.Default.Execute(ToolName).Output.Split(Environment.NewLine.ToCharArray())?[0], 17 | CommandLine.Default); 18 | } 19 | } 20 | } -------------------------------------------------------------------------------- /Editor/CliTools/Runtime/Tar/TarAttribute.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: ce3887aa3d3946eeadc9948282fb2812 3 | timeCreated: 1642146238 -------------------------------------------------------------------------------- /Editor/CliTools/Runtime/ToolNotInstalledException.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace UniTools.Build 4 | { 5 | public sealed class ToolNotInstalledException : Exception 6 | { 7 | 8 | } 9 | } -------------------------------------------------------------------------------- /Editor/CliTools/Runtime/ToolNotInstalledException.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 4e1862688cdc460db2aa23a6aa94e73e 3 | timeCreated: 1624437148 -------------------------------------------------------------------------------- /Editor/CliTools/Runtime/XCodeBuild.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 27d09ec2828f4efa96e2448d6b1905ba 3 | timeCreated: 1609854619 -------------------------------------------------------------------------------- /Editor/CliTools/Runtime/XCodeBuild/XCodeBuild.cs: -------------------------------------------------------------------------------- 1 | using UnityEngine; 2 | 3 | #if UNITY_IOS 4 | using UniTools.Build; 5 | [assembly: XCodeBuild] 6 | #endif 7 | 8 | namespace UniTools.Build 9 | { 10 | public sealed class XCodeBuild : BaseCliTool 11 | , ICliToolVersion 12 | , ICliToolFriendlyName 13 | { 14 | public const string ToolName = "xcodebuild"; 15 | private readonly CommandLine m_commandLine = default; 16 | private string m_version = string.Empty; 17 | 18 | public XCodeBuild(string path, CommandLine commandLine) 19 | { 20 | Path = path; 21 | m_commandLine = commandLine; 22 | } 23 | 24 | public string Name => nameof(XCodeBuild); 25 | 26 | public string Version 27 | { 28 | get 29 | { 30 | if (string.IsNullOrEmpty(m_version)) 31 | { 32 | ToolResult r = Execute("-version"); 33 | if (r.ExitCode == 0) 34 | { 35 | m_version = r.Output.Replace("\n", " "); 36 | } 37 | else 38 | { 39 | Debug.LogError($"{nameof(XCodeBuild)}: ExitCode {r.ExitCode}. Failed to get version due to {r.Error}"); 40 | } 41 | } 42 | 43 | return m_version; 44 | } 45 | } 46 | 47 | public override string Path { get; } = default; 48 | 49 | public override ToolResult Execute(string arguments = null, string workingDirectory = null) 50 | { 51 | if (string.IsNullOrEmpty(arguments)) 52 | { 53 | arguments = string.Empty; 54 | } 55 | 56 | if (string.IsNullOrEmpty(workingDirectory)) 57 | { 58 | workingDirectory = string.Empty; 59 | } 60 | 61 | return m_commandLine.Execute($"{Path} {arguments}", workingDirectory); 62 | } 63 | 64 | public override string ToString() 65 | { 66 | return $"{nameof(XCodeBuild)}: {Path}, {Version}"; 67 | } 68 | } 69 | } -------------------------------------------------------------------------------- /Editor/CliTools/Runtime/XCodeBuild/XCodeBuild.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 3a4bc50d4b824139b8df45a0a181515a 3 | timeCreated: 1609854641 -------------------------------------------------------------------------------- /Editor/CliTools/Runtime/XCodeBuild/XCodeBuildAttribute.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace UniTools.Build 4 | { 5 | public sealed class XCodeBuildAttribute : BaseCliToolAttribute 6 | { 7 | public XCodeBuildAttribute() : base(XCodeBuild.ToolName) 8 | { 9 | } 10 | 11 | public override BaseCliTool Create() 12 | { 13 | return new XCodeBuild( 14 | PathResolver.Default.Execute(XCodeBuild.ToolName).Output.Replace(Environment.NewLine, string.Empty), 15 | CommandLine.Default); 16 | } 17 | } 18 | } -------------------------------------------------------------------------------- /Editor/CliTools/Runtime/XCodeBuild/XCodeBuildAttribute.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: f58eac27e7fa46ff900482651e3fe863 3 | timeCreated: 1609854801 -------------------------------------------------------------------------------- /Editor/CliTools/Runtime/Zip.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 6eee88960fb14255847886709aab1e20 3 | timeCreated: 1642603368 -------------------------------------------------------------------------------- /Editor/CliTools/Runtime/Zip/Zip.cs: -------------------------------------------------------------------------------- 1 | using UniTools.Build; 2 | 3 | [assembly: Zip] 4 | 5 | namespace UniTools.Build 6 | { 7 | public sealed class Zip : BaseCliTool 8 | , ICliToolFriendlyName 9 | { 10 | private readonly CommandLine m_commandLine = default; 11 | 12 | public override string Path { get; } = default; 13 | 14 | public string Name => $"{nameof(Zip)} (archive tool)"; 15 | 16 | public Zip(string path, CommandLine commandLine) 17 | { 18 | Path = path; 19 | m_commandLine = commandLine; 20 | } 21 | 22 | public override ToolResult Execute(string arguments = null, string workingDirectory = null) 23 | { 24 | if (!IsInstalled) 25 | { 26 | throw new ToolNotInstalledException(); 27 | } 28 | 29 | if (string.IsNullOrEmpty(arguments)) 30 | { 31 | arguments = string.Empty; 32 | } 33 | 34 | if (string.IsNullOrEmpty(workingDirectory)) 35 | { 36 | workingDirectory = string.Empty; 37 | } 38 | 39 | return m_commandLine.Execute($"{Path} {arguments}", workingDirectory); 40 | } 41 | } 42 | } -------------------------------------------------------------------------------- /Editor/CliTools/Runtime/Zip/Zip.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: b5d2e58b133e457a8678d99ed66a8fd0 3 | timeCreated: 1642603377 -------------------------------------------------------------------------------- /Editor/CliTools/Runtime/Zip/ZipAttribute.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace UniTools.Build 4 | { 5 | public sealed class ZipAttribute : BaseCliToolAttribute 6 | { 7 | private const string ToolName = "zip"; 8 | 9 | public ZipAttribute() : base(ToolName) 10 | { 11 | } 12 | 13 | public override BaseCliTool Create() 14 | { 15 | return new Zip( 16 | PathResolver.Default.Execute(ToolName).Output.Split(Environment.NewLine.ToCharArray())?[0], 17 | CommandLine.Default); 18 | } 19 | } 20 | } -------------------------------------------------------------------------------- /Editor/CliTools/Runtime/Zip/ZipAttribute.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 63a0e150abf54a29a885f0b7755b9077 3 | timeCreated: 1642603392 -------------------------------------------------------------------------------- /Editor/Core.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 9df76e87a4614e0087d07c67758f528f 3 | timeCreated: 1642492121 -------------------------------------------------------------------------------- /Editor/Core/Parameters.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 2385bea428044e979dd941f05c1176fd 3 | timeCreated: 1674553344 -------------------------------------------------------------------------------- /Editor/Core/Parameters/BuildParameterPresenter.cs: -------------------------------------------------------------------------------- 1 | namespace UniTools.Build 2 | { 3 | public abstract class BuildParameterPresenter 4 | { 5 | 6 | public abstract string CliKey { get; } 7 | 8 | public abstract void Draw(bool duplicated); 9 | } 10 | } -------------------------------------------------------------------------------- /Editor/Core/Parameters/BuildParameterPresenter.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: b8ca3619956845b3a3d7735a2b01d388 3 | timeCreated: 1678442940 -------------------------------------------------------------------------------- /Editor/Core/Parameters/Int.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 6aeb526ebe9c41438c17087b79b8529a 3 | timeCreated: 1678381779 -------------------------------------------------------------------------------- /Editor/Core/Parameters/Int/IntBuildParameter.cs: -------------------------------------------------------------------------------- 1 | using UnityEngine; 2 | 3 | namespace UniTools.Build 4 | { 5 | [CreateAssetMenu( 6 | fileName = nameof(StringBuildParameter), 7 | menuName = MenuPaths.Parameters + "Int" 8 | )] 9 | public sealed class IntBuildParameter : ScriptableBuildParameter 10 | { 11 | protected override bool TryParseFromCommandLine(string commandLine, out int v) 12 | { 13 | if (CommandLineParser.TryToParseValue(commandLine, CliKey, out object obj)) 14 | { 15 | if (int.TryParse(obj.ToString(), out v)) 16 | { 17 | return true; 18 | } 19 | } 20 | 21 | v = int.MinValue; 22 | 23 | return false; 24 | } 25 | } 26 | } -------------------------------------------------------------------------------- /Editor/Core/Parameters/Int/IntBuildParameter.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: adb7a217404943c3aa9791700a35b93e 3 | timeCreated: 1678381791 -------------------------------------------------------------------------------- /Editor/Core/Parameters/Int/IntBuildParameterEditor.cs: -------------------------------------------------------------------------------- 1 | using System.Linq; 2 | using UnityEditor; 3 | using UnityEngine; 4 | 5 | namespace UniTools.Build 6 | { 7 | [CustomEditor(typeof(IntBuildParameter))] 8 | public sealed class IntBuildParameterEditor : Editor 9 | { 10 | private IntBuildParameter m_target = default; 11 | private SerializedProperty m_value = default; 12 | private SerializedProperty m_options = default; 13 | 14 | private void OnEnable() 15 | { 16 | m_value = serializedObject.FindProperty(nameof(m_value)); 17 | m_options = serializedObject.FindProperty(nameof(m_options)); 18 | m_target = target as IntBuildParameter; 19 | } 20 | 21 | public override void OnInspectorGUI() 22 | { 23 | Draw(m_target, serializedObject, m_value, m_options); 24 | } 25 | 26 | /// 27 | /// This method is using to draw the same editor in different windows 28 | /// 29 | public static void Draw(IntBuildParameter target, SerializedObject serializedObject, SerializedProperty value, SerializedProperty options) 30 | { 31 | bool copyToClipboard = false; 32 | 33 | if (target.Options == null || target.Options.Count <= 0) 34 | { 35 | EditorGUILayout.PropertyField(value); 36 | } 37 | else 38 | { 39 | int index = target.Options.IndexOf(value.intValue); 40 | index = EditorGUILayout.Popup(index, target.Options.Select(o => o.ToString()).ToArray()); 41 | 42 | if (index >= 0 && index <= target.Options.Count) 43 | { 44 | value.intValue = target.Options[index]; 45 | } 46 | } 47 | 48 | EditorGUILayout.PropertyField(options); 49 | 50 | EditorGUILayout.BeginHorizontal(); 51 | { 52 | EditorGUILayout.LabelField($"CLI: {target.CliCommand}"); 53 | copyToClipboard = GUILayout.Button("Copy"); 54 | } 55 | EditorGUILayout.EndHorizontal(); 56 | 57 | serializedObject.ApplyModifiedProperties(); 58 | 59 | if (copyToClipboard) 60 | { 61 | EditorGUIUtility.systemCopyBuffer = $"{target.CliCommand}"; 62 | } 63 | } 64 | } 65 | } -------------------------------------------------------------------------------- /Editor/Core/Parameters/Int/IntBuildParameterEditor.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 6a502df001874324968157c10086b8b0 3 | timeCreated: 1678381985 -------------------------------------------------------------------------------- /Editor/Core/Parameters/Int/IntBuildParameterPresenter.cs: -------------------------------------------------------------------------------- 1 | using UnityEditor; 2 | using UnityEngine; 3 | 4 | namespace UniTools.Build 5 | { 6 | public sealed class IntBuildParameterPresenter : BuildParameterPresenter 7 | { 8 | private readonly IntBuildParameter m_target = default; 9 | private readonly SerializedObject m_serializedObject = default; 10 | private readonly SerializedProperty m_value = default; 11 | private readonly SerializedProperty m_options = default; 12 | private bool m_foldout = false; 13 | 14 | public IntBuildParameterPresenter(IntBuildParameter target) 15 | { 16 | m_target = target; 17 | m_serializedObject = new SerializedObject(m_target); 18 | m_value = m_serializedObject.FindProperty(nameof(m_value)); 19 | m_options = m_serializedObject.FindProperty(nameof(m_options)); 20 | } 21 | 22 | public override string CliKey => m_target.CliKey; 23 | 24 | public override void Draw(bool duplicated) 25 | { 26 | bool select = false; 27 | if (m_foldout) 28 | { 29 | EditorGUILayout.BeginVertical("box"); 30 | { 31 | EditorGUILayout.BeginHorizontal(); 32 | { 33 | m_foldout = EditorGUILayout.Foldout(m_foldout, m_target.name, Styles.H2_Foldout); 34 | select = GUILayout.Button("Select", GUILayout.Width(100)); 35 | } 36 | EditorGUILayout.EndHorizontal(); 37 | if (duplicated) 38 | { 39 | EditorGUILayout.HelpBox("The parameter name is duplicated! Logical errors can happen during the batch mode call!", MessageType.Warning); 40 | } 41 | 42 | IntBuildParameterEditor.Draw(m_target, m_serializedObject, m_value, m_options); 43 | } 44 | EditorGUILayout.EndVertical(); 45 | } 46 | else 47 | { 48 | EditorGUILayout.BeginHorizontal("box"); 49 | { 50 | Color color = GUI.color; 51 | 52 | if (duplicated) 53 | { 54 | GUI.color = Color.red; 55 | } 56 | 57 | m_foldout = EditorGUILayout.Foldout(m_foldout, m_target.name, Styles.H2_Foldout); 58 | select = GUILayout.Button("Select", GUILayout.Width(100)); 59 | 60 | GUI.color = color; 61 | } 62 | EditorGUILayout.EndHorizontal(); 63 | } 64 | 65 | if (select) 66 | { 67 | EditorGUIUtility.PingObject(m_target); 68 | } 69 | } 70 | } 71 | } -------------------------------------------------------------------------------- /Editor/Core/Parameters/Int/IntBuildParameterPresenter.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: d8e4b3bfa46c4d7687211654dcdb6b72 3 | timeCreated: 1678443513 -------------------------------------------------------------------------------- /Editor/Core/Parameters/ScriptableBuildParameter.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using UnityEngine; 4 | 5 | namespace UniTools.Build 6 | { 7 | public abstract class ScriptableBuildParameter : ScriptableObject 8 | { 9 | /// 10 | /// The name of the parameter that can be used inside a command line 11 | /// 12 | public string CliKey => $"--{name.Replace(" ", string.Empty).ToLower()}"; 13 | 14 | /// 15 | /// The command for the CLI with a current value 16 | /// 17 | public abstract string CliCommand { get; } 18 | } 19 | 20 | /// 21 | /// Any value that can used inside a build pipeline and can be overriden from the command line 22 | /// 23 | public abstract class ScriptableBuildParameter : ScriptableBuildParameter 24 | { 25 | [SerializeField] private TValue m_value = default; 26 | 27 | /// 28 | /// Is this collection if not empty the values can be selected as enum 29 | /// 30 | [SerializeField, Tooltip("Add values to this collection to create a popup")] private List m_options = default; 31 | 32 | public List Options => m_options; 33 | 34 | public TValue Value 35 | { 36 | get 37 | { 38 | if (Application.isBatchMode && TryParseFromCommandLine(Environment.CommandLine, out TValue v)) 39 | { 40 | return v; 41 | } 42 | 43 | return m_value; 44 | } 45 | } 46 | 47 | public override string CliCommand => $"{CliKey} {Value.ToString()}"; 48 | 49 | protected abstract bool TryParseFromCommandLine(string commandLine, out TValue v); 50 | } 51 | } -------------------------------------------------------------------------------- /Editor/Core/Parameters/ScriptableBuildParameter.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 9e34158a96bc4c9fbf9cbc513e506e51 3 | timeCreated: 1674553357 -------------------------------------------------------------------------------- /Editor/Core/Parameters/String.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 0ed1b08943b744afaa7a084278628b99 3 | timeCreated: 1678381752 -------------------------------------------------------------------------------- /Editor/Core/Parameters/String/StringBuildParameter.cs: -------------------------------------------------------------------------------- 1 | using UnityEngine; 2 | 3 | namespace UniTools.Build 4 | { 5 | [CreateAssetMenu( 6 | fileName = nameof(StringBuildParameter), 7 | menuName = MenuPaths.Parameters + "String" 8 | )] 9 | public sealed class StringBuildParameter : ScriptableBuildParameter 10 | { 11 | protected override bool TryParseFromCommandLine(string commandLine, out string v) 12 | { 13 | if (CommandLineParser.TryToParseValue(commandLine, CliKey, out object obj)) 14 | { 15 | v = obj.ToString(); 16 | 17 | return true; 18 | } 19 | 20 | v = string.Empty; 21 | 22 | return false; 23 | } 24 | } 25 | } -------------------------------------------------------------------------------- /Editor/Core/Parameters/String/StringBuildParameter.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: e10929fef8c447abb9c3335155a4ea0d 3 | timeCreated: 1678367513 -------------------------------------------------------------------------------- /Editor/Core/Parameters/String/StringBuildParameterEditor.cs: -------------------------------------------------------------------------------- 1 | using System.Linq; 2 | using UnityEditor; 3 | using UnityEngine; 4 | 5 | namespace UniTools.Build 6 | { 7 | [CustomEditor(typeof(StringBuildParameter))] 8 | public sealed class StringBuildParameterEditor : Editor 9 | { 10 | private StringBuildParameter m_target = default; 11 | private SerializedProperty m_value = default; 12 | private SerializedProperty m_options = default; 13 | 14 | private void OnEnable() 15 | { 16 | m_value = serializedObject.FindProperty(nameof(m_value)); 17 | m_options = serializedObject.FindProperty(nameof(m_options)); 18 | m_target = target as StringBuildParameter; 19 | } 20 | 21 | public override void OnInspectorGUI() 22 | { 23 | Draw(m_target, serializedObject, m_value, m_options); 24 | } 25 | 26 | /// 27 | /// This method is using to draw the same editor in different windows 28 | /// 29 | public static void Draw(StringBuildParameter target, SerializedObject serializedObject, SerializedProperty value, SerializedProperty options) 30 | { 31 | bool copyToClipboard = false; 32 | 33 | if (target.Options == null || target.Options.Count <= 0) 34 | { 35 | EditorGUILayout.PropertyField(value); 36 | } 37 | else 38 | { 39 | int index = target.Options.IndexOf(value.stringValue); 40 | index = EditorGUILayout.Popup(index, target.Options.Select(o => o.ToString()).ToArray()); 41 | 42 | if (index >= 0 && index <= target.Options.Count) 43 | { 44 | value.stringValue = target.Options[index]; 45 | } 46 | } 47 | 48 | EditorGUILayout.PropertyField(options); 49 | 50 | EditorGUILayout.BeginHorizontal(); 51 | { 52 | EditorGUILayout.LabelField($"CLI: {target.CliCommand}"); 53 | copyToClipboard = GUILayout.Button("Copy"); 54 | } 55 | EditorGUILayout.EndHorizontal(); 56 | 57 | serializedObject.ApplyModifiedProperties(); 58 | 59 | if (copyToClipboard) 60 | { 61 | EditorGUIUtility.systemCopyBuffer = $"{target.CliCommand}"; 62 | } 63 | } 64 | } 65 | } -------------------------------------------------------------------------------- /Editor/Core/Parameters/String/StringBuildParameterEditor.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 87c263969ecc47dd999daa3e86ca98cb 3 | timeCreated: 1678366876 -------------------------------------------------------------------------------- /Editor/Core/Parameters/String/StringBuildParameterPresenter.cs: -------------------------------------------------------------------------------- 1 | using UnityEditor; 2 | using UnityEngine; 3 | 4 | namespace UniTools.Build 5 | { 6 | public sealed class StringBuildParameterPresenter : BuildParameterPresenter 7 | { 8 | private readonly StringBuildParameter m_target = default; 9 | private readonly SerializedObject m_serializedObject = default; 10 | private readonly SerializedProperty m_value = default; 11 | private readonly SerializedProperty m_options = default; 12 | 13 | private bool m_foldout = false; 14 | 15 | public StringBuildParameterPresenter(StringBuildParameter target) 16 | { 17 | m_target = target; 18 | m_serializedObject = new SerializedObject(m_target); 19 | m_value = m_serializedObject.FindProperty(nameof(m_value)); 20 | m_options = m_serializedObject.FindProperty(nameof(m_options)); 21 | } 22 | 23 | public override string CliKey => m_target.CliKey; 24 | 25 | public override void Draw(bool duplicated) 26 | { 27 | bool select = false; 28 | if (m_foldout) 29 | { 30 | EditorGUILayout.BeginVertical("box"); 31 | { 32 | EditorGUILayout.BeginHorizontal(); 33 | { 34 | m_foldout = EditorGUILayout.Foldout(m_foldout, m_target.name, Styles.H2_Foldout); 35 | select = GUILayout.Button("Select", GUILayout.Width(100)); 36 | } 37 | EditorGUILayout.EndHorizontal(); 38 | if (duplicated) 39 | { 40 | EditorGUILayout.HelpBox("The parameter name is duplicated! Logical errors can happen during the batch mode call!", MessageType.Warning); 41 | } 42 | 43 | StringBuildParameterEditor.Draw(m_target, m_serializedObject, m_value, m_options); 44 | } 45 | EditorGUILayout.EndVertical(); 46 | } 47 | else 48 | { 49 | EditorGUILayout.BeginHorizontal("box"); 50 | { 51 | Color color = GUI.color; 52 | 53 | if (duplicated) 54 | { 55 | GUI.color = Color.red; 56 | } 57 | 58 | m_foldout = EditorGUILayout.Foldout(m_foldout, m_target.name, Styles.H2_Foldout); 59 | select = GUILayout.Button("Select", GUILayout.Width(100)); 60 | 61 | GUI.color = color; 62 | } 63 | EditorGUILayout.EndHorizontal(); 64 | } 65 | 66 | if (select) 67 | { 68 | EditorGUIUtility.PingObject(m_target); 69 | } 70 | } 71 | } 72 | } -------------------------------------------------------------------------------- /Editor/Core/Parameters/String/StringBuildParameterPresenter.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: c544ac55d3a2410a9c10104d0e166463 3 | timeCreated: 1678442280 -------------------------------------------------------------------------------- /Editor/Core/Pipelines.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 58bdb51aa1b64f4f875741311931e34e 3 | timeCreated: 1609923346 -------------------------------------------------------------------------------- /Editor/Core/Pipelines/BuildPipeline.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Threading.Tasks; 3 | using UnityEditor; 4 | using UnityEngine; 5 | 6 | namespace UniTools.Build 7 | { 8 | [CreateAssetMenu( 9 | fileName = nameof(BuildPipeline), 10 | menuName = MenuPaths.Core + "Pipeline" 11 | )] 12 | public sealed class BuildPipeline : ScriptableObject 13 | { 14 | //TODO Notes for the custom editor 15 | //https://forum.unity.com/threads/solved-propertydrawer-on-array-elements-with-different-heights.542194/ 16 | [Serializable] 17 | private sealed class PipelineStep 18 | { 19 | public string Name = string.Empty; 20 | public BuildStep Step = default; 21 | public bool Skip = false; 22 | } 23 | 24 | [SerializeField] private PipelineStep[] m_steps = default; 25 | 26 | public int Count => m_steps.Length; 27 | 28 | private void OnValidate() 29 | { 30 | if (m_steps == null) return; 31 | 32 | foreach (PipelineStep step in m_steps) 33 | { 34 | if (step == null) continue; 35 | if (step.Step == null) continue; 36 | 37 | if (step.Skip) 38 | { 39 | step.Name = $"{step.Step.name}(Skipped)"; 40 | } 41 | else 42 | { 43 | step.Name = step.Step.name; 44 | } 45 | } 46 | } 47 | 48 | public async Task RunStep(int index) 49 | { 50 | if (index < 0 || index >= Count) 51 | { 52 | throw new Exception($"{nameof(BuildPipeline)}: Invalid step index {index}!"); 53 | } 54 | 55 | try 56 | { 57 | EditorUtility.ClearProgressBar(); 58 | if (m_steps[index] == null || m_steps[index].Step == null) 59 | { 60 | Debug.LogWarning($"{nameof(BuildPipeline)}: The step at index {index} is null!"); 61 | 62 | return; 63 | } 64 | 65 | EditorUtility.DisplayProgressBar($"Execute {m_steps[index].Step.name} ({index + 1}/{m_steps.Length})...", $"{m_steps[index].Step.name} ", index / (float)Count); 66 | 67 | if (m_steps[index].Skip) 68 | { 69 | Debug.LogWarning($"{nameof(BuildPipeline)}: The {m_steps[index].Step.name} was skipped!"); 70 | 71 | return; 72 | } 73 | 74 | await m_steps[index].Step.Execute(); 75 | EditorUtility.ClearProgressBar(); 76 | } 77 | finally 78 | { 79 | EditorUtility.ClearProgressBar(); 80 | } 81 | } 82 | 83 | [ContextMenu("Run")] 84 | public async Task Run() 85 | { 86 | if (Application.isBatchMode) 87 | { 88 | throw new Exception($"{nameof(BuildPipeline)}: can not be run from the BatchMode!"); 89 | } 90 | 91 | if (m_steps == null || m_steps.Length == 0) 92 | { 93 | Debug.Log($"{nameof(BuildPipeline)}: no any post build steps"); 94 | 95 | return; 96 | } 97 | 98 | try 99 | { 100 | for (int i = 0; i < Count; i++) 101 | { 102 | await RunStep(i); 103 | } 104 | } 105 | catch (Exception e) 106 | { 107 | Debug.LogException(e); 108 | 109 | throw e; 110 | } 111 | } 112 | } 113 | } -------------------------------------------------------------------------------- /Editor/Core/Pipelines/BuildPipeline.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: e12e6f4ab3264ce88a259de668535474 3 | timeCreated: 1609915515 -------------------------------------------------------------------------------- /Editor/Core/Pipelines/CustomEditors.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 6fdc507a56bc243ce89ee4fcbee680df 3 | folderAsset: yes 4 | DefaultImporter: 5 | externalObjects: {} 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Editor/Core/Pipelines/CustomEditors/BuildPipelinePresenter.cs: -------------------------------------------------------------------------------- 1 | using System.Collections.Generic; 2 | using UnityEditor; 3 | using UnityEngine; 4 | 5 | namespace UniTools.Build 6 | { 7 | public sealed class BuildPipelinePresenter 8 | { 9 | private readonly BuildPipeline m_buildPipeline = default; 10 | private readonly List m_parameters = default; 11 | private bool m_foldout = false; 12 | 13 | public BuildPipelinePresenter(BuildPipeline buildPipeline, IEnumerable parameters) 14 | { 15 | m_buildPipeline = buildPipeline; 16 | m_parameters = new List(parameters); 17 | } 18 | 19 | public void Draw() 20 | { 21 | bool run = false; 22 | bool select = false; 23 | string command = string.Empty; 24 | foreach (ScriptableBuildParameter p in m_parameters) 25 | { 26 | command += $" {p.CliCommand} "; 27 | } 28 | 29 | if (m_foldout) 30 | { 31 | string sh = $"./build.sh --pipeline {m_buildPipeline.name} {command}"; 32 | string ps = $".\\build.ps1 --pipeline {m_buildPipeline.name} {command}"; 33 | bool copySh = false; 34 | bool copyPs = false; 35 | 36 | EditorGUILayout.BeginVertical("box"); 37 | { 38 | EditorGUILayout.BeginHorizontal(); 39 | { 40 | m_foldout = EditorGUILayout.Foldout(m_foldout, m_buildPipeline.name, Styles.H2_Foldout); 41 | run = GUILayout.Button("Run", GUILayout.Width(100)); 42 | } 43 | EditorGUILayout.EndHorizontal(); 44 | 45 | EditorGUILayout.LabelField("CLI commands:"); 46 | EditorGUILayout.BeginHorizontal(); 47 | { 48 | EditorGUILayout.LabelField($"SH: {sh}"); 49 | copySh = GUILayout.Button("Copy"); 50 | } 51 | EditorGUILayout.EndHorizontal(); 52 | 53 | EditorGUILayout.BeginHorizontal(); 54 | { 55 | EditorGUILayout.LabelField($"PS: {ps}"); 56 | copyPs = GUILayout.Button("Copy"); 57 | } 58 | EditorGUILayout.EndHorizontal(); 59 | 60 | select = GUILayout.Button("Select Pipeline", GUILayout.Width(250)); 61 | 62 | if (copySh) 63 | { 64 | EditorGUIUtility.systemCopyBuffer = sh; 65 | } 66 | 67 | if (copyPs) 68 | { 69 | EditorGUIUtility.systemCopyBuffer = ps; 70 | } 71 | } 72 | EditorGUILayout.EndVertical(); 73 | } 74 | else 75 | { 76 | EditorGUILayout.BeginHorizontal("box"); 77 | { 78 | m_foldout = EditorGUILayout.Foldout(m_foldout, m_buildPipeline.name, Styles.H2_Foldout); 79 | run = GUILayout.Button("Run", GUILayout.Width(100)); 80 | } 81 | EditorGUILayout.EndHorizontal(); 82 | } 83 | 84 | if (run) 85 | { 86 | if (EditorUtility.DisplayDialog($"Run {m_buildPipeline.name} pipeline?", "", "Yes", "No")) 87 | { 88 | m_buildPipeline.Run().GetAwaiter().OnCompleted(() => { Debug.Log($"Pipeline {m_buildPipeline} is completed!"); }); 89 | } 90 | } 91 | 92 | if (select) 93 | { 94 | EditorGUIUtility.PingObject(m_buildPipeline); 95 | } 96 | } 97 | } 98 | } -------------------------------------------------------------------------------- /Editor/Core/Pipelines/CustomEditors/BuildPipelinePresenter.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: a98782ef545649a7bda4a738495f5cbb 3 | timeCreated: 1610025271 -------------------------------------------------------------------------------- /Editor/Core/Pipelines/CustomEditors/BuildPipelinesProjectSettingsProvider.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: e1584fe425864bb0aa9ea59fb259a86b 3 | timeCreated: 1610023385 -------------------------------------------------------------------------------- /Editor/Core/Steps.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: a076534936124e50b21de448195b7edc 3 | timeCreated: 1609857024 -------------------------------------------------------------------------------- /Editor/Core/Steps/Build.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 5e58d72606b74cd2a2e24c1890276915 3 | timeCreated: 1609923471 -------------------------------------------------------------------------------- /Editor/Core/Steps/Build/UnityBuildStep.cs: -------------------------------------------------------------------------------- 1 | using UnityEditor; 2 | 3 | namespace UniTools.Build 4 | { 5 | /// 6 | /// This step must be user to create a build (artifacts: iOS, Android, etc...) using Unity API 7 | /// 8 | public abstract class UnityBuildStep : BuildStep 9 | { 10 | public abstract BuildTarget Target { get; } 11 | } 12 | } -------------------------------------------------------------------------------- /Editor/Core/Steps/Build/UnityBuildStep.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 51bb898df0034d23bca9d4f3697f55d1 3 | timeCreated: 1609915977 -------------------------------------------------------------------------------- /Editor/Core/Steps/Build/UnityBuildStepWithOptions.cs: -------------------------------------------------------------------------------- 1 | using System.Linq; 2 | using UnityEditor; 3 | using UnityEngine; 4 | 5 | namespace UniTools.Build 6 | { 7 | public abstract class UnityBuildStepWithOptions : UnityBuildStep 8 | { 9 | [SerializeField] private PathProperty m_path = default; 10 | [SerializeField] private bool m_developmentBuild = false; 11 | #if UNITY_2021_2_OR_NEWER 12 | [SerializeField] private bool m_cleanBuildCache = false; 13 | #endif 14 | protected BuildPlayerOptions Options 15 | { 16 | get 17 | { 18 | BuildPlayerOptions buildPlayerOptions = new BuildPlayerOptions(); 19 | buildPlayerOptions.scenes = EditorBuildSettings.scenes.Select(s => s.path).ToArray(); 20 | buildPlayerOptions.locationPathName = m_path.ToString(); 21 | buildPlayerOptions.target = Target; 22 | buildPlayerOptions.targetGroup = UnityEditor.BuildPipeline.GetBuildTargetGroup(Target); 23 | 24 | if (m_developmentBuild) 25 | { 26 | buildPlayerOptions.options = BuildOptions.Development; 27 | } 28 | 29 | #if UNITY_2021_2_OR_NEWER 30 | if (m_cleanBuildCache) 31 | { 32 | buildPlayerOptions.options |= BuildOptions.CleanBuildCache; 33 | } 34 | #endif 35 | 36 | return buildPlayerOptions; 37 | } 38 | } 39 | } 40 | } -------------------------------------------------------------------------------- /Editor/Core/Steps/Build/UnityBuildStepWithOptions.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: d89da10cc1914234adb754b8f7fc3d5b 3 | timeCreated: 1623070606 -------------------------------------------------------------------------------- /Editor/Core/Steps/Custom.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 2d39c835ccd547c8815f1b9a75f413a7 3 | timeCreated: 1617093851 -------------------------------------------------------------------------------- /Editor/Core/Steps/Custom/BuildStep.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Threading.Tasks; 3 | using UnityEditor; 4 | using UnityEngine; 5 | 6 | namespace UniTools.Build 7 | { 8 | /// 9 | /// This type of steps should be user to create any custom behavior for the build pipeline 10 | /// 11 | public abstract class BuildStep : ScriptableObject 12 | { 13 | public abstract Task Execute(); 14 | 15 | [ContextMenu("Run")] 16 | private void Run() 17 | { 18 | if (EditorUtility.DisplayDialog($"Run {name} separately?", "This option must be used for the debug only. Running steps outside of the pipeline can cause unexpected behavior.", "Yes", "No")) 19 | { 20 | Debug.Log($"Running {name} separately."); 21 | 22 | try 23 | { 24 | Execute().GetAwaiter().GetResult(); 25 | } 26 | catch (Exception e) 27 | { 28 | Debug.LogException(e); 29 | } 30 | } 31 | } 32 | } 33 | } -------------------------------------------------------------------------------- /Editor/Core/Steps/Custom/BuildStep.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: d9e1c72a190d4e399ba1887e52e56246 3 | timeCreated: 1618555812 -------------------------------------------------------------------------------- /Editor/Core/Steps/Exceptions.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: eb4004152cf44007a922c862a1a5eb28 3 | timeCreated: 1610040596 -------------------------------------------------------------------------------- /Editor/Core/Steps/Exceptions/BuildStepFailedException.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace UniTools.Build 4 | { 5 | public sealed class BuildStepFailedException : Exception 6 | { 7 | public BuildStepFailedException(string message) : base(message) 8 | { 9 | } 10 | } 11 | } -------------------------------------------------------------------------------- /Editor/Core/Steps/Exceptions/BuildStepFailedException.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 2da1a94d86d24e4bad18d8ead7dad13a 3 | timeCreated: 1610040621 -------------------------------------------------------------------------------- /Editor/Defines.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 35ae07307271b433a9921af1201f39ab 3 | folderAsset: yes 4 | DefaultImporter: 5 | externalObjects: {} 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Editor/Defines/ApplyDefines.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Threading.Tasks; 3 | using UnityEditor; 4 | using UnityEngine; 5 | 6 | namespace UniTools.Build 7 | { 8 | [CreateAssetMenu( 9 | fileName = nameof(ApplyDefines), 10 | menuName = MenuPaths.Defines + "ApplyDefines" 11 | )] 12 | public sealed class ApplyDefines : BuildStep 13 | { 14 | [SerializeField] private ScriptingDefineSymbols m_symbols = default; 15 | [SerializeField] private BuildTargetGroup m_group = default; 16 | 17 | public override async Task Execute() 18 | { 19 | if (m_symbols == null) 20 | { 21 | throw new Exception("Invalid define symbols added!"); 22 | } 23 | 24 | PlayerSettings.SetScriptingDefineSymbolsForGroup(m_group, m_symbols.ToString()); 25 | 26 | AssetDatabase.Refresh(); 27 | AssetDatabase.SaveAssets(); 28 | 29 | await Task.CompletedTask; 30 | } 31 | } 32 | } -------------------------------------------------------------------------------- /Editor/Defines/ApplyDefines.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 74c6a9ad9eec421da59704adf50e4f74 3 | timeCreated: 1623069144 -------------------------------------------------------------------------------- /Editor/Defines/DefineSymbolPropertyDrawer.cs: -------------------------------------------------------------------------------- 1 | using UnityEditor; 2 | using UnityEngine; 3 | 4 | namespace UniTools.Build 5 | { 6 | [CustomPropertyDrawer(typeof(ScriptingDefineSymbols.DefineSymbol))] 7 | public sealed class DefineSymbolPropertyDrawer : PropertyDrawer 8 | { 9 | public override void OnGUI(Rect position, SerializedProperty property, GUIContent label) 10 | { 11 | int boolSize = 25; 12 | Rect enabledRect = new Rect(position.x, position.y, boolSize, position.height); 13 | Rect valueRect = new Rect(position.x + boolSize, position.y, position.width - boolSize, position.height); 14 | SerializedProperty value = property.FindPropertyRelative("Value"); 15 | SerializedProperty enabled = property.FindPropertyRelative("Enabled"); 16 | enabled.boolValue = EditorGUI.Toggle(enabledRect, enabled.boolValue); 17 | 18 | Color color = GUI.color; 19 | if (!enabled.boolValue) 20 | { 21 | GUI.color = new Color(color.r, color.g, color.b, 0.5f); 22 | } 23 | 24 | value.stringValue = EditorGUI.TextField(valueRect, value.stringValue).Replace(" ", "_"); 25 | GUI.color = color; 26 | } 27 | } 28 | } -------------------------------------------------------------------------------- /Editor/Defines/DefineSymbolPropertyDrawer.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 6750a45890ac4975b3acb3c84bd703f8 3 | timeCreated: 1678800504 -------------------------------------------------------------------------------- /Editor/Defines/ScriptingDefineSymbols.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Text; 4 | using UnityEngine; 5 | 6 | namespace UniTools.Build 7 | { 8 | [CreateAssetMenu( 9 | fileName = nameof(ScriptingDefineSymbols), 10 | menuName = MenuPaths.Defines + "DefineSymbols" 11 | )] 12 | public sealed class ScriptingDefineSymbols : ScriptableBuildParameter 13 | { 14 | [Serializable] 15 | public sealed class DefineSymbol 16 | { 17 | public string Value = "MY_DEFINE"; 18 | public bool Enabled = true; 19 | } 20 | 21 | [SerializeField] private List m_defines = new List(); 22 | public override string CliCommand => $"{CliKey} \"{ToString()}\""; 23 | 24 | public override string ToString() 25 | { 26 | //in case 27 | if (Application.isBatchMode && CommandLineParser.TryToParseValue(Environment.CommandLine, CliKey, out object obj)) 28 | { 29 | return obj.ToString(); 30 | } 31 | 32 | if (m_defines.Count == 0) 33 | { 34 | return string.Empty; 35 | } 36 | 37 | StringBuilder builder = new StringBuilder(); 38 | 39 | int last = m_defines.Count - 1; 40 | 41 | for (int i = 0; i < last; i++) 42 | { 43 | if (m_defines[i].Enabled) 44 | { 45 | builder.Append(m_defines[i].Value).Append(";"); 46 | } 47 | } 48 | 49 | if (m_defines[last].Enabled) 50 | { 51 | builder.Append(m_defines[last].Value); 52 | } 53 | 54 | return builder.ToString(); 55 | } 56 | } 57 | } -------------------------------------------------------------------------------- /Editor/Defines/ScriptingDefineSymbols.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 4b7ff42fc86d40c0a6c14c0bb45ae6cc 3 | timeCreated: 1612532281 -------------------------------------------------------------------------------- /Editor/Defines/ScriptingDefineSymbolsEditor.cs: -------------------------------------------------------------------------------- 1 | using UnityEditor; 2 | using UnityEngine; 3 | 4 | namespace UniTools.Build 5 | { 6 | [CustomEditor(typeof(ScriptingDefineSymbols))] 7 | public sealed class ScriptingDefineSymbolsEditor : Editor 8 | { 9 | private ScriptingDefineSymbols m_target = default; 10 | private SerializedProperty m_defines = default; 11 | 12 | private void OnEnable() 13 | { 14 | m_defines = serializedObject.FindProperty(nameof(m_defines)); 15 | m_target = target as ScriptingDefineSymbols; 16 | } 17 | 18 | public override void OnInspectorGUI() 19 | { 20 | Draw(m_target, serializedObject, m_defines); 21 | } 22 | 23 | public static void Draw(ScriptingDefineSymbols target, SerializedObject serializedObject, SerializedProperty defines) 24 | { 25 | EditorGUILayout.PropertyField(defines); 26 | bool copyToClipboard = false; 27 | 28 | EditorGUILayout.BeginHorizontal(); 29 | { 30 | EditorGUILayout.LabelField($"CLI: {target.CliCommand}"); 31 | copyToClipboard = GUILayout.Button("Copy"); 32 | } 33 | EditorGUILayout.EndHorizontal(); 34 | 35 | serializedObject.ApplyModifiedProperties(); 36 | 37 | if (copyToClipboard) 38 | { 39 | EditorGUIUtility.systemCopyBuffer = $"{target.CliCommand}"; 40 | } 41 | } 42 | } 43 | } -------------------------------------------------------------------------------- /Editor/Defines/ScriptingDefineSymbolsEditor.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 17d24a9bf64e403f84a51648fc823033 3 | timeCreated: 1678430751 -------------------------------------------------------------------------------- /Editor/Defines/ScriptingDefineSymbolsPresenter.cs: -------------------------------------------------------------------------------- 1 | using UnityEditor; 2 | using UnityEngine; 3 | 4 | namespace UniTools.Build 5 | { 6 | public sealed class ScriptingDefineSymbolsPresenter 7 | { 8 | private readonly ScriptingDefineSymbols m_target = default; 9 | private readonly SerializedObject m_serializedObject = default; 10 | private readonly SerializedProperty m_defines = default; 11 | private bool m_foldout = false; 12 | private BuildTargetGroup m_group; 13 | 14 | public ScriptingDefineSymbolsPresenter(ScriptingDefineSymbols target) 15 | { 16 | m_target = target; 17 | m_serializedObject = new SerializedObject(m_target); 18 | m_defines = m_serializedObject.FindProperty(nameof(m_defines)); 19 | 20 | m_group = EditorUserBuildSettings.selectedBuildTargetGroup; 21 | } 22 | 23 | public void Draw() 24 | { 25 | bool apply = false; 26 | bool select = false; 27 | 28 | if (m_foldout) 29 | { 30 | EditorGUILayout.BeginVertical("box"); 31 | { 32 | EditorGUILayout.BeginHorizontal(); 33 | { 34 | m_foldout = EditorGUILayout.Foldout(m_foldout, m_target.name, Styles.H2_Foldout); 35 | select = GUILayout.Button("Select", GUILayout.Width(100)); 36 | } 37 | EditorGUILayout.EndHorizontal(); 38 | 39 | ScriptingDefineSymbolsEditor.Draw(m_target, m_serializedObject, m_defines); 40 | EditorGUILayout.BeginHorizontal(); 41 | { 42 | apply = GUILayout.Button("Apply For"); 43 | m_group = (BuildTargetGroup)EditorGUILayout.EnumPopup("", m_group); 44 | } 45 | EditorGUILayout.EndHorizontal(); 46 | } 47 | EditorGUILayout.EndVertical(); 48 | } 49 | else 50 | { 51 | EditorGUILayout.BeginHorizontal("box"); 52 | { 53 | m_foldout = EditorGUILayout.Foldout(m_foldout, m_target.name, Styles.H2_Foldout); 54 | select = GUILayout.Button("Select", GUILayout.Width(100)); 55 | } 56 | EditorGUILayout.EndHorizontal(); 57 | } 58 | 59 | if (apply) 60 | { 61 | PlayerSettings.SetScriptingDefineSymbolsForGroup(m_group, m_target.ToString()); 62 | 63 | AssetDatabase.Refresh(); 64 | AssetDatabase.SaveAssets(); 65 | } 66 | 67 | if (select) 68 | { 69 | EditorGUIUtility.PingObject(m_target); 70 | } 71 | } 72 | } 73 | } -------------------------------------------------------------------------------- /Editor/Defines/ScriptingDefineSymbolsPresenter.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 88a78d9f96de4056bb0274f8b829e637 3 | timeCreated: 1678805807 -------------------------------------------------------------------------------- /Editor/IO.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 19703eb52f1674d92b6854488b29bbf5 3 | folderAsset: yes 4 | DefaultImporter: 5 | externalObjects: {} 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Editor/IO/Archive.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 1e26a85edce643bea61c7f882bb7644c 3 | timeCreated: 1642489348 -------------------------------------------------------------------------------- /Editor/IO/Archive/CreateZipArchiveStep.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.IO; 3 | using System.Threading.Tasks; 4 | using UnityEngine; 5 | 6 | namespace UniTools.Build 7 | { 8 | [CreateAssetMenu( 9 | fileName = nameof(CreateZipArchiveStep), 10 | menuName = MenuPaths.IO + "Zip Archive" 11 | )] 12 | public sealed class CreateZipArchiveStep : BuildStep 13 | { 14 | [SerializeField, Tooltip("The location of the folder that needs to be compressed.")] private PathProperty m_directory = default; 15 | [SerializeField, Tooltip("The name of the created archive (include extensions. Ex: my.zip).")] private PathProperty m_archiveFileName = default; 16 | 17 | public override async Task Execute() 18 | { 19 | if (string.IsNullOrWhiteSpace(m_archiveFileName.ToString())) 20 | { 21 | throw new Exception($"{nameof(CreateZipArchiveStep)}: file name is null or empty!"); 22 | } 23 | 24 | string ext = Path.GetExtension(m_archiveFileName.ToString()); 25 | if (!ext.Equals(".zip")) 26 | { 27 | throw new Exception($"{nameof(CreateZipArchiveStep)}: invalid file name {m_archiveFileName}!"); 28 | } 29 | 30 | if (!Directory.Exists(m_directory.ToString())) 31 | { 32 | throw new Exception($"{nameof(CreateZipArchiveStep)}: failed due to directory {m_directory} doesn't exist!"); 33 | } 34 | 35 | Zip zip = Cli.Tool(); 36 | if (zip == null || !zip.IsInstalled) 37 | { 38 | throw new ToolNotInstalledException(); 39 | } 40 | 41 | string command = $"-r {m_archiveFileName} *"; 42 | ToolResult result = zip.Execute(command, m_directory.ToString()); 43 | Debug.Log(result); 44 | 45 | await Task.CompletedTask; 46 | } 47 | } 48 | } -------------------------------------------------------------------------------- /Editor/IO/Archive/CreateZipArchiveStep.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: e5422d2e9e4242678845016fa182ec34 3 | timeCreated: 1642069988 -------------------------------------------------------------------------------- /Editor/IO/CustomEditors.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 4edb003ab1e1439d8d98efdddd3c26df 3 | timeCreated: 1618240641 -------------------------------------------------------------------------------- /Editor/IO/CustomEditors/CompositeScriptablePathEditor.cs: -------------------------------------------------------------------------------- 1 | using UnityEditor; 2 | 3 | namespace UniTools.Build 4 | { 5 | [CustomEditor(typeof(CompositeScriptablePath))] 6 | public sealed class CompositeScriptablePathEditor : Editor 7 | { 8 | private SerializedProperty m_paths = default; 9 | 10 | private void OnEnable() 11 | { 12 | m_paths = serializedObject.FindProperty(nameof(m_paths)); 13 | } 14 | 15 | public override void OnInspectorGUI() 16 | { 17 | EditorGUILayout.LabelField(target.ToString()); 18 | EditorGUILayout.PropertyField(m_paths); 19 | serializedObject.ApplyModifiedProperties(); 20 | } 21 | } 22 | } -------------------------------------------------------------------------------- /Editor/IO/CustomEditors/CompositeScriptablePathEditor.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 635ad2fd9afd4948b989d97b19a8967e 3 | timeCreated: 1618240659 -------------------------------------------------------------------------------- /Editor/IO/CustomEditors/EnsureDirectoryEmptyEditor.cs: -------------------------------------------------------------------------------- 1 | using UnityEditor; 2 | 3 | namespace UniTools.Build 4 | { 5 | [CustomEditor(typeof(EnsureDirectoryEmpty))] 6 | public sealed class EnsureDirectoryEmptyEditor : Editor 7 | { 8 | public override void OnInspectorGUI() 9 | { 10 | base.OnInspectorGUI(); 11 | EditorGUILayout.LabelField(target.ToString()); 12 | serializedObject.ApplyModifiedProperties(); 13 | } 14 | } 15 | } -------------------------------------------------------------------------------- /Editor/IO/CustomEditors/EnsureDirectoryEmptyEditor.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 5b2a807e807f48be86a40c892ae04083 3 | timeCreated: 1648036157 -------------------------------------------------------------------------------- /Editor/IO/CustomEditors/EnsureDirectoryExistsEditor.cs: -------------------------------------------------------------------------------- 1 | using UnityEditor; 2 | 3 | namespace UniTools.Build 4 | { 5 | [CustomEditor(typeof(EnsureDirectoryExists))] 6 | public sealed class EnsureDirectoryExistsEditor : Editor 7 | { 8 | public override void OnInspectorGUI() 9 | { 10 | base.OnInspectorGUI(); 11 | EditorGUILayout.LabelField(target.ToString()); 12 | serializedObject.ApplyModifiedProperties(); 13 | } 14 | } 15 | } -------------------------------------------------------------------------------- /Editor/IO/CustomEditors/EnsureDirectoryExistsEditor.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 511dd3de099448dca36641756502510d 3 | timeCreated: 1648036544 -------------------------------------------------------------------------------- /Editor/IO/Directory.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: f8110d1d2b104ee6a89c487901030d88 3 | timeCreated: 1642574607 -------------------------------------------------------------------------------- /Editor/IO/Directory/CopyDirectory.cs: -------------------------------------------------------------------------------- 1 | using System.Threading.Tasks; 2 | using UnityEditor; 3 | using UnityEngine; 4 | 5 | namespace UniTools.Build 6 | { 7 | [CreateAssetMenu( 8 | fileName = nameof(CopyDirectory), 9 | menuName = MenuPaths.IO + nameof(CopyDirectory) 10 | )] 11 | public sealed class CopyDirectory : BuildStep 12 | { 13 | [SerializeField] private PathProperty m_source = default; 14 | [SerializeField] private PathProperty m_destination = default; 15 | 16 | public override async Task Execute() 17 | { 18 | FileUtil.DeleteFileOrDirectory(m_destination.ToString()); 19 | FileUtil.CopyFileOrDirectory(m_source.ToString(), m_destination.ToString()); 20 | await Task.CompletedTask; 21 | } 22 | } 23 | } -------------------------------------------------------------------------------- /Editor/IO/Directory/CopyDirectory.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 5c173b0d1bb8f4bda91cea58587dc517 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Editor/IO/Directory/EnsureDirectoryEmpty.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.IO; 3 | using System.Threading.Tasks; 4 | using UnityEngine; 5 | 6 | namespace UniTools.Build 7 | { 8 | [CreateAssetMenu( 9 | fileName = nameof(EnsureDirectoryEmpty), 10 | menuName = MenuPaths.IO + nameof(EnsureDirectoryEmpty) 11 | )] 12 | public sealed class EnsureDirectoryEmpty : BuildStep 13 | { 14 | [SerializeField] private PathProperty m_path = default; 15 | 16 | public override async Task Execute() 17 | { 18 | DirectoryInfo di = new DirectoryInfo(m_path.ToString()); 19 | 20 | if (!di.Exists) 21 | { 22 | throw new Exception($"{nameof(EnsureDirectoryEmpty)}: failed due to directory does not exists!"); 23 | } 24 | 25 | foreach (FileInfo file in di.GetFiles()) 26 | { 27 | file.Delete(); 28 | } 29 | 30 | foreach (DirectoryInfo dir in di.GetDirectories()) 31 | { 32 | dir.Delete(true); 33 | } 34 | 35 | await Task.CompletedTask; 36 | } 37 | 38 | public override string ToString() 39 | { 40 | return m_path.ToString(); 41 | } 42 | } 43 | } -------------------------------------------------------------------------------- /Editor/IO/Directory/EnsureDirectoryEmpty.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: d060607e3fcc49da81ffff0d125537ef 3 | timeCreated: 1642575023 -------------------------------------------------------------------------------- /Editor/IO/Directory/EnsureDirectoryExists.cs: -------------------------------------------------------------------------------- 1 | using System.IO; 2 | using System.Threading.Tasks; 3 | using UnityEngine; 4 | 5 | namespace UniTools.Build 6 | { 7 | [CreateAssetMenu( 8 | fileName = nameof(EnsureDirectoryExists), 9 | menuName = MenuPaths.IO + nameof(EnsureDirectoryExists) 10 | )] 11 | public sealed class EnsureDirectoryExists : BuildStep 12 | { 13 | [SerializeField] private PathProperty m_path = default; 14 | 15 | public override async Task Execute() 16 | { 17 | Directory.CreateDirectory(m_path.ToString()); 18 | 19 | await Task.CompletedTask; 20 | } 21 | 22 | public override string ToString() 23 | { 24 | return m_path.ToString(); 25 | } 26 | } 27 | } -------------------------------------------------------------------------------- /Editor/IO/Directory/EnsureDirectoryExists.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: c09a96360f824071991d724c4486dbd8 3 | timeCreated: 1642574630 -------------------------------------------------------------------------------- /Editor/IO/Files.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 8a0a4ffc358b4f918b5e14baa96b90e1 3 | timeCreated: 1642574498 -------------------------------------------------------------------------------- /Editor/IO/Files/CopyFileToDirectory.cs: -------------------------------------------------------------------------------- 1 | using System.IO; 2 | using System.Threading.Tasks; 3 | using UniTools.Build; 4 | using UnityEditor; 5 | using UnityEngine; 6 | 7 | namespace UniTools.Build 8 | { 9 | [CreateAssetMenu( 10 | fileName = nameof(CopyFileToDirectory), 11 | menuName = MenuPaths.IO + nameof(CopyFileToDirectory) 12 | )] 13 | public sealed class CopyFileToDirectory : BuildStep 14 | { 15 | [SerializeField] private PathProperty m_filePath = default; 16 | [SerializeField] private PathProperty m_destination = default; 17 | 18 | public override async Task Execute() 19 | { 20 | string fileName = Path.GetFileName(m_filePath.ToString()); 21 | string dest = Path.Combine(m_destination.ToString(), fileName); 22 | FileUtil.DeleteFileOrDirectory(dest); 23 | FileUtil.CopyFileOrDirectory(m_filePath.ToString(), dest); 24 | await Task.CompletedTask; 25 | } 26 | } 27 | } -------------------------------------------------------------------------------- /Editor/IO/Files/CopyFileToDirectory.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 87140f12fbfd4965823c46db3f19d0ab 3 | timeCreated: 1642574522 -------------------------------------------------------------------------------- /Editor/IO/Files/DeleteFileOrDirectory.cs: -------------------------------------------------------------------------------- 1 | using System.Threading.Tasks; 2 | using UniTools.Build; 3 | using UnityEditor; 4 | using UnityEngine; 5 | 6 | namespace UniTools.Build 7 | { 8 | [CreateAssetMenu( 9 | fileName = nameof(DeleteFileOrDirectory), 10 | menuName = MenuPaths.IO + nameof(DeleteFileOrDirectory) 11 | )] 12 | public sealed class DeleteFileOrDirectory : BuildStep 13 | { 14 | [SerializeField] private PathProperty m_path = default; 15 | 16 | public override async Task Execute() 17 | { 18 | FileUtil.DeleteFileOrDirectory(m_path.ToString()); 19 | await Task.CompletedTask; 20 | } 21 | } 22 | } -------------------------------------------------------------------------------- /Editor/IO/Files/DeleteFileOrDirectory.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 627e9b34be2840188f77134ae2d1f3c4 3 | timeCreated: 1623074204 -------------------------------------------------------------------------------- /Editor/IO/Path.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: dcc1f9b56ce24483689dc39f4582de20 3 | folderAsset: yes 4 | DefaultImporter: 5 | externalObjects: {} 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Editor/IO/Path/BaseScriptablePath.cs: -------------------------------------------------------------------------------- 1 | using UnityEngine; 2 | 3 | namespace UniTools.Build 4 | { 5 | /// 6 | /// Created to separate path from other SO 7 | /// 8 | public abstract class BaseScriptablePath : ScriptableObject 9 | { 10 | } 11 | } -------------------------------------------------------------------------------- /Editor/IO/Path/BaseScriptablePath.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 6cb7d8ded8f4401a8089fc4b5ed79514 3 | timeCreated: 1618240244 -------------------------------------------------------------------------------- /Editor/IO/Path/CompositeScriptablePath.cs: -------------------------------------------------------------------------------- 1 | using System.Collections.Generic; 2 | using System.IO; 3 | using UnityEngine; 4 | 5 | namespace UniTools.Build 6 | { 7 | [CreateAssetMenu( 8 | fileName = nameof(CompositeScriptablePath), 9 | menuName = MenuPaths.IO + "Composite Path" 10 | )] 11 | public sealed class CompositeScriptablePath : BaseScriptablePath 12 | { 13 | [SerializeField] private List m_paths = default; 14 | 15 | public override string ToString() 16 | { 17 | if (m_paths == null) 18 | { 19 | return string.Empty; 20 | } 21 | 22 | string p = string.Empty; 23 | 24 | foreach (PathProperty path in m_paths) 25 | { 26 | p = Path.Combine(p, path.ToString()); 27 | } 28 | 29 | return p; 30 | } 31 | } 32 | } -------------------------------------------------------------------------------- /Editor/IO/Path/CompositeScriptablePath.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 81d46116aa124e968870dad724d393e5 3 | timeCreated: 1618240305 -------------------------------------------------------------------------------- /Editor/IO/Path/Core.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 1e3d6312ee3444d7a81f4e078a85c6aa 3 | timeCreated: 1642666217 -------------------------------------------------------------------------------- /Editor/IO/Path/Core/PathProperty.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using UnityEngine; 3 | 4 | namespace UniTools.Build 5 | { 6 | [Serializable] 7 | public sealed class PathProperty 8 | { 9 | [SerializeField] private PathTypes m_type = PathTypes.String; 10 | [SerializeField] private string m_path = default; 11 | [SerializeField] private BaseScriptablePath m_scriptablePath = default; 12 | 13 | private PathProperty() 14 | { 15 | } 16 | 17 | public PathProperty(string path) 18 | { 19 | m_path = path; 20 | } 21 | 22 | public override string ToString() 23 | { 24 | if (m_type == PathTypes.Scriptable) 25 | { 26 | if (m_scriptablePath == null) 27 | { 28 | return string.Empty; 29 | } 30 | 31 | return m_scriptablePath.ToString(); 32 | } 33 | 34 | return m_path; 35 | } 36 | } 37 | } -------------------------------------------------------------------------------- /Editor/IO/Path/Core/PathProperty.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 3f807e7d2f4044ef95e2beea628020c6 3 | timeCreated: 1617799268 -------------------------------------------------------------------------------- /Editor/IO/Path/Core/PathPropertyDrawer.cs: -------------------------------------------------------------------------------- 1 | using UnityEditor; 2 | using UnityEngine; 3 | 4 | namespace UniTools.Build 5 | { 6 | [CustomPropertyDrawer(typeof(PathProperty))] 7 | public sealed class PathPropertyDrawer : PropertyDrawer 8 | { 9 | public override void OnGUI(Rect position, SerializedProperty property, GUIContent label) 10 | { 11 | // Using BeginProperty / EndProperty on the parent property means that 12 | // prefab override logic works on the entire property. 13 | EditorGUI.BeginProperty(position, label, property); 14 | 15 | // Draw label 16 | position = EditorGUI.PrefixLabel(position, GUIUtility.GetControlID(FocusType.Passive), label); 17 | 18 | // Don't make child fields be indented 19 | int indent = EditorGUI.indentLevel; 20 | EditorGUI.indentLevel = 0; 21 | 22 | const int shift = 200; 23 | // Calculate rects 24 | Rect firstRect = new Rect(position.x, position.y, shift, position.height); 25 | Rect secondRect = new Rect(position.x + shift, position.y, position.width - shift, position.height); 26 | 27 | SerializedProperty typeProperty = property.FindPropertyRelative("m_type"); 28 | 29 | PathTypes t1 = (PathTypes) typeProperty.enumValueIndex; 30 | 31 | if (t1 == PathTypes.String) 32 | { 33 | SerializedProperty p = property.FindPropertyRelative("m_path"); 34 | Color c = GUI.color; 35 | if (string.IsNullOrEmpty(p.stringValue)) 36 | { 37 | GUI.color = Color.red; 38 | } 39 | 40 | EditorGUI.PropertyField(firstRect, p, GUIContent.none); 41 | GUI.color = c; 42 | } 43 | 44 | if (t1 == PathTypes.Scriptable) 45 | { 46 | SerializedProperty p = property.FindPropertyRelative("m_scriptablePath"); 47 | 48 | Color c = GUI.color; 49 | if (p.objectReferenceValue == null) 50 | { 51 | GUI.color = Color.red; 52 | } 53 | 54 | EditorGUI.PropertyField(firstRect, p, GUIContent.none); 55 | GUI.color = c; 56 | } 57 | 58 | EditorGUI.PropertyField(secondRect, typeProperty, GUIContent.none); 59 | 60 | // Set indent back to what it was 61 | EditorGUI.indentLevel = indent; 62 | 63 | EditorGUI.EndProperty(); 64 | } 65 | } 66 | } -------------------------------------------------------------------------------- /Editor/IO/Path/Core/PathPropertyDrawer.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 151f80b4087e48768a334f16f79fa43a 3 | timeCreated: 1617799443 -------------------------------------------------------------------------------- /Editor/IO/Path/Core/PathTypes.cs: -------------------------------------------------------------------------------- 1 | namespace UniTools.Build 2 | { 3 | public enum PathTypes : byte 4 | { 5 | String = 0, 6 | Scriptable 7 | } 8 | } -------------------------------------------------------------------------------- /Editor/IO/Path/Core/PathTypes.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 260ff968f0484a16a3a6a7e7f5c74ff6 3 | timeCreated: 1617799223 -------------------------------------------------------------------------------- /Editor/IO/Path/Core/ProjectPath.cs: -------------------------------------------------------------------------------- 1 | using System.IO; 2 | using UnityEngine; 3 | 4 | namespace UniTools.Build 5 | { 6 | /// 7 | /// The path value of the current Unity Project 8 | /// 9 | public static class ProjectPath 10 | { 11 | public static readonly string Value = Path.GetDirectoryName(Application.dataPath); 12 | } 13 | } -------------------------------------------------------------------------------- /Editor/IO/Path/Core/ProjectPath.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: ff05595f5d0f14cbab079b2247d4cc8f 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Editor/IO/Path/ScriptablePath.cs: -------------------------------------------------------------------------------- 1 | using UnityEngine; 2 | 3 | namespace UniTools.Build 4 | { 5 | [CreateAssetMenu( 6 | fileName = nameof(ScriptablePath), 7 | menuName = MenuPaths.IO + "Path" 8 | )] 9 | public sealed class ScriptablePath : BaseScriptablePath 10 | { 11 | [SerializeField] private string m_value = default; 12 | 13 | public string Value 14 | { 15 | set => m_value = value; 16 | } 17 | 18 | public override string ToString() 19 | { 20 | return m_value; 21 | } 22 | } 23 | } -------------------------------------------------------------------------------- /Editor/IO/Path/ScriptablePath.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: e8927cbe39d543e0ba598261b0518f11 3 | timeCreated: 1617798707 -------------------------------------------------------------------------------- /Editor/IO/Path/Steps.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 56a7bc886a4c4b8a9f107b681500c5db 3 | timeCreated: 1642666089 -------------------------------------------------------------------------------- /Editor/IO/Path/Steps/GenerateRandomPath.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.IO; 3 | using System.Threading.Tasks; 4 | using UnityEngine; 5 | 6 | namespace UniTools.Build 7 | { 8 | [CreateAssetMenu( 9 | fileName = nameof(GenerateRandomPath), 10 | menuName = MenuPaths.IO + nameof(GenerateRandomPath) 11 | )] 12 | public sealed class GenerateRandomPath : BuildStep 13 | { 14 | [SerializeField] private PathProperty m_initial = default; 15 | [SerializeField] private ScriptablePath m_result = default; 16 | 17 | public override async Task Execute() 18 | { 19 | m_result.Value = Path.Combine( 20 | m_initial.ToString(), 21 | Guid.NewGuid().ToString()); 22 | 23 | await Task.CompletedTask; 24 | } 25 | } 26 | } -------------------------------------------------------------------------------- /Editor/IO/Path/Steps/GenerateRandomPath.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 977d6f5c15765984dad96deb85fa97d6 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Editor/MenuPaths.cs: -------------------------------------------------------------------------------- 1 | namespace UniTools.Build 2 | { 3 | public static class MenuPaths 4 | { 5 | public const string Core = nameof(UniTools) + "/"; 6 | public const string IO = Steps + "IO/"; 7 | public const string Parameters = Core + "Parameters/"; 8 | 9 | public const string Steps = Core + "Steps/"; 10 | public const string Defines = Steps + "Defines/"; 11 | public const string Versioning = Steps + "Versioning/"; 12 | 13 | private const string Platforms = Steps + "Platforms/"; 14 | public const string Android = Platforms + "Android/"; 15 | public const string IOS = Platforms + "iOS/"; 16 | public const string Standalone = Platforms + "Standalone/"; 17 | public const string WebGL = Platforms + "WebGL/"; 18 | } 19 | } -------------------------------------------------------------------------------- /Editor/MenuPaths.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 91a4ada76cc1406db61b919e5854857a 3 | timeCreated: 1647956875 -------------------------------------------------------------------------------- /Editor/Platforms.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 7a82a722b55c64cbb847405ee916646f 3 | folderAsset: yes 4 | DefaultImporter: 5 | externalObjects: {} 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Editor/Platforms/Android.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 7a1d8c5a554cd4a83b99c718e6ff1854 3 | folderAsset: yes 4 | DefaultImporter: 5 | externalObjects: {} 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Editor/Platforms/Android/Build.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: c5c7b1421a3a94b11a9ebd04c38ee6f3 3 | timeCreated: 1609923471 -------------------------------------------------------------------------------- /Editor/Platforms/Android/Build/BuildAab.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Threading.Tasks; 3 | using UnityEditor; 4 | using UnityEditor.Build.Reporting; 5 | using UnityEngine; 6 | 7 | namespace UniTools.Build 8 | { 9 | [CreateAssetMenu( 10 | fileName = nameof(BuildAab), 11 | menuName = MenuPaths.Android + nameof(BuildAab) 12 | )] 13 | public sealed class BuildAab: UnityBuildStepWithOptions 14 | { 15 | public override BuildTarget Target => BuildTarget.Android; 16 | 17 | public override async Task Execute() 18 | { 19 | BuildPlayerOptions buildPlayerOptions = Options; 20 | EditorUserBuildSettings.buildAppBundle=true; 21 | EditorUserBuildSettings.androidBuildSystem = AndroidBuildSystem.Gradle; 22 | BuildReport report = UnityEditor.BuildPipeline.BuildPlayer(buildPlayerOptions); 23 | await Task.CompletedTask; 24 | 25 | BuildSummary summary = report.summary; 26 | if (summary.result == BuildResult.Failed) 27 | { 28 | throw new Exception($"{nameof(BuildPipeline)}: {name} Build failed!"); 29 | } 30 | } 31 | } 32 | } -------------------------------------------------------------------------------- /Editor/Platforms/Android/Build/BuildAab.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: ca76892c383c56349ab81c99d636205f 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Editor/Platforms/Android/Build/BuildApk.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Threading.Tasks; 3 | using UnityEditor; 4 | using UnityEditor.Build.Reporting; 5 | using UnityEngine; 6 | 7 | namespace UniTools.Build 8 | { 9 | [CreateAssetMenu( 10 | fileName = nameof(BuildApk), 11 | menuName = MenuPaths.Android + nameof(BuildApk) 12 | )] 13 | public sealed class BuildApk : UnityBuildStepWithOptions 14 | { 15 | public override BuildTarget Target => BuildTarget.Android; 16 | 17 | public override async Task Execute() 18 | { 19 | BuildPlayerOptions buildPlayerOptions = Options; 20 | EditorUserBuildSettings.buildAppBundle = false; 21 | EditorUserBuildSettings.androidBuildSystem = AndroidBuildSystem.Gradle; 22 | BuildReport report = UnityEditor.BuildPipeline.BuildPlayer(buildPlayerOptions); 23 | await Task.CompletedTask; 24 | 25 | BuildSummary summary = report.summary; 26 | if (summary.result == BuildResult.Failed) 27 | { 28 | throw new Exception($"{nameof(BuildPipeline)}: {name} Build failed!"); 29 | } 30 | } 31 | } 32 | } -------------------------------------------------------------------------------- /Editor/Platforms/Android/Build/BuildApk.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: a2aa453893820498da0d90d089d59c79 3 | timeCreated: 1609926258 -------------------------------------------------------------------------------- /Editor/Platforms/Android/CustomEditors.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 596c0d03cd54490fb7025a223d54ebf1 3 | timeCreated: 1623857299 -------------------------------------------------------------------------------- /Editor/Platforms/Android/CustomEditors/SetAliasEditor.cs: -------------------------------------------------------------------------------- 1 | using UnityEditor; 2 | 3 | namespace UniTools.Build 4 | { 5 | [CustomEditor(typeof(SetAlias))] 6 | public sealed class SetAliasEditor : Editor 7 | { 8 | private SerializedProperty m_password = default; 9 | private SerializedProperty m_alias = default; 10 | 11 | private bool m_showPassword = false; 12 | 13 | private void OnEnable() 14 | { 15 | m_password = serializedObject.FindProperty(nameof(m_password)); 16 | m_alias = serializedObject.FindProperty(nameof(m_alias)); 17 | } 18 | 19 | public override void OnInspectorGUI() 20 | { 21 | EditorGUILayout.BeginVertical(); 22 | { 23 | EditorGUILayout.PropertyField(m_alias); 24 | 25 | if (m_showPassword) 26 | { 27 | EditorGUILayout.PropertyField(m_password); 28 | } 29 | else 30 | { 31 | m_password.stringValue = EditorGUILayout.PasswordField("Password", m_password.stringValue); 32 | } 33 | 34 | m_showPassword = EditorGUILayout.Toggle("Show", m_showPassword); 35 | } 36 | EditorGUILayout.EndVertical(); 37 | 38 | serializedObject.ApplyModifiedProperties(); 39 | } 40 | } 41 | } -------------------------------------------------------------------------------- /Editor/Platforms/Android/CustomEditors/SetAliasEditor.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 5702f5990f4e47df8ddb8fb6e1ca2b0f 3 | timeCreated: 1624000051 -------------------------------------------------------------------------------- /Editor/Platforms/Android/CustomEditors/SetKeystorePasswordEditor.cs: -------------------------------------------------------------------------------- 1 | using UnityEditor; 2 | 3 | namespace UniTools.Build 4 | { 5 | [CustomEditor(typeof(SetKeystorePassword))] 6 | public sealed class SetKeystorePasswordEditor : Editor 7 | { 8 | private SerializedProperty m_password = default; 9 | private bool m_showPassword = false; 10 | 11 | private void OnEnable() 12 | { 13 | m_password = serializedObject.FindProperty(nameof(m_password)); 14 | } 15 | 16 | public override void OnInspectorGUI() 17 | { 18 | EditorGUILayout.BeginVertical(); 19 | { 20 | if (m_showPassword) 21 | { 22 | EditorGUILayout.PropertyField(m_password); 23 | } 24 | else 25 | { 26 | m_password.stringValue = EditorGUILayout.PasswordField("Password", m_password.stringValue); 27 | } 28 | 29 | m_showPassword = EditorGUILayout.Toggle("Show", m_showPassword); 30 | } 31 | EditorGUILayout.EndVertical(); 32 | 33 | serializedObject.ApplyModifiedProperties(); 34 | } 35 | } 36 | } -------------------------------------------------------------------------------- /Editor/Platforms/Android/CustomEditors/SetKeystorePasswordEditor.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: fe9403d2153243e6a96630abeac90f19 3 | timeCreated: 1623999587 -------------------------------------------------------------------------------- /Editor/Platforms/Android/Pre.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 01e4fe1ba76a470abbb3150823944079 3 | timeCreated: 1623854998 -------------------------------------------------------------------------------- /Editor/Platforms/Android/Pre/SetAlias.cs: -------------------------------------------------------------------------------- 1 | using System.Threading.Tasks; 2 | using UnityEditor; 3 | using UnityEditor.Build; 4 | using UnityEngine; 5 | 6 | namespace UniTools.Build 7 | { 8 | [CreateAssetMenu( 9 | fileName = nameof(SetAlias), 10 | menuName = MenuPaths.Android + nameof(SetAlias) 11 | )] 12 | public sealed class SetAlias : BuildStep 13 | { 14 | [SerializeField] private string m_alias = default; 15 | [SerializeField] private string m_password = default; 16 | 17 | [ContextMenu(nameof(Execute))] 18 | public override async Task Execute() 19 | { 20 | if (!PlayerSettings.Android.useCustomKeystore) 21 | { 22 | throw new BuildFailedException($"{nameof(SetAlias)}: failed due to using of the custom keystore is not selected!"); 23 | } 24 | 25 | PlayerSettings.Android.keyaliasName = m_alias; 26 | PlayerSettings.Android.keyaliasPass = m_password; 27 | PlayerSettings.keyaliasPass = m_password; 28 | AssetDatabase.Refresh(); 29 | AssetDatabase.SaveAssets(); 30 | 31 | await Task.CompletedTask; 32 | } 33 | } 34 | } -------------------------------------------------------------------------------- /Editor/Platforms/Android/Pre/SetAlias.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: f9385a8b732c486ea5404faf62c719ac 3 | timeCreated: 1623999459 -------------------------------------------------------------------------------- /Editor/Platforms/Android/Pre/SetDebugKeystore.cs: -------------------------------------------------------------------------------- 1 | using System.Threading.Tasks; 2 | using UnityEditor; 3 | using UnityEngine; 4 | 5 | namespace UniTools.Build 6 | { 7 | [CreateAssetMenu( 8 | fileName = nameof(SetDebugKeystore), 9 | menuName = MenuPaths.Android + nameof(SetDebugKeystore) 10 | )] 11 | public sealed class SetDebugKeystore : BuildStep 12 | { 13 | public override async Task Execute() 14 | { 15 | PlayerSettings.Android.useCustomKeystore = false; 16 | AssetDatabase.Refresh(); 17 | AssetDatabase.SaveAssets(); 18 | await Task.CompletedTask; 19 | } 20 | } 21 | } -------------------------------------------------------------------------------- /Editor/Platforms/Android/Pre/SetDebugKeystore.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 8071ed9f7ef14b29a9ee2c696b32d3f8 3 | timeCreated: 1623855360 -------------------------------------------------------------------------------- /Editor/Platforms/Android/Pre/SetKeystorePassword.cs: -------------------------------------------------------------------------------- 1 | using System.Threading.Tasks; 2 | using UnityEditor; 3 | using UnityEngine; 4 | 5 | namespace UniTools.Build 6 | { 7 | [CreateAssetMenu( 8 | fileName = nameof(SetKeystorePassword), 9 | menuName = MenuPaths.Android + nameof(SetKeystorePassword) 10 | )] 11 | public sealed class SetKeystorePassword : BuildStep 12 | { 13 | [SerializeField] private string m_password = default; 14 | 15 | [ContextMenu(nameof(Execute))] 16 | public override async Task Execute() 17 | { 18 | PlayerSettings.Android.useCustomKeystore = true; 19 | 20 | PlayerSettings.keystorePass = m_password; 21 | 22 | AssetDatabase.Refresh(); 23 | AssetDatabase.SaveAssets(); 24 | 25 | await Task.CompletedTask; 26 | } 27 | } 28 | } -------------------------------------------------------------------------------- /Editor/Platforms/Android/Pre/SetKeystorePassword.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: c29af46adc474aa38af7918484697a78 3 | timeCreated: 1623999345 -------------------------------------------------------------------------------- /Editor/Platforms/Standalone.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 5c6f336998b884651bd2a50955682130 3 | folderAsset: yes 4 | DefaultImporter: 5 | externalObjects: {} 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Editor/Platforms/Standalone/Build.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: b3ef8b90f38874b33adf4d36117c217c 3 | folderAsset: yes 4 | DefaultImporter: 5 | externalObjects: {} 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Editor/Platforms/Standalone/Build/BuildMacOS.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Threading.Tasks; 3 | using UnityEditor; 4 | using UnityEditor.Build.Reporting; 5 | using UnityEngine; 6 | #if UNITY_EDITOR_OSX 7 | #if UNITY_2022_2_OR_NEWER 8 | using UnityEditor.Build; 9 | #endif 10 | using UnityEditor.OSXStandalone; 11 | #endif 12 | 13 | namespace UniTools.Build 14 | { 15 | [CreateAssetMenu( 16 | fileName = nameof(BuildMacOS), 17 | menuName = MenuPaths.Standalone + nameof(BuildMacOS) 18 | )] 19 | public sealed class BuildMacOS : UnityBuildStepWithOptions 20 | { 21 | #if UNITY_EDITOR_OSX 22 | 23 | #if UNITY_2022_2_OR_NEWER 24 | [SerializeField] private OSArchitecture m_architecture = default; 25 | #endif 26 | [SerializeField] private bool m_createXcodeProject = false; 27 | #endif 28 | public override BuildTarget Target => BuildTarget.StandaloneOSX; 29 | 30 | public override async Task Execute() 31 | { 32 | #if UNITY_EDITOR_OSX 33 | 34 | #if UNITY_2022_2_OR_NEWER 35 | UserBuildSettings.architecture = m_architecture; 36 | #endif 37 | UserBuildSettings.createXcodeProject = m_createXcodeProject; 38 | #endif 39 | AssetDatabase.Refresh(); 40 | AssetDatabase.SaveAssets(); 41 | 42 | BuildReport report = UnityEditor.BuildPipeline.BuildPlayer(Options); 43 | 44 | await Task.CompletedTask; 45 | 46 | BuildSummary summary = report.summary; 47 | if (summary.result == BuildResult.Failed) 48 | { 49 | throw new Exception($"{nameof(BuildPipeline)}: {name} Build failed!"); 50 | } 51 | } 52 | } 53 | } -------------------------------------------------------------------------------- /Editor/Platforms/Standalone/Build/BuildMacOS.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: c128854671084438fa339442d5efd552 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Editor/Platforms/Standalone/Build/BuildWindows.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Threading.Tasks; 3 | using UnityEditor; 4 | using UnityEditor.Build.Reporting; 5 | using UnityEngine; 6 | 7 | namespace UniTools.Build 8 | { 9 | [CreateAssetMenu( 10 | fileName = nameof(BuildWindows), 11 | menuName = MenuPaths.Standalone + nameof(BuildWindows) 12 | )] 13 | public sealed class BuildWindows : UnityBuildStepWithOptions 14 | { 15 | public override BuildTarget Target => BuildTarget.StandaloneWindows; 16 | 17 | public override async Task Execute() 18 | { 19 | BuildReport report = UnityEditor.BuildPipeline.BuildPlayer(Options); 20 | 21 | await Task.CompletedTask; 22 | 23 | BuildSummary summary = report.summary; 24 | if (summary.result == BuildResult.Failed) 25 | { 26 | throw new Exception($"{nameof(BuildPipeline)}: {name} Build failed!"); 27 | } 28 | } 29 | } 30 | } -------------------------------------------------------------------------------- /Editor/Platforms/Standalone/Build/BuildWindows.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 2979090d763e4374a3ad3b8ecea43ec0 3 | timeCreated: 1635759928 -------------------------------------------------------------------------------- /Editor/Platforms/Standalone/Build/BuildWindows64.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Threading.Tasks; 3 | using UnityEditor; 4 | using UnityEditor.Build.Reporting; 5 | using UnityEngine; 6 | 7 | namespace UniTools.Build 8 | { 9 | [CreateAssetMenu( 10 | fileName = nameof(BuildWindows64), 11 | menuName = MenuPaths.Standalone + nameof(BuildWindows64) 12 | )] 13 | public sealed class BuildWindows64 : UnityBuildStepWithOptions 14 | { 15 | public override BuildTarget Target => BuildTarget.StandaloneWindows64; 16 | 17 | public override async Task Execute() 18 | { 19 | BuildReport report = UnityEditor.BuildPipeline.BuildPlayer(Options); 20 | 21 | await Task.CompletedTask; 22 | 23 | BuildSummary summary = report.summary; 24 | if (summary.result == BuildResult.Failed) 25 | { 26 | throw new Exception($"{nameof(BuildPipeline)}: {name} Build failed!"); 27 | } 28 | } 29 | } 30 | } -------------------------------------------------------------------------------- /Editor/Platforms/Standalone/Build/BuildWindows64.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: fb638c448bd4492f8287b4a16bf3c0d8 3 | timeCreated: 1635761135 -------------------------------------------------------------------------------- /Editor/Platforms/WebGL.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 009b56e10194e468dba87b3f06c6a4a6 3 | folderAsset: yes 4 | DefaultImporter: 5 | externalObjects: {} 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Editor/Platforms/WebGL/BuildWebGL.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Threading.Tasks; 3 | using UnityEditor; 4 | using UnityEditor.Build; 5 | using UnityEditor.Build.Reporting; 6 | using UnityEngine; 7 | #if UNITY_WEBGL && !(UNITY_2022_1_OR_NEWER) 8 | using UnityEditor.WebGL; 9 | #endif 10 | 11 | namespace UniTools.Build 12 | { 13 | [CreateAssetMenu( 14 | fileName = nameof(BuildWebGL), 15 | menuName = MenuPaths.WebGL + nameof(BuildWebGL) 16 | )] 17 | public sealed class BuildWebGL : UnityBuildStepWithOptions 18 | { 19 | #if UNITY_WEBGL && !(UNITY_2022_1_OR_NEWER) 20 | [SerializeField] private CodeOptimization m_codeOptimization = CodeOptimization.Size; 21 | #endif 22 | 23 | 24 | #if UNITY_2021_2_OR_NEWER 25 | [SerializeField] private Il2CppCodeGeneration m_IL2CPPCodeGeneration = Il2CppCodeGeneration.OptimizeSize; 26 | #endif 27 | 28 | [SerializeField] private WebGLExceptionSupport m_exceptionSupport = WebGLExceptionSupport.None; 29 | [SerializeField] private WebGLCompressionFormat m_compressionFormat = default; 30 | [SerializeField] private bool m_nameFilesAsHashes = true; 31 | 32 | [SerializeField] private bool m_dataCaching = false; 33 | 34 | #if UNITY_2021_2_OR_NEWER 35 | [SerializeField] private WebGLDebugSymbolMode m_debugSymbolMode = WebGLDebugSymbolMode.Off; 36 | #endif 37 | #if UNITY_2020_1_OR_NEWER 38 | [SerializeField] private bool m_decompressionFallback = false; 39 | #endif 40 | public override BuildTarget Target => BuildTarget.WebGL; 41 | 42 | public override async Task Execute() 43 | { 44 | AssetDatabase.Refresh(); 45 | AssetDatabase.SaveAssets(); 46 | 47 | PlayerSettings.WebGL.exceptionSupport = m_exceptionSupport; 48 | PlayerSettings.WebGL.compressionFormat = m_compressionFormat; 49 | PlayerSettings.WebGL.nameFilesAsHashes = m_nameFilesAsHashes; 50 | PlayerSettings.WebGL.dataCaching = m_dataCaching; 51 | #if UNITY_2021_2_OR_NEWER 52 | PlayerSettings.WebGL.debugSymbolMode = m_debugSymbolMode; 53 | #endif 54 | 55 | #if UNITY_2020_1_OR_NEWER 56 | PlayerSettings.WebGL.decompressionFallback = m_decompressionFallback; 57 | #endif 58 | 59 | #if UNITY_WEBGL && !(UNITY_2022_1_OR_NEWER) 60 | EditorUserBuildSettings.SetPlatformSettings(UnityEditor.BuildPipeline.GetBuildTargetName(BuildTarget.WebGL), "CodeOptimization", m_codeOptimization.ToString()); 61 | #else 62 | EditorUserBuildSettings.SetPlatformSettings(UnityEditor.BuildPipeline.GetBuildTargetName(BuildTarget.WebGL), "CodeOptimization", "Size"); 63 | #endif 64 | 65 | #if UNITY_2022_1_OR_NEWER 66 | PlayerSettings.SetIl2CppCodeGeneration(NamedBuildTarget.WebGL, m_IL2CPPCodeGeneration); 67 | #elif UNITY_2021_2_OR_NEWER 68 | EditorUserBuildSettings.il2CppCodeGeneration = m_IL2CPPCodeGeneration; 69 | #endif 70 | 71 | AssetDatabase.Refresh(); 72 | AssetDatabase.SaveAssets(); 73 | 74 | BuildReport report = UnityEditor.BuildPipeline.BuildPlayer(Options); 75 | 76 | await Task.CompletedTask; 77 | 78 | BuildSummary summary = report.summary; 79 | if (summary.result == BuildResult.Failed) 80 | { 81 | throw new Exception($"{nameof(BuildPipeline)}: {name} Build failed!"); 82 | } 83 | } 84 | } 85 | } -------------------------------------------------------------------------------- /Editor/Platforms/WebGL/BuildWebGL.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 8fd0035a436404215ac1cfebb1a3388b 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Editor/Platforms/iOS.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: bca9641c01ea24e4187951d476effeaa 3 | folderAsset: yes 4 | DefaultImporter: 5 | externalObjects: {} 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Editor/Platforms/iOS/CustomEditors.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: a24c61ccab3e4c139e4af38be08c6269 3 | timeCreated: 1617285735 -------------------------------------------------------------------------------- /Editor/Platforms/iOS/CustomEditors/Archive.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 518b38463e264427a6d446096ba7a98f 3 | timeCreated: 1617368415 -------------------------------------------------------------------------------- /Editor/Platforms/iOS/CustomEditors/Archive/ArchiveEditor.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: fa392cff172543c0a23bbd36729647f4 3 | timeCreated: 1617286062 -------------------------------------------------------------------------------- /Editor/Platforms/iOS/CustomEditors/Distribute.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 90656137232740e48b1ab5b27f474c84 3 | timeCreated: 1617368391 -------------------------------------------------------------------------------- /Editor/Platforms/iOS/CustomEditors/Distribute/DistributeIosApplicationStepEditor.cs: -------------------------------------------------------------------------------- 1 | using UnityEditor; 2 | using UnityEngine; 3 | 4 | namespace UniTools.Build 5 | { 6 | public abstract class DistributeIosApplicationStepEditor : Editor 7 | { 8 | private SerializedProperty m_teamId = default; 9 | private SerializedProperty m_provisioningProfileName = default; 10 | private SerializedProperty m_bundleIdentifier = default; 11 | private SerializedProperty m_uploadBitcode = default; 12 | private SerializedProperty m_uploadSymbols = default; 13 | private SerializedProperty m_pathToXCodeProject = default; 14 | private SerializedProperty m_archivePath = default; 15 | private SerializedProperty m_outputPath = default; 16 | 17 | protected virtual void OnEnable() 18 | { 19 | m_teamId = serializedObject.FindProperty(nameof(m_teamId)); 20 | m_provisioningProfileName = serializedObject.FindProperty(nameof(m_provisioningProfileName)); 21 | m_bundleIdentifier = serializedObject.FindProperty(nameof(m_bundleIdentifier)); 22 | m_uploadBitcode = serializedObject.FindProperty(nameof(m_uploadBitcode)); 23 | m_uploadSymbols = serializedObject.FindProperty(nameof(m_uploadSymbols)); 24 | m_pathToXCodeProject = serializedObject.FindProperty(nameof(m_pathToXCodeProject)); 25 | m_archivePath = serializedObject.FindProperty(nameof(m_archivePath)); 26 | m_outputPath = serializedObject.FindProperty(nameof(m_outputPath)); 27 | } 28 | 29 | public override void OnInspectorGUI() 30 | { 31 | EditorGUILayout.PropertyField(m_pathToXCodeProject); 32 | EditorGUILayout.PropertyField(m_archivePath); 33 | EditorGUILayout.PropertyField(m_outputPath); 34 | 35 | bool useCurrentBundle = false; 36 | EditorGUILayout.BeginHorizontal(); 37 | { 38 | EditorGUILayout.PropertyField(m_bundleIdentifier); 39 | useCurrentBundle = GUILayout.Button("From Player Settings"); 40 | } 41 | EditorGUILayout.EndHorizontal(); 42 | 43 | bool parseTeamId = false; 44 | bool parseProvisioningProfileName = false; 45 | EditorGUILayout.BeginVertical("box"); 46 | { 47 | EditorGUILayout.HelpBox("Team Id and Provisioning Profile can be parsed from the Provisioning Profile file.", MessageType.Info); 48 | 49 | EditorGUILayout.BeginHorizontal(); 50 | { 51 | EditorGUILayout.PropertyField(m_teamId); 52 | parseTeamId = GUILayout.Button("From file"); 53 | } 54 | EditorGUILayout.EndHorizontal(); 55 | 56 | EditorGUILayout.BeginHorizontal(); 57 | { 58 | EditorGUILayout.PropertyField(m_provisioningProfileName); 59 | parseProvisioningProfileName = GUILayout.Button("From file"); 60 | } 61 | EditorGUILayout.EndHorizontal(); 62 | } 63 | EditorGUILayout.EndVertical(); 64 | 65 | EditorGUILayout.PropertyField(m_uploadBitcode); 66 | EditorGUILayout.PropertyField(m_uploadSymbols); 67 | 68 | if (useCurrentBundle) 69 | { 70 | m_bundleIdentifier.stringValue = PlayerSettings.applicationIdentifier; 71 | } 72 | 73 | if (parseTeamId) 74 | { 75 | string path = EditorUtility.OpenFilePanel("Test", Application.dataPath, "mobileprovision"); 76 | ProvisioningProfile pp = ProvisioningProfile.Load(path); 77 | m_teamId.stringValue = pp.TeamIdentifier; 78 | } 79 | 80 | if (parseProvisioningProfileName) 81 | { 82 | string path = EditorUtility.OpenFilePanel("Test", Application.dataPath, "mobileprovision"); 83 | ProvisioningProfile pp = ProvisioningProfile.Load(path); 84 | m_provisioningProfileName.stringValue = pp.Name; 85 | } 86 | 87 | serializedObject.ApplyModifiedProperties(); 88 | } 89 | } 90 | } -------------------------------------------------------------------------------- /Editor/Platforms/iOS/CustomEditors/Distribute/DistributeIosApplicationStepEditor.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: a3ee45f023704fdcad7812c40329b156 3 | timeCreated: 1617368175 -------------------------------------------------------------------------------- /Editor/Platforms/iOS/CustomEditors/Distribute/ExportIpaEditor.cs: -------------------------------------------------------------------------------- 1 | using UnityEditor; 2 | 3 | namespace UniTools.Build 4 | { 5 | [CustomEditor(typeof(ExportIpa))] 6 | public sealed class ExportIpaEditor : DistributeIosApplicationStepEditor 7 | { 8 | private SerializedProperty m_method = default; 9 | 10 | protected override void OnEnable() 11 | { 12 | base.OnEnable(); 13 | 14 | m_method = serializedObject.FindProperty(nameof(m_method)); 15 | } 16 | 17 | public override void OnInspectorGUI() 18 | { 19 | base.OnInspectorGUI(); 20 | 21 | EditorGUILayout.PropertyField(m_method); 22 | 23 | serializedObject.ApplyModifiedProperties(); 24 | } 25 | } 26 | } -------------------------------------------------------------------------------- /Editor/Platforms/iOS/CustomEditors/Distribute/ExportIpaEditor.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: cc147d393c354eecb3fb1b0d00e15768 3 | timeCreated: 1617366263 -------------------------------------------------------------------------------- /Editor/Platforms/iOS/CustomEditors/Distribute/UploadToAppStoreEditor.cs: -------------------------------------------------------------------------------- 1 | using UnityEditor; 2 | 3 | namespace UniTools.Build 4 | { 5 | [CustomEditor(typeof(UploadToAppStore))] 6 | public sealed class UploadToAppStoreEditor : DistributeIosApplicationStepEditor 7 | { 8 | } 9 | } -------------------------------------------------------------------------------- /Editor/Platforms/iOS/CustomEditors/Distribute/UploadToAppStoreEditor.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 187371f16063499ca46b3f4d7d3eceb4 3 | timeCreated: 1617625445 -------------------------------------------------------------------------------- /Editor/Platforms/iOS/CustomEditors/Plist.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: c0eb955f0f374bd8b59d7baef7a62279 3 | timeCreated: 1617693785 -------------------------------------------------------------------------------- /Editor/Platforms/iOS/CustomEditors/Plist/ModifyInfoPlistEditor.cs: -------------------------------------------------------------------------------- 1 | using UnityEditor; 2 | 3 | namespace UniTools.Build 4 | { 5 | [CustomEditor(typeof(ModifyInfoPlist))] 6 | public sealed class ModifyInfoPlistEditor : Editor 7 | { 8 | public override void OnInspectorGUI() 9 | { 10 | EditorGUILayout.HelpBox("Values below will be added to the root dictionary", MessageType.Info); 11 | base.OnInspectorGUI(); 12 | } 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /Editor/Platforms/iOS/CustomEditors/Plist/ModifyInfoPlistEditor.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 4567324874824f9c9e444eb714947260 3 | timeCreated: 1617693799 -------------------------------------------------------------------------------- /Editor/Platforms/iOS/CustomEditors/Signing.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: dfb3a9e9d906495fb536e28ef8f1d0ec 3 | timeCreated: 1674558139 -------------------------------------------------------------------------------- /Editor/Platforms/iOS/CustomEditors/Signing/SetManualProvisionProfileEditor.cs: -------------------------------------------------------------------------------- 1 | using UnityEditor; 2 | using UnityEngine; 3 | 4 | namespace UniTools.Build 5 | { 6 | [CustomEditor(typeof(SetManualProvisionProfile))] 7 | public sealed class SetManualProvisionProfileEditor : Editor 8 | { 9 | private SerializedProperty m_name = default; 10 | private SerializedProperty m_id = default; 11 | private SerializedProperty m_type = default; 12 | 13 | private void OnEnable() 14 | { 15 | m_name = serializedObject.FindProperty(nameof(m_name)); 16 | m_id = serializedObject.FindProperty(nameof(m_id)); 17 | m_type = serializedObject.FindProperty(nameof(m_type)); 18 | } 19 | 20 | public override void OnInspectorGUI() 21 | { 22 | bool load = false; 23 | 24 | EditorGUILayout.BeginVertical("box"); 25 | { 26 | EditorGUILayout.BeginVertical(); 27 | { 28 | EditorGUILayout.HelpBox("You can parse Name and Id from the Provisioning Profile file", MessageType.Info); 29 | load = GUILayout.Button("From file"); 30 | } 31 | EditorGUILayout.EndVertical(); 32 | EditorGUILayout.PropertyField(m_name); 33 | EditorGUILayout.PropertyField(m_id); 34 | EditorGUILayout.PropertyField(m_type); 35 | } 36 | EditorGUILayout.EndVertical(); 37 | 38 | if (load) 39 | { 40 | string path = EditorUtility.OpenFilePanel("Test", Application.dataPath, "mobileprovision"); 41 | 42 | ProvisioningProfile pp = ProvisioningProfile.Load(path); 43 | 44 | m_id.stringValue = pp.Uuid; 45 | m_name.stringValue = pp.Name; 46 | } 47 | 48 | serializedObject.ApplyModifiedProperties(); 49 | } 50 | } 51 | } -------------------------------------------------------------------------------- /Editor/Platforms/iOS/CustomEditors/Signing/SetManualProvisionProfileEditor.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 1126d0c9e749446ca6bda9e3ae75d2cf 3 | timeCreated: 1674559043 -------------------------------------------------------------------------------- /Editor/Platforms/iOS/CustomEditors/Signing/SetTeamIdEditor.cs: -------------------------------------------------------------------------------- 1 | using UnityEditor; 2 | using UnityEngine; 3 | 4 | namespace UniTools.Build 5 | { 6 | [CustomEditor(typeof(SetTeamId))] 7 | public sealed class SetTeamIdEditor : Editor 8 | { 9 | private SerializedProperty m_teamId = default; 10 | 11 | private void OnEnable() 12 | { 13 | m_teamId = serializedObject.FindProperty(nameof(m_teamId)); 14 | } 15 | 16 | public override void OnInspectorGUI() 17 | { 18 | bool load = false; 19 | 20 | EditorGUILayout.BeginVertical("box"); 21 | { 22 | EditorGUILayout.BeginVertical(); 23 | { 24 | EditorGUILayout.HelpBox("You can parse Team Id from the Provisioning Profile file", MessageType.Info); 25 | load = GUILayout.Button("From file"); 26 | } 27 | EditorGUILayout.EndVertical(); 28 | EditorGUILayout.PropertyField(m_teamId); 29 | } 30 | EditorGUILayout.EndVertical(); 31 | 32 | if (load) 33 | { 34 | string path = EditorUtility.OpenFilePanel("Test", Application.dataPath, "mobileprovision"); 35 | 36 | ProvisioningProfile pp = ProvisioningProfile.Load(path); 37 | 38 | m_teamId.stringValue = pp.TeamIdentifier; 39 | } 40 | 41 | serializedObject.ApplyModifiedProperties(); 42 | } 43 | } 44 | } -------------------------------------------------------------------------------- /Editor/Platforms/iOS/CustomEditors/Signing/SetTeamIdEditor.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 68b3c31e9212409e8b153fc14bb0ca8a 3 | timeCreated: 1674558122 -------------------------------------------------------------------------------- /Editor/Platforms/iOS/Models.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: dbcd0172a6b64123b9ce2a9a715f23b1 3 | timeCreated: 1617285867 -------------------------------------------------------------------------------- /Editor/Platforms/iOS/Models/ProvisioningProfile.cs: -------------------------------------------------------------------------------- 1 | #if UNITY_IOS 2 | using System.Xml; 3 | using System.IO; 4 | using System.Text.RegularExpressions; 5 | #endif 6 | 7 | namespace UniTools.Build 8 | { 9 | public sealed class ProvisioningProfile 10 | { 11 | public static readonly ProvisioningProfile Empty = new ProvisioningProfile 12 | { 13 | Uuid = string.Empty, 14 | Name = string.Empty, 15 | TeamIdentifier = string.Empty 16 | }; 17 | 18 | public string Uuid { get; private set; } 19 | 20 | public string Name { get; private set; } 21 | public string TeamIdentifier { get; private set; } 22 | 23 | private ProvisioningProfile() 24 | { 25 | } 26 | 27 | public static ProvisioningProfile Load(string pathToFile) 28 | { 29 | if (string.IsNullOrWhiteSpace(pathToFile)) 30 | { 31 | return Empty; 32 | } 33 | 34 | #if UNITY_IOS 35 | const string patternPlist = ""; 36 | 37 | ProvisioningProfile profile = new ProvisioningProfile(); 38 | string input = File.ReadAllText(pathToFile); 39 | 40 | Match match = Regex.Match(input, patternPlist, RegexOptions.Singleline); 41 | 42 | string xml = match.ToString(); 43 | XmlDocument xmlDoc = new XmlDocument(); 44 | xmlDoc.LoadXml(xml); 45 | 46 | foreach (XmlNode parentNode in xmlDoc.DocumentElement) 47 | { 48 | for (int i = 0; i < parentNode.ChildNodes.Count; i++) 49 | { 50 | if (parentNode.ChildNodes[i].InnerText == "UUID") 51 | { 52 | profile.Uuid = parentNode.ChildNodes[i + 1].InnerText; 53 | } 54 | 55 | if (parentNode.ChildNodes[i].InnerText == "Name") 56 | { 57 | profile.Name = parentNode.ChildNodes[i + 1].InnerText; 58 | } 59 | 60 | if (parentNode.ChildNodes[i].InnerText == "TeamIdentifier") 61 | { 62 | profile.TeamIdentifier = parentNode.ChildNodes[i + 1].InnerText; 63 | } 64 | } 65 | } 66 | 67 | return profile; 68 | #else 69 | throw new System.Exception($"{nameof(ProvisioningProfile)}: unsupported platform."); 70 | #endif 71 | } 72 | } 73 | } -------------------------------------------------------------------------------- /Editor/Platforms/iOS/Models/ProvisioningProfile.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 11ed1b61f71b4e69a38418bca60a09f6 3 | timeCreated: 1617285881 -------------------------------------------------------------------------------- /Editor/Platforms/iOS/Steps.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 828d5ec53a1114e928e06456f16119be 3 | timeCreated: 1609923443 -------------------------------------------------------------------------------- /Editor/Platforms/iOS/Steps/Archive.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 09abf506edf442f99b2ae4b633bf84a2 3 | timeCreated: 1617369939 -------------------------------------------------------------------------------- /Editor/Platforms/iOS/Steps/Archive/Archive.cs: -------------------------------------------------------------------------------- 1 | using System.Threading.Tasks; 2 | using UnityEngine; 3 | 4 | namespace UniTools.Build 5 | { 6 | public abstract class Archive : BuildStep 7 | { 8 | [SerializeField] private PathProperty m_projectPath = new PathProperty("Unity-iPhone.xcodeproj"); 9 | [SerializeField] private PathProperty m_outputPath = new PathProperty("Unity-iPhone.xcarchive"); 10 | [SerializeField] private string m_scheme = "Unity-iPhone"; 11 | [SerializeField] private string m_destination = "generic/platform=iOS"; 12 | [SerializeField] private string m_teamId = string.Empty; 13 | [SerializeField] private bool m_useModernBuildSystem = true; 14 | [SerializeField] private bool m_enableBitcode = false; 15 | [SerializeField] private bool m_overrideProvisioningProfile = false; 16 | [SerializeField] private string m_provisioningProfileUuid = string.Empty; 17 | [SerializeField, Tooltip("Arguments that needs to be added, but not in the list above")] private string m_extraArgs = string.Empty; 18 | 19 | protected abstract string CommandStart { get; } 20 | 21 | public override async Task Execute() 22 | { 23 | await Task.CompletedTask; 24 | 25 | XCodeBuild build = Cli.Tool(); 26 | string command = 27 | " archive" + 28 | $" -{CommandStart} {m_projectPath}" + 29 | $" -scheme \"{m_scheme}\"" + 30 | $" -archivePath {m_outputPath}"; 31 | 32 | if (!string.IsNullOrWhiteSpace(m_destination)) 33 | { 34 | command += $" -destination \"{m_destination}\""; 35 | } 36 | 37 | if (!string.IsNullOrWhiteSpace(m_extraArgs)) 38 | { 39 | command += $" {m_extraArgs} "; 40 | } 41 | 42 | command += $" DEVELOPMENT_TEAM={m_teamId}"; 43 | 44 | if (m_overrideProvisioningProfile) 45 | { 46 | command += $" PROVISIONING_PROFILE={m_provisioningProfileUuid}"; 47 | } 48 | 49 | if (m_enableBitcode) 50 | { 51 | command += " ENABLE_BITCODE=YES"; 52 | } 53 | else 54 | { 55 | command += " ENABLE_BITCODE=NO"; 56 | } 57 | 58 | if (m_useModernBuildSystem) 59 | { 60 | command += " -UseModernBuildSystem=YES"; 61 | } 62 | else 63 | { 64 | command += " -UseModernBuildSystem=NO"; 65 | } 66 | 67 | ToolResult result = build.Execute(command, ProjectPath.Value); 68 | if (result.ExitCode != 0) 69 | { 70 | throw new BuildStepFailedException($"{nameof(Archive)}: Failed! {result.ToString()}"); 71 | } 72 | } 73 | } 74 | } -------------------------------------------------------------------------------- /Editor/Platforms/iOS/Steps/Archive/Archive.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: f777feb01dc764f07a42b31ef39a8680 3 | timeCreated: 1609857157 -------------------------------------------------------------------------------- /Editor/Platforms/iOS/Steps/Archive/ArchiveProject.cs: -------------------------------------------------------------------------------- 1 | using UnityEngine; 2 | 3 | namespace UniTools.Build 4 | { 5 | /// 6 | /// Creates iOS archive from the xCode project using CLI tools 7 | /// 8 | [CreateAssetMenu( 9 | fileName = nameof(ArchiveProject), 10 | menuName = MenuPaths.IOS + nameof(ArchiveProject) 11 | )] 12 | public sealed class ArchiveProject : Archive 13 | { 14 | protected override string CommandStart => "project"; 15 | } 16 | } -------------------------------------------------------------------------------- /Editor/Platforms/iOS/Steps/Archive/ArchiveProject.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: f7faa3302e1532c4cb385c74ba6a86ef 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Editor/Platforms/iOS/Steps/Archive/ArchiveWorkspace.cs: -------------------------------------------------------------------------------- 1 | using UnityEngine; 2 | 3 | namespace UniTools.Build 4 | { 5 | /// 6 | /// Creates iOS archive from the xCode workspace using CLI tools 7 | /// 8 | [CreateAssetMenu( 9 | fileName = nameof(ArchiveWorkspace), 10 | menuName = MenuPaths.IOS + nameof(ArchiveWorkspace) 11 | )] 12 | public sealed class ArchiveWorkspace : Archive 13 | { 14 | protected override string CommandStart => "workspace"; 15 | } 16 | } -------------------------------------------------------------------------------- /Editor/Platforms/iOS/Steps/Archive/ArchiveWorkspace.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 4b5ecf8cc24b319438268f81fb52174e 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Editor/Platforms/iOS/Steps/Build.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 8b0e6f9fe4f6c466c926b68da676f82a 3 | timeCreated: 1609923471 -------------------------------------------------------------------------------- /Editor/Platforms/iOS/Steps/Build/BuildXCode.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Threading.Tasks; 3 | using UnityEditor; 4 | using UnityEditor.Build.Reporting; 5 | using UnityEngine; 6 | 7 | namespace UniTools.Build 8 | { 9 | [CreateAssetMenu( 10 | fileName = nameof(BuildXCode), 11 | menuName = MenuPaths.IOS + nameof(BuildXCode) 12 | )] 13 | public sealed class BuildXCode : UnityBuildStepWithOptions 14 | { 15 | [SerializeField] private bool m_symlinkUnityLibraries = true; 16 | [SerializeField] private bool m_tryAppend = true; 17 | 18 | public override BuildTarget Target => BuildTarget.iOS; 19 | 20 | public override async Task Execute() 21 | { 22 | BuildPlayerOptions buildPlayerOptions = Options; 23 | 24 | if (m_symlinkUnityLibraries) 25 | { 26 | #if UNITY_2021_2_OR_NEWER 27 | buildPlayerOptions.options |= BuildOptions.SymlinkSources; 28 | #else 29 | buildPlayerOptions.options |= BuildOptions.SymlinkLibraries; 30 | #endif 31 | } 32 | 33 | if (m_tryAppend) 34 | { 35 | switch (UnityEditor.BuildPipeline.BuildCanBeAppended(buildPlayerOptions.target, buildPlayerOptions.locationPathName)) 36 | { 37 | case CanAppendBuild.Unsupported: 38 | throw new InvalidOperationException($"The build target {buildPlayerOptions.target} does not support build appending."); 39 | case CanAppendBuild.No: 40 | Debug.Log($"{nameof(BuildXCode)}: the build can not be appended, it will be replaced."); 41 | 42 | break; 43 | case CanAppendBuild.Yes: 44 | buildPlayerOptions.options |= BuildOptions.AcceptExternalModificationsToPlayer; 45 | 46 | break; 47 | default: 48 | throw new ArgumentOutOfRangeException(); 49 | } 50 | } 51 | 52 | BuildReport report = UnityEditor.BuildPipeline.BuildPlayer(buildPlayerOptions); 53 | 54 | await Task.CompletedTask; 55 | 56 | BuildSummary summary = report.summary; 57 | if (summary.result == BuildResult.Failed) 58 | { 59 | throw new Exception($"{nameof(BuildPipeline)}: {name} Build failed!"); 60 | } 61 | } 62 | } 63 | } -------------------------------------------------------------------------------- /Editor/Platforms/iOS/Steps/Build/BuildXCode.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 5e07cbf39332b457197ec6ce5cb1be56 3 | timeCreated: 1609916178 -------------------------------------------------------------------------------- /Editor/Platforms/iOS/Steps/Distribute.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 1ab0d1df56274e63af04ad29ccfb8bbf 3 | timeCreated: 1617368365 -------------------------------------------------------------------------------- /Editor/Platforms/iOS/Steps/Distribute/DistributeIosApplicationStep.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.IO; 3 | using UnityEngine; 4 | #if UNITY_IOS 5 | using UnityEditor.iOS.Xcode; 6 | #endif 7 | 8 | namespace UniTools.Build 9 | { 10 | public abstract class DistributeIosApplicationStep : BuildStep 11 | { 12 | [SerializeField, Tooltip("Can be found at Apple Developer Console")] private string m_teamId = string.Empty; 13 | #pragma warning disable 14 | //Pragma used to avoid miss values on another platform. Can't not be closed #if UNITY_IOS 15 | [SerializeField] private string m_provisioningProfileName = default; 16 | #pragma warning restore 17 | [SerializeField] private string m_bundleIdentifier = default; 18 | [SerializeField] private bool m_uploadBitcode = false; 19 | [SerializeField] private bool m_uploadSymbols = false; 20 | [SerializeField] private PathProperty m_pathToXCodeProject = new PathProperty("Builds/xCode"); 21 | [SerializeField] private PathProperty m_archivePath = new PathProperty("Unity-iPhone.xcarchive"); 22 | [SerializeField, Tooltip("Must be a folder")] private PathProperty m_outputPath = new PathProperty("Builds"); 23 | 24 | protected string ExportOptionsPath 25 | { 26 | get 27 | { 28 | const string fileName = "ExportOptions.plist"; 29 | 30 | return Path.Combine(m_pathToXCodeProject.ToString(), fileName); 31 | 32 | #if !UNITY_IOS 33 | throw new Exception($"{nameof(DistributeIosApplicationStep)}: unsupported platform for {m_bundleIdentifier}, {m_uploadBitcode}, {m_uploadSymbols}"); 34 | #endif 35 | } 36 | } 37 | 38 | protected string ArchivePath => m_archivePath.ToString(); 39 | protected string OutputPath => m_outputPath.ToString(); 40 | 41 | #if UNITY_IOS 42 | protected PlistDocument CreateExportOptions() 43 | { 44 | PlistDocument plist = new PlistDocument(); 45 | PlistElementDict rootDict = plist.root; 46 | 47 | rootDict.SetBoolean("generateAppStoreInformation", false); 48 | 49 | PlistElementDict provisioningProfiles = rootDict.CreateDict("provisioningProfiles"); 50 | provisioningProfiles.SetString(m_bundleIdentifier, m_provisioningProfileName); 51 | rootDict.SetString("signingCertificate", "Apple Distribution"); 52 | rootDict.SetString("signingStyle", "manual"); 53 | rootDict.SetString("teamID", m_teamId); 54 | rootDict.SetBoolean("stripSwiftSymbols", true); 55 | rootDict.SetBoolean("uploadBitcode", m_uploadBitcode); 56 | rootDict.SetBoolean("uploadSymbols", m_uploadSymbols); 57 | 58 | return plist; 59 | } 60 | #endif 61 | } 62 | } -------------------------------------------------------------------------------- /Editor/Platforms/iOS/Steps/Distribute/DistributeIosApplicationStep.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 3e36d603190f49d1a890251aa5dbac17 3 | timeCreated: 1617364275 -------------------------------------------------------------------------------- /Editor/Platforms/iOS/Steps/Distribute/ExportIpa.cs: -------------------------------------------------------------------------------- 1 | using System.Threading.Tasks; 2 | using UnityEngine; 3 | #if UNITY_IOS 4 | using System.IO; 5 | using UnityEditor.iOS.Xcode; 6 | 7 | #else 8 | using System; 9 | #endif 10 | 11 | namespace UniTools.Build 12 | { 13 | [CreateAssetMenu( 14 | fileName = nameof(ExportIpa), 15 | menuName = MenuPaths.IOS + nameof(ExportIpa) 16 | )] 17 | public sealed class ExportIpa : DistributeIosApplicationStep 18 | { 19 | #pragma warning disable 20 | //Pragma used to avoid miss values on another platform. Can't not be closed #if UNITY_IOS 21 | [SerializeField, Tooltip("The method must correspond to the provision profile")] private ExportMethods m_method = ExportMethods.AdHoc; 22 | #pragma warning restore 23 | 24 | public override async Task Execute() 25 | { 26 | await Task.CompletedTask; 27 | #if UNITY_IOS 28 | PlistDocument exportOptions = CreateExportOptions(); 29 | 30 | if (m_method == ExportMethods.AdHoc) 31 | { 32 | exportOptions.root.SetString("method", "ad-hoc"); 33 | } 34 | else if (m_method == ExportMethods.AppStore) 35 | { 36 | exportOptions.root.SetString("method", "app-store"); 37 | } 38 | else 39 | { 40 | throw new BuildStepFailedException($"{nameof(Archive)}: Failed due to unsupported method {m_method}"); 41 | } 42 | 43 | File.WriteAllText(ExportOptionsPath, exportOptions.WriteToString()); 44 | 45 | XCodeBuild build = Cli.Tool(); 46 | 47 | string command = 48 | $"-exportArchive " + 49 | $" -archivePath {ArchivePath}" + 50 | $" -exportOptionsPlist {ExportOptionsPath}" + 51 | $" -exportPath {OutputPath}"; 52 | 53 | ToolResult result = build.Execute(command, ProjectPath.Value); 54 | if (result.ExitCode != 0) 55 | { 56 | throw new BuildStepFailedException($"{nameof(Archive)}: Failed! {result.ToString()}"); 57 | } 58 | #else 59 | throw new Exception($"{nameof(ExportIpa)}: unsupported platform!"); 60 | #endif 61 | } 62 | } 63 | } -------------------------------------------------------------------------------- /Editor/Platforms/iOS/Steps/Distribute/ExportIpa.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 1718898d2a414c12bdebd0b67f0fb585 3 | timeCreated: 1617366010 -------------------------------------------------------------------------------- /Editor/Platforms/iOS/Steps/Distribute/ExportMethods.cs: -------------------------------------------------------------------------------- 1 | namespace UniTools.Build 2 | { 3 | public enum ExportMethods : byte 4 | { 5 | AdHoc = 0, 6 | AppStore 7 | } 8 | } -------------------------------------------------------------------------------- /Editor/Platforms/iOS/Steps/Distribute/ExportMethods.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 6c53105b65964a56a28b90e7dfff88c7 3 | timeCreated: 1617371438 -------------------------------------------------------------------------------- /Editor/Platforms/iOS/Steps/Distribute/UploadToAppStore.cs: -------------------------------------------------------------------------------- 1 | using System.Threading.Tasks; 2 | using UnityEngine; 3 | #if UNITY_IOS 4 | using System.IO; 5 | using UnityEditor.iOS.Xcode; 6 | 7 | #else 8 | using System; 9 | #endif 10 | 11 | namespace UniTools.Build 12 | { 13 | [CreateAssetMenu( 14 | fileName = nameof(UploadToAppStore), 15 | menuName = MenuPaths.IOS + nameof(UploadToAppStore) 16 | )] 17 | public sealed class UploadToAppStore : DistributeIosApplicationStep 18 | { 19 | public override async Task Execute() 20 | { 21 | await Task.CompletedTask; 22 | 23 | #if UNITY_IOS 24 | PlistDocument exportOptions = CreateExportOptions(); 25 | 26 | exportOptions.root.SetString("method", "app-store"); 27 | exportOptions.root.SetString("destination", "upload"); 28 | 29 | File.WriteAllText(ExportOptionsPath, exportOptions.WriteToString()); 30 | 31 | XCodeBuild build = Cli.Tool(); 32 | 33 | string command = 34 | $"-exportArchive " + 35 | $" -archivePath {ArchivePath}" + 36 | $" -exportOptionsPlist {ExportOptionsPath}" + 37 | $" -exportPath {OutputPath}"; 38 | 39 | ToolResult result = build.Execute(command, ProjectPath.Value); 40 | if (result.ExitCode != 0) 41 | { 42 | throw new BuildStepFailedException($"{nameof(Archive)}: Failed! {result.ToString()}"); 43 | } 44 | #else 45 | throw new Exception($"{nameof(ExportIpa)}: unsupported platform!"); 46 | #endif 47 | } 48 | } 49 | } -------------------------------------------------------------------------------- /Editor/Platforms/iOS/Steps/Distribute/UploadToAppStore.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 29af928fe22b4ea7aa15b9a52b97f896 3 | timeCreated: 1617625320 -------------------------------------------------------------------------------- /Editor/Platforms/iOS/Steps/Plist.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 0c7de655cc4e4c2783ac3cd0986b9958 3 | timeCreated: 1617629374 -------------------------------------------------------------------------------- /Editor/Platforms/iOS/Steps/Plist/Elements.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 8f051eee5d2d47ef9fe566d3fb54bfc1 3 | timeCreated: 1617629542 -------------------------------------------------------------------------------- /Editor/Platforms/iOS/Steps/Plist/Elements/BoolPlistElement.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | #if UNITY_IOS 3 | using UnityEditor.iOS.Xcode; 4 | #endif 5 | namespace UniTools.Build 6 | { 7 | [Serializable] 8 | public sealed class BoolPlistElement : SerializablePlistElement 9 | { 10 | #if UNITY_IOS 11 | public override void AddTo(PlistElementDict plistElementDict) 12 | { 13 | plistElementDict.SetBoolean(Key, Value); 14 | } 15 | #endif 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /Editor/Platforms/iOS/Steps/Plist/Elements/BoolPlistElement.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 139ec733dbf9497b8b869d7cb78ed529 3 | timeCreated: 1617629531 -------------------------------------------------------------------------------- /Editor/Platforms/iOS/Steps/Plist/Elements/FloatPlistElement.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | #if UNITY_IOS 4 | using UnityEditor.iOS.Xcode; 5 | #endif 6 | namespace UniTools.Build 7 | { 8 | [Serializable] 9 | public sealed class FloatPlistElement : SerializablePlistElement 10 | { 11 | #if UNITY_IOS 12 | public override void AddTo(PlistElementDict plistElementDict) 13 | { 14 | plistElementDict.SetReal(Key, Value); 15 | } 16 | #endif 17 | } 18 | } -------------------------------------------------------------------------------- /Editor/Platforms/iOS/Steps/Plist/Elements/FloatPlistElement.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 393b40a9702842a6a65a6d2556986ff7 3 | timeCreated: 1617691876 -------------------------------------------------------------------------------- /Editor/Platforms/iOS/Steps/Plist/Elements/IPlistElement.cs: -------------------------------------------------------------------------------- 1 | #if UNITY_IOS 2 | using UnityEditor.iOS.Xcode; 3 | #endif 4 | namespace UniTools.Build 5 | { 6 | public interface IPlistElement 7 | { 8 | void AddTo( 9 | #if UNITY_IOS 10 | PlistElementDict plistElementDict 11 | #endif 12 | ); 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /Editor/Platforms/iOS/Steps/Plist/Elements/IPlistElement.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 3b118021b02e4aaa8c508b430b63b498 3 | timeCreated: 1617693464 -------------------------------------------------------------------------------- /Editor/Platforms/iOS/Steps/Plist/Elements/IntPlistElement.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | #if UNITY_IOS 4 | using UnityEditor.iOS.Xcode; 5 | #endif 6 | namespace UniTools.Build 7 | { 8 | [Serializable] 9 | public sealed class IntPlistElement : SerializablePlistElement 10 | { 11 | #if UNITY_IOS 12 | public override void AddTo(PlistElementDict plistElementDict) 13 | { 14 | plistElementDict.SetInteger(Key, Value); 15 | } 16 | #endif 17 | } 18 | } -------------------------------------------------------------------------------- /Editor/Platforms/iOS/Steps/Plist/Elements/IntPlistElement.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 8bcf8cc70b2d400faa96346c8965955f 3 | timeCreated: 1617692021 -------------------------------------------------------------------------------- /Editor/Platforms/iOS/Steps/Plist/Elements/SerializablePlistElement.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using UnityEngine; 3 | #if UNITY_IOS 4 | using UnityEditor.iOS.Xcode; 5 | #endif 6 | 7 | namespace UniTools.Build 8 | { 9 | [Serializable] 10 | public abstract class SerializablePlistElement 11 | : IPlistElement 12 | { 13 | [SerializeField] protected string Key; 14 | [SerializeField] protected TValue Value; 15 | 16 | #if UNITY_IOS 17 | public abstract void AddTo(PlistElementDict plistElementDict); 18 | #else 19 | public void AddTo() 20 | { 21 | throw new Exception($"{nameof(SerializablePlistElement)}:Unsupported platform for {Key} and {Value}"); 22 | } 23 | 24 | #endif 25 | } 26 | } -------------------------------------------------------------------------------- /Editor/Platforms/iOS/Steps/Plist/Elements/SerializablePlistElement.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: d31628c31e6044989f193520100f1740 3 | timeCreated: 1617629464 -------------------------------------------------------------------------------- /Editor/Platforms/iOS/Steps/Plist/Elements/StringPlistElement.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | #if UNITY_IOS 3 | using UnityEditor.iOS.Xcode; 4 | #endif 5 | 6 | namespace UniTools.Build 7 | { 8 | [Serializable] 9 | public sealed class StringPlistElement : SerializablePlistElement 10 | { 11 | #if UNITY_IOS 12 | 13 | public override void AddTo(PlistElementDict plistElementDict) 14 | { 15 | plistElementDict.SetString(Key, Value); 16 | } 17 | #endif 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /Editor/Platforms/iOS/Steps/Plist/Elements/StringPlistElement.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 38d6736c18c84af8a7f3af08176db5da 3 | timeCreated: 1617691711 -------------------------------------------------------------------------------- /Editor/Platforms/iOS/Steps/Plist/ModifyInfoPlist.cs: -------------------------------------------------------------------------------- 1 | #if UNITY_IOS 2 | using System.Collections.Generic; 3 | using System.IO; 4 | using UnityEditor.iOS.Xcode; 5 | #else 6 | using System; 7 | #endif 8 | using System.Threading.Tasks; 9 | using UniTools.Build; 10 | using UnityEngine; 11 | 12 | namespace UniTools.Build 13 | { 14 | [CreateAssetMenu( 15 | fileName = nameof(ModifyInfoPlist), 16 | menuName = MenuPaths.IOS + nameof(ModifyInfoPlist) 17 | )] 18 | public sealed class ModifyInfoPlist : BuildStep 19 | { 20 | [SerializeField] private PathProperty m_pathToXCodeProject = default; 21 | [SerializeField] private BoolPlistElement[] m_bool = default; 22 | [SerializeField] private FloatPlistElement[] m_float = default; 23 | [SerializeField] private IntPlistElement[] m_int = default; 24 | [SerializeField] private StringPlistElement[] m_string = default; 25 | 26 | public override async Task Execute() 27 | { 28 | await Task.CompletedTask; 29 | 30 | #if UNITY_IOS 31 | List elements = new List(); 32 | if (m_bool != null) 33 | { 34 | elements.AddRange(m_bool); 35 | } 36 | 37 | if (m_float != null) 38 | { 39 | elements.AddRange(m_float); 40 | } 41 | 42 | if (m_int != null) 43 | { 44 | elements.AddRange(m_int); 45 | } 46 | 47 | if (m_string != null) 48 | { 49 | elements.AddRange(m_string); 50 | } 51 | 52 | string plistPath = Path.Combine(m_pathToXCodeProject.ToString(), "Info.plist"); 53 | PlistDocument plist = new PlistDocument(); 54 | plist.ReadFromString(File.ReadAllText(plistPath)); 55 | foreach (IPlistElement element in elements) 56 | { 57 | element.AddTo(plist.root); 58 | } 59 | 60 | File.WriteAllText(plistPath, plist.WriteToString()); 61 | #else 62 | throw new Exception($"{nameof(ModifyInfoPlist)}: unsupported platform for {m_bool}, {m_float}, {m_int}, {m_string}, {m_pathToXCodeProject}"); 63 | #endif 64 | } 65 | } 66 | } -------------------------------------------------------------------------------- /Editor/Platforms/iOS/Steps/Plist/ModifyInfoPlist.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: aef348dabd744e6eaaf55afc28559ae8 3 | timeCreated: 1617628988 -------------------------------------------------------------------------------- /Editor/Platforms/iOS/Steps/Signing.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 6c0ebdef104d40f29d94332f9144fca2 3 | timeCreated: 1674553606 -------------------------------------------------------------------------------- /Editor/Platforms/iOS/Steps/Signing/SetAutomaticSigning.cs: -------------------------------------------------------------------------------- 1 | using System.Threading.Tasks; 2 | using UnityEditor; 3 | using UnityEngine; 4 | 5 | namespace UniTools.Build 6 | { 7 | /// 8 | /// Enable automatic signing in the PlayerSettings.iOS 9 | /// 10 | [CreateAssetMenu( 11 | fileName = nameof(SetAutomaticSigning), 12 | menuName = MenuPaths.IOS + nameof(SetAutomaticSigning) 13 | )] 14 | public sealed class SetAutomaticSigning : BuildStep 15 | { 16 | public override async Task Execute() 17 | { 18 | PlayerSettings.iOS.iOSManualProvisioningProfileID = string.Empty; 19 | PlayerSettings.iOS.iOSManualProvisioningProfileType = ProvisioningProfileType.Automatic; 20 | PlayerSettings.iOS.appleEnableAutomaticSigning = true; 21 | 22 | AssetDatabase.Refresh(); 23 | AssetDatabase.SaveAssets(); 24 | 25 | await Task.CompletedTask; 26 | } 27 | } 28 | } -------------------------------------------------------------------------------- /Editor/Platforms/iOS/Steps/Signing/SetAutomaticSigning.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 5691cc515d1543f395d2e7b094fccbe6 3 | timeCreated: 1674553855 -------------------------------------------------------------------------------- /Editor/Platforms/iOS/Steps/Signing/SetManualProvisionProfile.cs: -------------------------------------------------------------------------------- 1 | using System.Threading.Tasks; 2 | using UnityEditor; 3 | using UnityEngine; 4 | 5 | namespace UniTools.Build 6 | { 7 | [CreateAssetMenu( 8 | fileName = nameof(SetManualProvisionProfile), 9 | menuName = MenuPaths.IOS + nameof(SetManualProvisionProfile) 10 | )] 11 | public sealed class SetManualProvisionProfile : BuildStep 12 | { 13 | [SerializeField] private string m_name = string.Empty; 14 | [SerializeField] private string m_id = string.Empty; 15 | [SerializeField] private ProvisioningProfileType m_type = ProvisioningProfileType.Automatic; 16 | 17 | public override async Task Execute() 18 | { 19 | Debug.Log($"Set ProvisioningProfile {m_name} with id {m_id} to the PlayerSettings.iOS"); 20 | 21 | PlayerSettings.iOS.appleEnableAutomaticSigning = false; 22 | 23 | //TODO Get them from file 24 | PlayerSettings.iOS.iOSManualProvisioningProfileID = m_id; 25 | PlayerSettings.iOS.iOSManualProvisioningProfileType = m_type; 26 | 27 | AssetDatabase.Refresh(); 28 | AssetDatabase.SaveAssets(); 29 | 30 | await Task.CompletedTask; 31 | } 32 | } 33 | } -------------------------------------------------------------------------------- /Editor/Platforms/iOS/Steps/Signing/SetManualProvisionProfile.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: e84cb1a33af1e4d149cdc72ecf63b027 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Editor/Platforms/iOS/Steps/Signing/SetTeamId.cs: -------------------------------------------------------------------------------- 1 | using System.Threading.Tasks; 2 | using UnityEditor; 3 | using UnityEngine; 4 | 5 | namespace UniTools.Build 6 | { 7 | /// 8 | /// Set iOS team id in the PlayerSettings.iOS 9 | /// 10 | [CreateAssetMenu( 11 | fileName = nameof(SetTeamId), 12 | menuName = MenuPaths.IOS + nameof(SetTeamId) 13 | )] 14 | public sealed class SetTeamId : BuildStep 15 | { 16 | [SerializeField] private string m_teamId = default; 17 | 18 | public override async Task Execute() 19 | { 20 | PlayerSettings.iOS.appleDeveloperTeamID = m_teamId; 21 | 22 | AssetDatabase.Refresh(); 23 | AssetDatabase.SaveAssets(); 24 | 25 | await Task.CompletedTask; 26 | } 27 | } 28 | } -------------------------------------------------------------------------------- /Editor/Platforms/iOS/Steps/Signing/SetTeamId.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 7bc3f0abfe454335affba45b5675eb82 3 | timeCreated: 1674553671 -------------------------------------------------------------------------------- /Editor/Styles.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 64667b2471ca45d3bb7f5077d8f1e866 3 | timeCreated: 1678457997 -------------------------------------------------------------------------------- /Editor/Styles/Styles.cs: -------------------------------------------------------------------------------- 1 | using UnityEditor; 2 | using UnityEngine; 3 | 4 | namespace UniTools.Build 5 | { 6 | public static class Styles 7 | { 8 | public static readonly GUIStyle H1 = CreateStyle(16, FontStyle.Bold, new Color(0.7333333f, 0.7333333f, 0.7333333f)); 9 | 10 | public static readonly GUIStyle H2_Foldout = CustomFoldout(14, FontStyle.Italic, Color.white); 11 | 12 | private static GUIStyle CreateStyle(int size, FontStyle fontStyle, Color textColor) 13 | { 14 | // this is setting up all kinds of styles for any given field: 15 | GUIStyle style = new GUIStyle(); 16 | style.fontSize = size; 17 | style.fontStyle = fontStyle; 18 | style.normal.textColor = textColor; 19 | 20 | return style; 21 | } 22 | 23 | private static GUIStyle CustomFoldout(int size, FontStyle fontStyle, Color textColor) 24 | { 25 | GUIStyle style = new GUIStyle(EditorStyles.foldout); 26 | 27 | style.fontSize = size; 28 | style.fontStyle = fontStyle; 29 | style.normal.textColor = textColor; 30 | style.active.textColor = textColor; 31 | style.focused.textColor = textColor; 32 | 33 | return style; 34 | } 35 | } 36 | } -------------------------------------------------------------------------------- /Editor/Styles/Styles.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: fa7846872b564e28a65bae668311a134 3 | timeCreated: 1678458005 -------------------------------------------------------------------------------- /Editor/UniTools.Build.asmdef: -------------------------------------------------------------------------------- 1 | { 2 | "name": "UniTools.Build", 3 | "rootNamespace": "UniTools.Build", 4 | "references": [], 5 | "includePlatforms": [ 6 | "Editor" 7 | ], 8 | "excludePlatforms": [], 9 | "allowUnsafeCode": false, 10 | "overrideReferences": false, 11 | "precompiledReferences": [], 12 | "autoReferenced": true, 13 | "defineConstraints": [], 14 | "versionDefines": [], 15 | "noEngineReferences": false 16 | } -------------------------------------------------------------------------------- /Editor/UniTools.Build.asmdef.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: d94495eb8c16444dea063a3605506bac 3 | AssemblyDefinitionImporter: 4 | externalObjects: {} 5 | userData: 6 | assetBundleName: 7 | assetBundleVariant: 8 | -------------------------------------------------------------------------------- /Editor/UnityEnvironment.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: dcee2ab9e28d42b8b4694f1c7209ac50 3 | timeCreated: 1589519024 -------------------------------------------------------------------------------- /Editor/UnityEnvironment/CustomEditors.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: fd2d5824472e4f6d9775f7aaedf52b67 3 | timeCreated: 1643982040 -------------------------------------------------------------------------------- /Editor/UnityEnvironment/CustomEditors/UnityEnvironmentVariableEditorPresenter.cs: -------------------------------------------------------------------------------- 1 | using UnityEditor; 2 | 3 | namespace UniTools.Build 4 | { 5 | public sealed class UnityEnvironmentVariableEditorPresenter 6 | { 7 | public void Draw(UnityEnvironmentVariableModel model) 8 | { 9 | EditorGUILayout.BeginHorizontal(); 10 | { 11 | EditorGUILayout.LabelField(model.Name); 12 | EditorGUILayout.LabelField(model.Value); 13 | } 14 | EditorGUILayout.EndHorizontal(); 15 | } 16 | } 17 | } -------------------------------------------------------------------------------- /Editor/UnityEnvironment/CustomEditors/UnityEnvironmentVariableEditorPresenter.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 1465a0b2f60e41ad8857afbceecaf4e4 3 | timeCreated: 1589519344 -------------------------------------------------------------------------------- /Editor/UnityEnvironment/CustomEditors/UnityEnvironmentVariablesHeaderPresenter.cs: -------------------------------------------------------------------------------- 1 | using UnityEditor; 2 | 3 | namespace UniTools.Build 4 | { 5 | public sealed class UnityEnvironmentVariablesHeaderPresenter 6 | { 7 | public void Draw() 8 | { 9 | EditorGUILayout.BeginHorizontal(); 10 | { 11 | EditorGUILayout.LabelField("Name"); 12 | EditorGUILayout.LabelField("Value"); 13 | } 14 | EditorGUILayout.EndHorizontal(); 15 | } 16 | } 17 | } -------------------------------------------------------------------------------- /Editor/UnityEnvironment/CustomEditors/UnityEnvironmentVariablesHeaderPresenter.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 3d825a10f6e8481492042b5bd8fa163d 3 | timeCreated: 1589522195 -------------------------------------------------------------------------------- /Editor/UnityEnvironment/CustomEditors/UnityEnvironmentWindow.cs: -------------------------------------------------------------------------------- 1 | using System.Collections.Generic; 2 | using System.Linq; 3 | using UnityEditor; 4 | using UnityEngine; 5 | 6 | namespace UniTools.Build 7 | { 8 | public sealed class UnityEnvironmentWindow : EditorWindow 9 | { 10 | private static readonly UnityEnvironmentVariablesHeaderPresenter Header = new UnityEnvironmentVariablesHeaderPresenter(); 11 | private readonly List m_presenters = new List(); 12 | private Vector2 scrollPos = default; 13 | 14 | [MenuItem("Tools/CLI/" + nameof(UnityEnvironment))] 15 | public static void Open() 16 | { 17 | UnityEnvironmentWindow w = GetWindow(); 18 | w.name = nameof(UnityEnvironment); 19 | w.Show(); 20 | } 21 | 22 | public void OnFocus() 23 | { 24 | IEnumerable variables = UnityEnvironment.Variables; 25 | int count = variables.Count() - m_presenters.Count; 26 | if (count > 0) 27 | { 28 | for (int i = 0; i < count; i++) 29 | { 30 | m_presenters.Add(new UnityEnvironmentVariableEditorPresenter()); 31 | } 32 | } 33 | } 34 | 35 | public void OnGUI() 36 | { 37 | Header.Draw(); 38 | IEnumerable variables = UnityEnvironment.Variables; 39 | 40 | scrollPos = EditorGUILayout.BeginScrollView(scrollPos); 41 | 42 | for (int i = 0; i < variables.Count(); i++) 43 | { 44 | m_presenters[i].Draw(variables.ElementAt(i)); 45 | } 46 | 47 | EditorGUILayout.EndScrollView(); 48 | } 49 | } 50 | } -------------------------------------------------------------------------------- /Editor/UnityEnvironment/CustomEditors/UnityEnvironmentWindow.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 2dc9cddec50574aca935970598af6ecd 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Editor/UnityEnvironment/Runtime.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: d5fea931955c4800afa3c630c0691e6b 3 | timeCreated: 1589518979 -------------------------------------------------------------------------------- /Editor/UnityEnvironment/Runtime/PathVariableAttribute.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | //NOTE Example of usage 4 | // [assembly: PathVariable("/usr/bin")] 5 | // [assembly: PathVariable("/usr/local/share/dotnet")] 6 | 7 | namespace UniTools.Build 8 | { 9 | [AttributeUsage(AttributeTargets.Assembly, AllowMultiple = true)] 10 | public sealed class PathVariableAttribute : Attribute 11 | { 12 | public readonly string Value; 13 | 14 | public PathVariableAttribute(string value) 15 | { 16 | Value = value; 17 | } 18 | 19 | public override string ToString() 20 | { 21 | return $"{nameof(PathVariableAttribute)}: {Value}"; 22 | } 23 | } 24 | } -------------------------------------------------------------------------------- /Editor/UnityEnvironment/Runtime/PathVariableAttribute.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: dd21dc00d1bc4f108f36f3107b6fdb1d 3 | timeCreated: 1609265652 -------------------------------------------------------------------------------- /Editor/UnityEnvironment/Runtime/UnityEnvironment.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections; 3 | using System.Collections.Generic; 4 | using System.Linq; 5 | 6 | namespace UniTools.Build 7 | { 8 | public static class UnityEnvironment 9 | { 10 | private static List m_variables = null; 11 | 12 | static UnityEnvironment() 13 | { 14 | List declared = ReflectionHelper.Find().ToList(); 15 | 16 | foreach (PathVariableAttribute attribute in declared) 17 | { 18 | ModifyPath(attribute.Value); 19 | } 20 | } 21 | 22 | public static IEnumerable Variables 23 | { 24 | get 25 | { 26 | if (m_variables == null) 27 | { 28 | m_variables = new List(); 29 | foreach (DictionaryEntry entry in Environment.GetEnvironmentVariables()) 30 | { 31 | m_variables.Add(new UnityEnvironmentVariableModel(entry.Key.ToString(), entry.Value.ToString())); 32 | } 33 | } 34 | 35 | return m_variables; 36 | } 37 | } 38 | 39 | public static UnityEnvironmentVariableModel Get(string name) 40 | { 41 | return Variables.FirstOrDefault(v => v.Name.Equals(name)); 42 | } 43 | 44 | private static void ModifyPath(string newValue) 45 | { 46 | const string pathName = "PATH"; 47 | 48 | string path = Environment.GetEnvironmentVariable(pathName); 49 | if (path.Contains(newValue)) 50 | { 51 | return; 52 | } 53 | 54 | #if UNITY_EDITOR_OSX 55 | Environment.SetEnvironmentVariable(pathName, $"{path}:{newValue}"); 56 | #elif UNITY_EDITOR_WIN 57 | Environment.SetEnvironmentVariable(pathName, $"{path}{newValue}"); 58 | #endif 59 | m_variables = null; 60 | 61 | } 62 | } 63 | } -------------------------------------------------------------------------------- /Editor/UnityEnvironment/Runtime/UnityEnvironment.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 1d27be75a3f145bd8a468738b0567e05 3 | timeCreated: 1589518990 -------------------------------------------------------------------------------- /Editor/UnityEnvironment/Runtime/UnityEnvironmentVariableModel.cs: -------------------------------------------------------------------------------- 1 | namespace UniTools.Build 2 | { 3 | public sealed class UnityEnvironmentVariableModel 4 | { 5 | public string Name { get; } 6 | 7 | public string Value { get; } 8 | 9 | public UnityEnvironmentVariableModel(string name, string value) 10 | { 11 | Name = name; 12 | Value = value; 13 | } 14 | 15 | public override string ToString() 16 | { 17 | return $"{nameof(UnityEnvironmentVariableModel)}: {nameof(Name)}:{Name},{nameof(Value)}:{Value}"; 18 | } 19 | } 20 | } -------------------------------------------------------------------------------- /Editor/UnityEnvironment/Runtime/UnityEnvironmentVariableModel.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: b1cef9f37b26453e80386c424d9a3811 3 | timeCreated: 1589519255 -------------------------------------------------------------------------------- /Editor/Versioning.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: f2c4c80ab3fa445ea9a043e237dde06f 3 | folderAsset: yes 4 | DefaultImporter: 5 | externalObjects: {} 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Editor/Versioning/Semantic.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 36ac0480c851648a1b277d2ae00dbc10 3 | folderAsset: yes 4 | DefaultImporter: 5 | externalObjects: {} 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Editor/Versioning/Semantic/Exceptions.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 70d30093bdfe4ac69be03d9f9384f6ee 3 | timeCreated: 1617187566 -------------------------------------------------------------------------------- /Editor/Versioning/Semantic/Exceptions/VersionIsNotSemanticException.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace UniTools.Build 4 | { 5 | public sealed class VersionIsNotSemanticException : Exception 6 | { 7 | public VersionIsNotSemanticException(string message) : base(message) 8 | { 9 | } 10 | } 11 | } -------------------------------------------------------------------------------- /Editor/Versioning/Semantic/Exceptions/VersionIsNotSemanticException.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: fe3b469866a747508abd4a7a9c1d1f60 3 | timeCreated: 1617187613 -------------------------------------------------------------------------------- /Editor/Versioning/Semantic/Steps.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 28610af6006b4291b0ee58fba674d521 3 | timeCreated: 1617187505 -------------------------------------------------------------------------------- /Editor/Versioning/Semantic/Steps/Pre.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 4036c5b7891d4bd783c75c470b66fbe5 3 | timeCreated: 1617186899 -------------------------------------------------------------------------------- /Editor/Versioning/Semantic/Steps/Pre/BumpSemanticBuildValue.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Threading.Tasks; 3 | using UnityEngine; 4 | 5 | namespace UniTools.Build 6 | { 7 | [CreateAssetMenu( 8 | fileName = nameof(BumpSemanticBuildValue), 9 | menuName = MenuPaths.Versioning + nameof(BumpSemanticBuildValue) 10 | )] 11 | public sealed class BumpSemanticBuildValue : IncrementSemanticVersionStep 12 | { 13 | public override async Task Execute() 14 | { 15 | Version v = Load(); 16 | Save(v.Major, v.Minor, v.Build + (int)Increment, v.Revision); 17 | await Task.CompletedTask; 18 | } 19 | } 20 | } -------------------------------------------------------------------------------- /Editor/Versioning/Semantic/Steps/Pre/BumpSemanticBuildValue.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 7bb972be7fc94591a3699dfaebb070d6 3 | timeCreated: 1617186950 -------------------------------------------------------------------------------- /Editor/Versioning/Semantic/Steps/Pre/BumpSemanticMajorValue.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Threading.Tasks; 3 | using UnityEngine; 4 | 5 | namespace UniTools.Build 6 | { 7 | [CreateAssetMenu( 8 | fileName = nameof(BumpSemanticMajorValue), 9 | menuName = MenuPaths.Versioning + nameof(BumpSemanticMajorValue) 10 | )] 11 | public sealed class BumpSemanticMajorValue : IncrementSemanticVersionStep 12 | { 13 | public override async Task Execute() 14 | { 15 | Version v = Load(); 16 | Save(v.Major + (int)Increment, v.Minor, v.Build, v.Revision); 17 | await Task.CompletedTask; 18 | } 19 | } 20 | } -------------------------------------------------------------------------------- /Editor/Versioning/Semantic/Steps/Pre/BumpSemanticMajorValue.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: f441b4c518e842c7b0109ba4e5e5e443 3 | timeCreated: 1617195485 -------------------------------------------------------------------------------- /Editor/Versioning/Semantic/Steps/Pre/BumpSemanticMinorValue.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Threading.Tasks; 3 | using UnityEngine; 4 | 5 | namespace UniTools.Build 6 | { 7 | [CreateAssetMenu( 8 | fileName = nameof(BumpSemanticMinorValue), 9 | menuName = MenuPaths.Versioning + nameof(BumpSemanticMinorValue) 10 | )] 11 | public sealed class BumpSemanticMinorValue : IncrementSemanticVersionStep 12 | { 13 | public override async Task Execute() 14 | { 15 | Version v = Load(); 16 | Save(v.Major, v.Minor + (int)Increment, v.Build, v.Revision); 17 | await Task.CompletedTask; 18 | } 19 | } 20 | } -------------------------------------------------------------------------------- /Editor/Versioning/Semantic/Steps/Pre/BumpSemanticMinorValue.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 182fb1196aa44e4380914f860e064804 3 | timeCreated: 1617195433 -------------------------------------------------------------------------------- /Editor/Versioning/Semantic/Steps/Pre/BumpSemanticRevisionValue.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Threading.Tasks; 3 | using UnityEngine; 4 | 5 | namespace UniTools.Build 6 | { 7 | [CreateAssetMenu( 8 | fileName = nameof(BumpSemanticRevisionValue), 9 | menuName = MenuPaths.Versioning + nameof(BumpSemanticRevisionValue) 10 | )] 11 | public sealed class BumpSemanticRevisionValue : IncrementSemanticVersionStep 12 | { 13 | public override async Task Execute() 14 | { 15 | Version v = Load(); 16 | Save(v.Major, v.Minor, v.Build, v.Revision + (int)Increment); 17 | await Task.CompletedTask; 18 | } 19 | } 20 | } -------------------------------------------------------------------------------- /Editor/Versioning/Semantic/Steps/Pre/BumpSemanticRevisionValue.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 2e8309cda2a74cf7ab5fc657d498165f 3 | timeCreated: 1617190580 -------------------------------------------------------------------------------- /Editor/Versioning/Semantic/Steps/Pre/ChangeSemanticVersionStep.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using UnityEditor; 3 | 4 | namespace UniTools.Build 5 | { 6 | public abstract class ChangeSemanticVersionStep : BuildStep 7 | { 8 | protected Version Load() 9 | { 10 | if (Version.TryParse(PlayerSettings.bundleVersion, out Version version)) 11 | { 12 | return version; 13 | } 14 | 15 | throw new VersionIsNotSemanticException($"Invalid version format in {nameof(PlayerSettings)}! Current is version {PlayerSettings.bundleVersion} is not semantic!"); 16 | } 17 | 18 | protected void Save(int major, int minor, int build, int revision) 19 | { 20 | if (build == -1) 21 | { 22 | PlayerSettings.bundleVersion = 23 | $"{major.ToString()}.{minor.ToString()}"; 24 | } 25 | else if (revision == -1) 26 | { 27 | PlayerSettings.bundleVersion = 28 | $"{major.ToString()}.{minor.ToString()}.{build.ToString()}"; 29 | } 30 | else 31 | { 32 | PlayerSettings.bundleVersion = 33 | $"{major.ToString()}.{minor.ToString()}.{build.ToString()}.{revision.ToString()}"; 34 | } 35 | 36 | AssetDatabase.Refresh(); 37 | AssetDatabase.SaveAssets(); 38 | } 39 | } 40 | } -------------------------------------------------------------------------------- /Editor/Versioning/Semantic/Steps/Pre/ChangeSemanticVersionStep.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: ecd28793c917417cb47c746c3045b2ef 3 | timeCreated: 1617187958 -------------------------------------------------------------------------------- /Editor/Versioning/Semantic/Steps/Pre/IncrementSemanticVersionStep.cs: -------------------------------------------------------------------------------- 1 | using UnityEngine; 2 | 3 | namespace UniTools.Build 4 | { 5 | public abstract class IncrementSemanticVersionStep : ChangeSemanticVersionStep 6 | { 7 | [SerializeField] protected uint Increment = 1; 8 | } 9 | } -------------------------------------------------------------------------------- /Editor/Versioning/Semantic/Steps/Pre/IncrementSemanticVersionStep.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: ab0309b7d781423ca4d08fdca29333ca 3 | timeCreated: 1617190430 -------------------------------------------------------------------------------- /Editor/Versioning/Semantic/Variables.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: a8a7acb815324367b0ecf5c183449ff6 3 | timeCreated: 1647959818 -------------------------------------------------------------------------------- /Editor/Versioning/Semantic/Variables/ApplicationVersion.cs: -------------------------------------------------------------------------------- 1 | using UnityEngine; 2 | 3 | namespace UniTools.Build 4 | { 5 | /// 6 | /// Returns the current value of the application version as a Scriptable Object. 7 | /// Useful to use in the Path as a composite value 8 | /// 9 | [CreateAssetMenu( 10 | fileName = nameof(ApplicationVersion), 11 | menuName = MenuPaths.Versioning + nameof(ApplicationVersion) 12 | )] 13 | public sealed class ApplicationVersion : BaseScriptablePath 14 | { 15 | public override string ToString() 16 | { 17 | return Application.version; 18 | } 19 | } 20 | } -------------------------------------------------------------------------------- /Editor/Versioning/Semantic/Variables/ApplicationVersion.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 71f972dd1bac47b6b82cbfc7995b547f 3 | timeCreated: 1647959714 -------------------------------------------------------------------------------- /Editor/Versioning/Semantic/Variables/ApplicationVersionEditor.cs: -------------------------------------------------------------------------------- 1 | using UnityEditor; 2 | 3 | namespace UniTools.Build 4 | { 5 | [CustomEditor(typeof(ApplicationVersion))] 6 | public sealed class ApplicationVersionEditor : Editor 7 | { 8 | public override void OnInspectorGUI() 9 | { 10 | EditorGUILayout.LabelField(target.ToString()); 11 | } 12 | } 13 | } -------------------------------------------------------------------------------- /Editor/Versioning/Semantic/Variables/ApplicationVersionEditor.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 738f740182fc4f7e8b6b25e85f171cd8 3 | timeCreated: 1647960030 -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2021 Stanislav Felinskyi 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /LICENSE.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 66426f9a6022c4385a2286cf49a01435 3 | DefaultImporter: 4 | externalObjects: {} 5 | userData: 6 | assetBundleName: 7 | assetBundleVariant: 8 | -------------------------------------------------------------------------------- /README.md.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: fb5649c812e8b441a9ec6e78d580115f 3 | TextScriptImporter: 4 | externalObjects: {} 5 | userData: 6 | assetBundleName: 7 | assetBundleVariant: 8 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "displayName": "UniTools.Build", 3 | "name": "com.unitools.build", 4 | "version": "0.1.10-preview", 5 | "unity": "2019.1", 6 | "description": "Customizable Build Pipeline for Unity3D", 7 | "keywords": [ 8 | "build", 9 | "unity3d", 10 | "ci-cd", 11 | "build-tool", 12 | "ci-cd-pipeline", 13 | "unity-tool" 14 | ], 15 | "category": "Libraries", 16 | "type": "library" 17 | } -------------------------------------------------------------------------------- /package.json.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: a4d26ce320e50412d97b06dca4abcfac 3 | PackageManifestImporter: 4 | externalObjects: {} 5 | userData: 6 | assetBundleName: 7 | assetBundleVariant: 8 | --------------------------------------------------------------------------------