GetInstalledPlatformModules()
Gets a list of all installed platforms.
Read time 2 minutesLast updated 10 days ago
Definition
- Type: Method
- Namespace: UnityEditor.Build.Profile
- Assembly: UnityEditor.CoreModule
public static IReadOnlyList<InstalledPlatformInfo> GetInstalledPlatformModules()
Returns
Type | Description |
|---|---|
| IReadOnlyList<InstalledPlatformInfo> | InstalledPlatformInfo collection. |
Remarks
Each InstalledPlatformInfo in the returned collection provides the platform's and its .
displayNameplatformGuidUse to identify a platform in code, because it's a stable identifier. Don't compare against , because it's localized and intended only for display in the Editor.
platformGuiddisplayNameThe following values identify commonly used platforms:
platformGuid- Windows:
4e3c793746204150860bf175a9a41a05 - macOS:
0d2129357eac403d8b359c2dcbf82502 - Linux:
cb423bfea44b4d658edb8bc5d91a3024 - Windows Server:
8d1e1bca926649cba89d37a4c66e8b3d - macOS Server:
8659dec1db6b4fac86149f99f2fa4291 - Linux Server:
91d938b35f6f4798811e41f2acf9377f - Android:
b9b35072a6f44c2e863f17467ea3dc13 - iOS:
ad48d16a66894befa4d8181998c3cb09 - Web:
84a3bb9e7420477f885e98145999eb20 - Universal Windows Platform:
32e92b6f4db44fadb869cafb8184d021 - tvOS:
81e4f4c492fd4311bbf5b0b88a28c737 - visionOS:
53916e6f1f7240d992977ffa2322b047 - Meta Quest:
80657fe557de4d17822398b3a01b8c9e - Android XR:
a71389c8cc8e4edc99d30db86d62ee8f
The following example logs the display name and GUID of every installed platform.
using System.Collections.Generic;using UnityEditor;using UnityEditor.Build.Profile;using UnityEngine;public static class InstalledPlatformsLogger{ [MenuItem("Build/Log Installed Platforms")] public static void LogInstalledPlatforms() { // Retrieve every platform module currently installed in the Editor. var installedPlatforms = BuildProfile.GetInstalledPlatformModules(); foreach (InstalledPlatformInfo platform in installedPlatforms) { // Each entry exposes a display name and the GUID used to create a build profile. Debug.Log($"{platform.displayName} ({platform.platformGuid})"); } }}
The following example checks whether the Android platform is installed, and if it is, creates a build profile that targets Android.
using UnityEditor;using UnityEditor.Build.Profile;using UnityEngine;public static class AndroidProfileCreator{ // GUID that identifies the Android platform. Refer to the list of common platform GUIDs on this page. static readonly GUID k_AndroidPlatformGuid = new GUID("b9b35072a6f44c2e863f17467ea3dc13"); [MenuItem("Build/Create Android Profile If Installed")] public static void CreateAndroidProfile() { // Confirm the Android module is installed before you create a profile that targets it. foreach (InstalledPlatformInfo platform in BuildProfile.GetInstalledPlatformModules()) { if (platform.platformGuid == k_AndroidPlatformGuid) { BuildProfile.CreateBuildProfile(platform.platformGuid, "Android"); return; } } Debug.LogWarning("The Android platform module isn't installed."); }}
Additional Resources: InstalledPlatformInfo, BuildProfile.CreateBuildProfile.