@@ -34,6 +34,7 @@ public class AndroidBuildConfig : BuildConfigBase
3434 /// <para>예를들어 UnityProject/Asset 폴더 밑에 example.keystore가 있으면 "/example.keystore" 입니다.</para>
3535 /// </summary>
3636 [ SerializeField ]
37+ [ Tooltip ( "Keystore 파일의 경로입니다. `파일경로/파일명.keystore` 까지 쓰셔야 합니다." ) ]
3738 protected string keystorePath ;
3839
3940 /// <summary>
@@ -54,6 +55,12 @@ public class AndroidBuildConfig : BuildConfigBase
5455 [ SerializeField ]
5556 protected int bundleVersionCode ;
5657
58+ /// <summary>
59+ /// 안드로이드 앱번들(.aab)로 빌드할 지, false면 apk로 빌드
60+ /// </summary>
61+ [ SerializeField ]
62+ protected bool aabBuild ;
63+
5764 ///<inheritdoc cref="IBuildConfig.ResetSetting"/>
5865 public override void ResetSetting ( BuildConfigBase config )
5966 {
@@ -75,25 +82,33 @@ public override void OnPreBuild(IDictionary<string, string> commandLine, ref Bui
7582 PlayerSettings . Android . keyaliasName = keyaliasName ;
7683 PlayerSettings . Android . keyaliasPass = keyaliasPassword ;
7784
78- PlayerSettings . Android . keystoreName = Application . dataPath + keystorePath ;
85+ PlayerSettings . Android . keystoreName = keystorePath ;
7986 PlayerSettings . Android . keystorePass = keystorePassword ;
8087 PlayerSettings . Android . bundleVersionCode = bundleVersionCode ;
8188
89+ EditorUserBuildSettings . buildAppBundle = aabBuild ;
90+
8291 PlayerSettings . SetScriptingBackend ( BuildTargetGroup . Android , scriptingBackEnd ) ;
8392
8493 Debug . LogFormat ( $ "OnPreBuild [Android]\n " +
85- $ "PackageName : { PlayerSettings . applicationIdentifier } \n " +
86- $ "keyaliasName : { PlayerSettings . Android . keyaliasName } , keyaliasPass : { PlayerSettings . Android . keyaliasPass } \n " +
87- $ "keystoreName : { PlayerSettings . Android . keystoreName } , keystorePass : { PlayerSettings . Android . keystorePass } \n ") ;
94+ $ "PackageName:{ PlayerSettings . applicationIdentifier } \n " +
95+ $ "keyaliasName:{ PlayerSettings . Android . keyaliasName } , keyaliasPass:{ PlayerSettings . Android . keyaliasPass } \n " +
96+ $ "keystoreName:{ PlayerSettings . Android . keystoreName } , keystorePass:{ PlayerSettings . Android . keystorePass } \n " +
97+ $ "aabBuild:{ aabBuild } ") ;
8898 }
8999
90100 ///<inheritdoc cref="IBuildConfig.GetBuildPath"/>
91101 public override string GetBuildPath ( )
92102 {
93- return base . GetBuildPath ( )
103+ string extensionName = EditorUserBuildSettings . buildAppBundle ? ".aab" : ".apk" ;
104+ return base . GetBuildPath ( ) + extensionName ;
105+ }
106+
107+ public override string ReplaceStrings ( string replaceTarget )
108+ {
109+ return base . ReplaceStrings ( replaceTarget )
94110 . Replace ( "{scriptingBackEnd}" , scriptingBackEnd . ToString ( ) )
95- . Replace ( "{bundleVersionCode}" , bundleVersionCode . ToString ( ) )
96- + ".apk" ;
111+ . Replace ( "{bundleVersionCode}" , bundleVersionCode . ToString ( ) ) ;
97112 }
98113 }
99114
@@ -117,34 +132,22 @@ public override void OnInspectorGUI()
117132 if ( GUILayout . Button ( "Reset to Current EditorSetting" ) )
118133 {
119134 config . ResetSetting ( config ) ;
135+ AssetDatabase . SaveAssets ( ) ;
136+ AssetDatabase . Refresh ( ) ;
137+ EditorUtility . SetDirty ( config ) ;
120138 }
121139
122140 if ( GUILayout . Button ( "Build!" ) )
123141 {
124142 UnityBuilder . Build ( config ) ;
125143 }
126144
127- _commandLine = EditorGUILayout . TextField ( "commandLine" , _commandLine ) ;
145+ EditorGUILayout . Space ( ) ;
146+ EditorGUILayout . LabelField ( "or with command line" ) ;
147+ _commandLine = EditorGUILayout . TextArea ( _commandLine ) ;
128148 if ( GUILayout . Button ( $ "Build with \' { _commandLine } \' ") )
129149 {
130- string [ ] commands = _commandLine . Split ( ' ' ) ;
131- for ( int i = 0 ; i < commands . Length ; i ++ )
132- {
133- string command = commands [ i ] ;
134- bool hasNextCommand = i + 1 < commands . Length ;
135- if ( command . StartsWith ( "-" ) )
136- {
137- if ( hasNextCommand )
138- {
139- Environment . SetEnvironmentVariable ( command , commands [ i + 1 ] ) ;
140- }
141- else
142- {
143- Environment . SetEnvironmentVariable ( command , "" ) ;
144- }
145- }
146- }
147-
150+ UnityBuilder . AddCommandLine ( _commandLine ) ;
148151 UnityBuilder . Build ( ) ;
149152 }
150153 }
0 commit comments