private HashSet <string> RelevantRelativeDirectoriesBeneathDirectory(string path,
                                                                      CancellationToken cancellationToken)
 {
     return(new HashSet <string>(Directory.GetDirectories(path, "*", SearchOption.AllDirectories)
                                 .TakeWhile((s) => !cancellationToken.IsCancellationRequested)
                                 .Select(p => PXR_PathHelper.MakeRelativePath(path, p)).Where(RelativeDirectoryPathIsRelevant)));
 }
示例#2
0
    private static void InstallAPP()
    {
        PXR_SceneQuickPreviewEW.PrintLog("installing APP  . . .", PXR_SceneQuickPreviewEW.LogType.Normal);

        PXR_DirectorySyncer.CreateDirectory(SQP_BUNDLE_PATH);

        PrebuildProjectSettingUpdate();

        if (string.IsNullOrEmpty(previewIndexPath) || !File.Exists(previewIndexPath))
        {
            string[] editorScenePaths = Directory.GetFiles(PXR_PathHelper.GetPXRPluginPath(), SQP_INDEX_NAME, SearchOption.AllDirectories);

            if (editorScenePaths.Length == 0 || editorScenePaths.Length > 1)
            {
                PXR_SceneQuickPreviewEW.PrintLog(editorScenePaths.Length + " " + SQP_INDEX_NAME + " has been found, please double check your PicoXR Plugin import.", PXR_SceneQuickPreviewEW.LogType.Error);
                return;
            }
            previewIndexPath = Path.Combine(Application.dataPath, SQP_INDEX_NAME);
            if (File.Exists(previewIndexPath))
            {
                File.Delete(previewIndexPath);
            }
            File.Copy(editorScenePaths[0], previewIndexPath);
        }

        string[] buildScenes = new string[1] {
            previewIndexPath
        };
        string apkOutputPath = Path.Combine(SQP_BUNDLE_PATH, SQP_APK_NAME);

        if (File.Exists(apkOutputPath))
        {
            File.Delete(apkOutputPath);
        }

        var buildPlayerOptions = new BuildPlayerOptions
        {
            scenes           = buildScenes,
            locationPathName = apkOutputPath,
            target           = BuildTarget.Android,
            options          = BuildOptions.Development |
                               BuildOptions.AutoRunPlayer
        };

        BuildReport report = BuildPipeline.BuildPlayer(buildPlayerOptions);

        if (report.summary.result == BuildResult.Succeeded)
        {
            PXR_SceneQuickPreviewEW.PrintLog("App is installed.", PXR_SceneQuickPreviewEW.LogType.Success);
        }
        else if (report.summary.result == BuildResult.Failed)
        {
            PXR_SceneQuickPreviewEW.PrintLog("Failed", PXR_SceneQuickPreviewEW.LogType.Error);
        }
        PostbuildProjectSettingUpdate();
    }
示例#3
0
    public static bool RestartApp()
    {
        if (!PXR_ADBTool.GetInstance().IsReady())
        {
            return(false);
        }

        string output, error;

        string[] appStartCommand = { "-d shell", "am start -a android.intent.action.MAIN -c android.intent.category.LAUNCHER -S -f 0x10200000 -n", PXR_PathHelper.GetPlayerActivityName() };
        if (PXR_ADBTool.GetInstance().RunCommand(appStartCommand, null, out output, out error) == 0)
        {
            PXR_SceneQuickPreviewEW.PrintLog("App " + " Restart Success!", PXR_SceneQuickPreviewEW.LogType.Success);
            return(true);
        }

        string completeError = "PXRLog Failed to restart App. Try restarting it manually through the device.\n" + (string.IsNullOrEmpty(error) ? output : error);

        Debug.LogError(completeError);
        return(false);
    }