IReadOnlyList<InstalledPlatformInfo> InstalledPlatformInfo collection.
Gets a list of all installed platforms.
Each InstalledPlatformInfo in the returned collection provides the platform's displayName and its platformGuid.
Use platformGuid to identify a platform in code, because it's a stable identifier. Don't compare against displayName, because it's localized and intended only for display in the Editor.
The following platformGuid values identify commonly used platforms:
4e3c793746204150860bf175a9a41a050d2129357eac403d8b359c2dcbf82502cb423bfea44b4d658edb8bc5d91a30248d1e1bca926649cba89d37a4c66e8b3d8659dec1db6b4fac86149f99f2fa429191d938b35f6f4798811e41f2acf9377fb9b35072a6f44c2e863f17467ea3dc13ad48d16a66894befa4d8181998c3cb0984a3bb9e7420477f885e98145999eb2032e92b6f4db44fadb869cafb8184d02181e4f4c492fd4311bbf5b0b88a28c73753916e6f1f7240d992977ffa2322b04780657fe557de4d17822398b3a01b8c9ea71389c8cc8e4edc99d30db86d62ee8fThe 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.