@@ -2843,13 +2843,89 @@ private void btnPatchHubConfig_Click(object sender, RoutedEventArgs e)
28432843 File . WriteAllText ( configFile , json ) ;
28442844 SetStatus ( "editors.json file saved" ) ;
28452845 }
2846+ else
2847+ {
2848+ SetStatus ( configFile + " not found" ) ;
2849+ }
28462850 }
28472851 else
28482852 {
28492853 SetStatus ( "Cancelled" ) ;
28502854 }
28512855 }
28522856
2857+ private void menuInstallLastAPK_Click ( object sender , RoutedEventArgs e )
2858+ {
2859+ var proj = GetSelectedProject ( ) ;
2860+
2861+ var yamlFile = Path . Combine ( proj . Path , "Library" , "PlayerDataCache" , "Android" , "ScriptsOnlyCache.yaml" ) ;
2862+ if ( File . Exists ( yamlFile ) == false )
2863+ {
2864+ SetStatus ( "No ScriptsOnlyCache.yaml file found" ) ;
2865+ return ;
2866+ }
2867+ var yaml = File . ReadAllLines ( yamlFile ) ;
2868+ // loop rows until "playerPath:"
2869+ string playerPath = null ;
2870+ foreach ( var row in yaml )
2871+ {
2872+ if ( row . IndexOf ( "playerPath:" ) > - 1 )
2873+ {
2874+ // get the player path
2875+ playerPath = row . Substring ( row . IndexOf ( ":" ) + 1 ) . Trim ( ) ;
2876+ break ;
2877+ }
2878+ }
2879+
2880+ if ( playerPath == null )
2881+ {
2882+ SetStatus ( "No playerPath found in ScriptsOnlyCache.yaml" ) ;
2883+ return ;
2884+ }
2885+
2886+ // install the apk using ADB using cmd (-r = replace app)
2887+ var cmd = "cmd.exe" ; // /C adb install -r \"{playerPath}\"";
2888+ var pars = $ "/C adb install -r \" { playerPath } \" ";
2889+
2890+ string packageName = null ;
2891+
2892+ // get package name from ProjectSettings.asset
2893+ var psPath = Path . Combine ( proj . Path , "ProjectSettings" , "ProjectSettings.asset" ) ;
2894+ if ( File . Exists ( psPath ) == true )
2895+ {
2896+ // read project settings
2897+ var rows = File . ReadAllLines ( psPath ) ;
2898+
2899+ // search applicationIdentifier, Android:
2900+ for ( int i = 0 , len = rows . Length ; i < len ; i ++ )
2901+ {
2902+ // skip rows until companyname
2903+ if ( rows [ i ] . Trim ( ) . IndexOf ( "applicationIdentifier:" ) > - 1 )
2904+ {
2905+ var temp = rows [ i + 1 ] . Trim ( ) ;
2906+ if ( temp . IndexOf ( "Android:" ) > - 1 )
2907+ {
2908+ // get package name
2909+ packageName = temp . Substring ( temp . IndexOf ( ":" ) + 1 ) . Trim ( ) ;
2910+ break ;
2911+ }
2912+ }
2913+ }
2914+ }
2915+
2916+ if ( string . IsNullOrEmpty ( packageName ) == false )
2917+ {
2918+ pars += $ " && adb shell monkey -p { packageName } 1";
2919+ }
2920+
2921+ // TODO start cmd minimized
2922+ Tools . LaunchExe ( cmd , pars ) ;
2923+ // get apk name from path
2924+ var apkName = Path . GetFileName ( playerPath ) ;
2925+ if ( chkStreamerMode . IsChecked == true ) apkName = " (hidden in streamermode)" ;
2926+ SetStatus ( "Installed APK:" + apkName ) ;
2927+ }
2928+
28532929 //private void BtnBrowseTemplateUnityPackagesFolder_Click(object sender, RoutedEventArgs e)
28542930 //{
28552931 // var folder = Tools.BrowseForOutputFolder("Select unitypackage Templates folder");
0 commit comments