void OnGUI()

in RealityMaterialExplorer/Assets/Oculus/VR/Editor/OVRPlatformTool.cs [90:396]


		void OnGUI()
		{
			if (boldFoldoutStyle == null)
			{
				boldFoldoutStyle = new GUIStyle(EditorStyles.foldout);
				boldFoldoutStyle.fontStyle = FontStyle.Bold;
			}

			EditorGUIUtility.labelWidth = DEFAULT_LABEL_WIDTH;

			GUILayout.Label("OVR Platform Tool", EditorStyles.boldLabel);
			this.titleContent.text = "OVR Platform Tool";

			GUIContent TargetPlatformLabel = new GUIContent("Target Oculus Platform");
			OVRPlatformToolSettings.TargetPlatform = (TargetPlatform)MakeEnumPopup(TargetPlatformLabel, OVRPlatformToolSettings.TargetPlatform);

			if (OVRPlatformToolSettings.TargetPlatform == TargetPlatform.None)
				return;

			SetOVRProjectConfig(OVRPlatformToolSettings.TargetPlatform);
			SetDirtyOnGUIChange();

			commandMenuScroll = EditorGUILayout.BeginScrollView(commandMenuScroll, GUILayout.Height(Screen.height / 2));
			{
				// Add the UI Form
				EditorGUI.BeginChangeCheck();
				GUILayout.Space(15.0f);

				// App ID
				GUIContent AppIDLabel = new GUIContent("Oculus Application ID [?]: ",
					"This AppID will be used when uploading the build.");
				OVRPlatformToolSettings.AppID = MakeTextBox(AppIDLabel, OVRPlatformToolSettings.AppID);

				// App Token
				GUIContent AppTokenLabel = new GUIContent("Oculus App Token [?]: ",
					"You can get your app token from your app's Oculus API Dashboard.");
				appToken = MakePasswordBox(AppTokenLabel, appToken);

				// Release Channel
				GUIContent ReleaseChannelLabel = new GUIContent("Release Channel [?]: ",
					"Specify the releaes channel of the new build, you can reassign to other channels after upload.");
				OVRPlatformToolSettings.ReleaseChannel = MakeTextBox(ReleaseChannelLabel, OVRPlatformToolSettings.ReleaseChannel);

				// Releaes Note
				GUIContent ReleaseNoteLabel = new GUIContent("Release Note: ");
				OVRPlatformToolSettings.ReleaseNote = MakeTextBox(ReleaseNoteLabel, OVRPlatformToolSettings.ReleaseNote);

				// Platform specific fields
				if (OVRPlatformToolSettings.TargetPlatform == TargetPlatform.Rift)
				{
					GUIContent BuildDirLabel = new GUIContent("Rift Build Directory [?]: ",
						"The full path to the directory containing your Rift build files.");
					OVRPlatformToolSettings.RiftBuildDirectory = MakeFileDirectoryField(BuildDirLabel, OVRPlatformToolSettings.RiftBuildDirectory,
						"Choose Rifle Build Directory");

					GUIContent BuildVersionLabel = new GUIContent("Build Version [?]: ",
						"The version number shown to users.");
					OVRPlatformToolSettings.RiftBuildVersion = MakeTextBox(BuildVersionLabel, OVRPlatformToolSettings.RiftBuildVersion);

					GUIContent LaunchFileLabel = new GUIContent("Launch File Path [?]: ",
						"The full path to the executable that launches your app.");
					OVRPlatformToolSettings.RiftLaunchFile = MakeFileDirectoryField(LaunchFileLabel, OVRPlatformToolSettings.RiftLaunchFile,
						"Choose Launch File", true, "exe");
				}
				else
				{
					GUIContent ApkPathLabel = new GUIContent("Build APK File Path [?]: ",
						"The full path to the APK file.");
					OVRPlatformToolSettings.ApkBuildPath = MakeFileDirectoryField(ApkPathLabel, OVRPlatformToolSettings.ApkBuildPath,
						"Choose APK File", true, "apk");

					if (OVRPlatformToolSettings.TargetPlatform == TargetPlatform.Quest)
					{
						// Quest specific fields
					}
				}

				GUIContent uploadDebugSymbolsLabel = new GUIContent("Upload Debug Symbols [?]: ",
					"Check this box to enable uploading of debug symbols.");
				OVRPlatformToolSettings.UploadDebugSymbols = MakeToggleBox(uploadDebugSymbolsLabel, OVRPlatformToolSettings.UploadDebugSymbols);
				if (OVRPlatformToolSettings.UploadDebugSymbols)
				{
					IncrementIndent();
					if (OVRPlatformToolSettings.TargetPlatform == TargetPlatform.Quest)
					{
						if (showUploadDebugSymbols != OVRPlatformToolSettings.UploadDebugSymbols)
						{
							// If no debug symbol directory is set, default to the expected place based of scripting backend
							if (string.IsNullOrEmpty(OVRPlatformToolSettings.DebugSymbolsDirectory))
							{
								ScriptingImplementation scriptingBackend = PlayerSettings.GetScriptingBackend(EditorUserBuildSettings.selectedBuildTargetGroup);
								if (scriptingBackend == ScriptingImplementation.IL2CPP)
								{
									OVRPlatformToolSettings.DebugSymbolsDirectory = Path.Combine(Application.dataPath, "../Temp/StagingArea/symbols");
								}
								else
								{
									OVRPlatformToolSettings.DebugSymbolsDirectory = Path.Combine(EditorApplication.applicationContentsPath,
										"PlaybackEngines/AndroidPlayer/Variations/mono/Release/Symbols/armeabi-v7a");
								}
							}
							EditorUtility.SetDirty(OVRPlatformToolSettings.Instance);
						}

						GUIContent DebugSymbolLabel = new GUIContent("Debug Symbols Directory [?]: ",
						"The full path to the directory containing the app symbols (libil2cpp.sym.so)");
						OVRPlatformToolSettings.DebugSymbolsDirectory = MakeFileDirectoryField(DebugSymbolLabel, OVRPlatformToolSettings.DebugSymbolsDirectory,
							"Choose Debug Symbols Directory", false);

						GUIContent uploadSymbolsOnlyLabel = new GUIContent("Upload Debug Symbols Only [?]: ",
							"Check this box to upload debug symbols to an existing build. Will require a Build ID along with the App ID, App Token, and Symbols Directory.");
						OVRPlatformToolSettings.UploadDebugSymbolsOnly = MakeToggleBox(uploadSymbolsOnlyLabel, OVRPlatformToolSettings.UploadDebugSymbolsOnly);

						if (OVRPlatformToolSettings.UploadDebugSymbolsOnly)
						{
							GUIContent BuildIDLabel = new GUIContent("Build ID [?]: ",
								"This BuildID will be used for uploading debug symbols to a specific build.");
							OVRPlatformToolSettings.BuildID = MakeTextBox(BuildIDLabel, OVRPlatformToolSettings.BuildID);
						}
					}
					DecrementIndent();
				}
				showUploadDebugSymbols = OVRPlatformToolSettings.UploadDebugSymbols;

				showOptionalCommands = EditorGUILayout.Foldout(showOptionalCommands, "Optional Commands", boldFoldoutStyle);
				if (showOptionalCommands)
				{
					IncrementIndent();

					if (OVRPlatformToolSettings.TargetPlatform == TargetPlatform.Rift)
					{
						// Launch Parameters
						GUIContent LaunchParamLabel = new GUIContent("Launch Parameters [?]: ",
							"Specifies any arguments passed to the launcher.");
						OVRPlatformToolSettings.RiftLaunchParams = MakeTextBox(LaunchParamLabel, OVRPlatformToolSettings.RiftLaunchParams);

						GUIContent FirewallExceptionLabel = new GUIContent("Firewall Exception [?]: ",
							"Specifies if a Windows Firewall exception is required.");
						OVRPlatformToolSettings.RiftFirewallException = MakeToggleBox(FirewallExceptionLabel, OVRPlatformToolSettings.RiftFirewallException);

						GUIContent GamepadEmulationLabel = new GUIContent("Gamepad Emulation [?]: ",
							"Specifies the type of gamepad emulation used by the Oculus Touch controllers.");
						OVRPlatformToolSettings.RiftGamepadEmulation = (GamepadType)MakeEnumPopup(GamepadEmulationLabel, OVRPlatformToolSettings.RiftGamepadEmulation);

						show2DCommands = EditorGUILayout.Foldout(show2DCommands, "2D", boldFoldoutStyle);
						if (show2DCommands)
						{
							IncrementIndent();

							// 2D Launch File
							GUIContent LaunchFile2DLabel = new GUIContent("2D Launch File [?]: ",
								"The full path to the executable that launches your app in 2D mode.");
							OVRPlatformToolSettings.Rift2DLaunchFile = MakeFileDirectoryField(LaunchFile2DLabel, OVRPlatformToolSettings.Rift2DLaunchFile,
								"Choose 2D Launch File", true, "exe");

							// 2D Launch Parameters
							GUIContent LaunchParam2DLabel = new GUIContent("2D Launch Parameters [?]: ",
								"Specifies any arguments passed to the launcher in 2D mode.");
							OVRPlatformToolSettings.Rift2DLaunchParams = MakeTextBox(LaunchParam2DLabel, OVRPlatformToolSettings.Rift2DLaunchParams);

							DecrementIndent();
						}

						showRedistCommands = EditorGUILayout.Foldout(showRedistCommands, "Redistributable Packages", boldFoldoutStyle);
						if (showRedistCommands)
						{
							IncrementIndent();

							for (int i = 0; i < OVRPlatformToolSettings.RiftRedistPackages.Count; i++)
							{
								GUIContent RedistPackageLabel = new GUIContent(OVRPlatformToolSettings.RiftRedistPackages[i].name);
								OVRPlatformToolSettings.RiftRedistPackages[i].include = MakeToggleBox(RedistPackageLabel, OVRPlatformToolSettings.RiftRedistPackages[i].include);
							}

							DecrementIndent();
						}

						showExpansionFileCommands = EditorGUILayout.Foldout(showExpansionFileCommands, "Expansion Files", boldFoldoutStyle);
						if (showExpansionFileCommands)
						{
							IncrementIndent();

							// Language Pack Directory
							GUIContent LanguagePackLabel = new GUIContent("Language Pack Directory [?]: ",
								"The full path to the directory containing the language packs");
							OVRPlatformToolSettings.LanguagePackDirectory = MakeFileDirectoryField(LanguagePackLabel, OVRPlatformToolSettings.LanguagePackDirectory,
								"Choose Language Pack Directory");
						}
					}
					else
					{
						if (OVRPlatformToolSettings.TargetPlatform == TargetPlatform.Quest)
						{
							// Quest specific optional fields
						}

						showExpansionFileCommands = EditorGUILayout.Foldout(showExpansionFileCommands, "Expansion Files", boldFoldoutStyle);
						if (showExpansionFileCommands)
						{
							IncrementIndent();

							// OBB File Path
							GUIContent ObbPathLabel = new GUIContent("OBB File Path [?]: ",
								"The full path to the OBB file.");
							OVRPlatformToolSettings.ObbFilePath = MakeFileDirectoryField(ObbPathLabel, OVRPlatformToolSettings.ObbFilePath,
								"Choose OBB File", true, "obb");
						}
					}

					if (showExpansionFileCommands)
					{
						// Assets Directory
						GUIContent AssetsDirLabel = new GUIContent("Assets Directory [?]: ",
							"The full path to the directory with DLCs for this build.");
						string assetsDirectory = MakeFileDirectoryField(AssetsDirLabel, OVRPlatformToolSettings.AssetsDirectory,
							"Choose Assets Directory");

						if (assetsDirectory != OVRPlatformToolSettings.AssetsDirectory)
						{
							OVRPlatformToolSettings.AssetsDirectory = assetsDirectory;
							OVRPlatformToolSettings.AssetConfigs.Clear();
							if (!string.IsNullOrEmpty(OVRPlatformToolSettings.AssetsDirectory))
							{
								DirectoryInfo dirInfo = new DirectoryInfo(OVRPlatformToolSettings.AssetsDirectory);
								FileInfo[] assetFiles = dirInfo.GetFiles();
								foreach (FileInfo f in assetFiles)
								{
									OVRPlatformToolSettings.AssetConfigs.Add(new AssetConfig(f.Name));
								}
							}
							EditorUtility.SetDirty(OVRPlatformToolSettings.Instance);
						}

						// Display bordered asset configuration list
						GUILayout.Space(3f);
						Rect rect = GUILayoutUtility.GetRect(0, GetAssetConfigElementHeight() + (ASSET_CONFIG_BACKGROUND_PADDING * 2),
							GUILayout.ExpandWidth(true));
						rect.x += (EditorGUI.indentLevel * INDENT_SPACING + 5);
						rect.width -= (EditorGUI.indentLevel * INDENT_SPACING + 10);
						DrawAssetConfigList(rect);

						DecrementIndent();
					}

					EditorGUI.indentLevel--;
				}

				if (EditorGUI.EndChangeCheck())
				{
					EditorUtility.SetDirty(OVRPlatformToolSettings.Instance);
				}
			}
			EditorGUILayout.EndScrollView();

			GUILayout.Space(SINGLE_LINE_SPACING);

			GUILayout.FlexibleSpace();

			// Run OVR Lint Option
			EditorGUIUtility.labelWidth = DEFAULT_LABEL_WIDTH;
			GUIContent RunOvrLintLabel = new GUIContent("Run OVR Lint (Recommended) [?]: ",
				"Run OVR Lint tool to ensure project is optimized for performance and meets Oculus packaging requirement for publishing.");
			OVRPlatformToolSettings.RunOvrLint = MakeToggleBox(RunOvrLintLabel, OVRPlatformToolSettings.RunOvrLint);

			// Add an Upload button
			GUI.enabled = !activeProcess;
			GUIContent btnTxt = new GUIContent("Upload");
			var rt = GUILayoutUtility.GetRect(btnTxt, GUI.skin.button, GUILayout.ExpandWidth(false));
			var btnYPos = rt.center.y;
			rt.center = new Vector2(EditorGUIUtility.currentViewWidth / 2 - rt.width / 2 - buttonPadding, btnYPos);
			if (GUI.Button(rt, btnTxt, GUI.skin.button))
			{
				OVRPlugin.SendEvent("oculus_platform_tool", "upload");
				OVRPlatformTool.log = string.Empty;
				OnUpload(OVRPlatformToolSettings.TargetPlatform);
			}

			// Add a cancel button
			GUI.enabled = activeProcess;
			btnTxt = new GUIContent("Cancel");
			rt = GUILayoutUtility.GetRect(btnTxt, GUI.skin.button, GUILayout.ExpandWidth(false));
			rt.center = new Vector2(EditorGUIUtility.currentViewWidth / 2 + rt.width / 2 + buttonPadding, btnYPos);
			if (GUI.Button(rt, btnTxt, GUI.skin.button))
			{
				if (EditorUtility.DisplayDialog("Cancel Upload Process", "Are you sure you want to cancel the upload process?", "Yes", "No"))
				{
					if (ovrPlatUtilProcess != null)
					{
						ovrPlatUtilProcess.Kill();
						OVRPlatformTool.log += "Upload process was canceled\n";
					}
				}
			}

			GUI.enabled = true;
			GUILayout.FlexibleSpace();

			GUILayout.Space(SINGLE_LINE_SPACING);

			debugLogScroll = EditorGUILayout.BeginScrollView(debugLogScroll);
			GUIStyle logBoxStyle = new GUIStyle();
			logBoxStyle.margin.left = 5;
			logBoxStyle.wordWrap = true;
			logBoxStyle.normal.textColor = logBoxStyle.focused.textColor = EditorStyles.label.normal.textColor;
			EditorGUILayout.SelectableLabel(OVRPlatformTool.log, logBoxStyle, GUILayout.Height(position.height - 30));
			EditorGUILayout.EndScrollView();
		}