// Writes the fields that don't have to be handled differently based on Operating System private static void WriteOsIndependentFields(StreamWriter writer) { writer.WriteLine("*** UNITY VERSION ***"); writer.WriteLine(Application.unityVersion); writer.WriteLine(); writer.WriteLine("*** UNITY RUNTIME PLATFORM ***"); writer.WriteLine(Application.platform); writer.WriteLine(); writer.WriteLine("*** ARCORE SDK FOR UNITY VERSION ***"); writer.WriteLine(GoogleARCore.VersionInfo.Version); writer.WriteLine(); // Can be null string adbPath = ShellHelper.GetAdbPath(); writer.WriteLine("*** ARCORE APP VERSION ***"); WritePackageVersionString(adbPath, "com.google.ar.core", writer); writer.WriteLine("*** INSTANT PREVIEW APP VERSION ***"); WritePackageVersionString(adbPath, "com.google.ar.core.instantpreview", writer); StringBuilder instantPreviewPluginVer = new StringBuilder(64); // Get Instant preview version by running the server. NativeApi.InitializeInstantPreview( adbPath, instantPreviewPluginVer, instantPreviewPluginVer.Capacity); writer.WriteLine("*** INSTANT PREVIEW PLUGIN VERSION ***"); writer.WriteLine(instantPreviewPluginVer); writer.WriteLine(); writer.WriteLine("*** ADB DEVICES ***"); WriteCommand(adbPath, "devices -l", writer); writer.WriteLine("*** DEVICE FINGERPRINT ***"); WriteCommand(adbPath, "shell getprop ro.build.fingerprint", writer); writer.WriteLine("*** ADB VERSION USED BY UNITY ***"); WriteCommand(adbPath, "version", writer); }
/// <summary> /// Coroutine method that communicates to the Instant Preview plugin /// every frame. /// /// If not running in the editor, this does nothing. /// </summary> /// <returns>Enumerator for a coroutine that updates Instant Preview /// every frame.</returns> public static IEnumerator InitializeIfNeeded() { // Terminates if not running in editor. if (!Application.isEditor) { yield break; } // User may have explicitly disabled Instant Preview. if (ARCoreProjectSettings.Instance != null && !ARCoreProjectSettings.Instance.IsInstantPreviewEnabled) { yield break; } #if UNITY_EDITOR // When build platform is not Android, verify min game view scale is 1.0x to prevent // confusing 2x scaling when Unity editor is running on a high density display. if (EditorUserBuildSettings.activeBuildTarget != BuildTarget.Android) { float minGameViewScale = GetMinGameViewScaleOrUnknown(); if (minGameViewScale != 1.0) { String viewScaleText = minGameViewScale == k_UnknownGameViewScale ? "<unknown>" : string.Format("{0}x", minGameViewScale); Debug.LogWarningFormat( "Instant Preview disabled, {0} minimum Game view scale unsupported for " + "target build platform '{1}'.\n" + "To use Instant Preview, switch build platform to '{2}' from the 'Build " + "settings' window.", viewScaleText, EditorUserBuildSettings.activeBuildTarget, BuildTarget.Android); yield break; } } // Determine if any augmented image databases need a rebuild. List <AugmentedImageDatabase> databases = new List <AugmentedImageDatabase>(); bool shouldRebuild = false; var augmentedImageDatabaseGuids = AssetDatabase.FindAssets("t:AugmentedImageDatabase"); foreach (var databaseGuid in augmentedImageDatabaseGuids) { var database = AssetDatabase.LoadAssetAtPath <AugmentedImageDatabase>( AssetDatabase.GUIDToAssetPath(databaseGuid)); databases.Add(database); shouldRebuild = shouldRebuild || database.IsBuildNeeded(); } // If the preference is to ask the user to rebuild, ask now. if (shouldRebuild && PromptToRebuildAugmentedImagesDatabase()) { foreach (var database in databases) { string error; database.BuildIfNeeded(out error); if (!string.IsNullOrEmpty(error)) { Debug.LogWarning("Failed to rebuild augmented image database: " + error); } } } #endif var adbPath = ShellHelper.GetAdbPath(); if (adbPath == null) { Debug.LogError("Instant Preview requires your Unity Android SDK path to be set. " + "Please set it under 'Preferences > External Tools > Android'. " + "You may need to install the Android SDK first."); yield break; } else if (!File.Exists(adbPath)) { Debug.LogErrorFormat( "adb not found at \"{0}\". Please verify that 'Preferences > External Tools " + "> Android' has the correct Android SDK path that the Android Platform Tools " + "are installed, and that \"{0}\" exists. You may need to install the Android " + "SDK first.", adbPath); yield break; } string localVersion; if (!StartServer(adbPath, out localVersion)) { yield break; } yield return(InstallApkAndRunIfConnected(adbPath, localVersion)); yield return(UpdateLoop(adbPath)); }