BuildProfilePlayerSettings
A build profile component that stores Player settings the build profile uses in place of the global Player settings.
Read time 5 minutesLast updated 2 days ago
Definition
- Type: Class
- Namespace: UnityEditor.Build.Profile
- Assembly: UnityEditor.CoreModule
- Inherits from: Object
[ExcludeFromObjectFactory]public sealed class BuildProfilePlayerSettings : Object
Remarks
A build profile has at most one component. A build profile without this component uses the global Player settings.
BuildProfilePlayerSettingsUse the following methods to manage the component:
- BuildProfile.CreateComponent adds the component to a build profile. The new component starts as a copy of the global Player settings.
- BuildProfile.GetComponent returns the component, or if the build profile uses the global Player settings. To get the Player settings that apply to a build profile in either case, call BuildProfile.GetComponent with PlayerSettings as the type.
null - BuildProfile.RemoveComponent removes the component, so that the build profile uses the global Player settings again.
To change the Player settings of the active build profile, use the PlayerSettings API. While the build profile is active, the PlayerSettings API reads and writes the values stored in this component.
To change the Player settings of a build profile that isn't active, edit this component through a SerializedObject. The serialized property paths of this component aren't part of the public API and might change in future versions.
You can't create this component with a constructor, and you can't add an existing instance to a build profile with BuildProfile.AddComponent.
The following example gives the active build profile its own Player settings, and then changes the company name of that build profile only.
using UnityEditor;using UnityEditor.Build.Profile;using UnityEngine;public static class BuildProfilePlayerSettingsExample{ [MenuItem("Example/Set Company Name For Active Build Profile")] static void SetCompanyNameForActiveBuildProfile() { BuildProfile profile = BuildProfile.GetActiveBuildProfile(); if (profile == null) return; // Copy the global Player settings into the build profile, unless it already has its own. if (profile.GetComponent<BuildProfilePlayerSettings>() == null) profile.CreateComponent<BuildProfilePlayerSettings>(); // While the build profile is active, the PlayerSettings API changes its own Player settings. // The global Player settings keep their company name. PlayerSettings.companyName = "Example Studio"; Debug.Log($"Company name for {profile.name}: {PlayerSettings.companyName}"); } [MenuItem("Example/Use Global Player Settings For Active Build Profile")] static void UseGlobalPlayerSettingsForActiveBuildProfile() { BuildProfile profile = BuildProfile.GetActiveBuildProfile(); if (profile == null || profile.GetComponent<BuildProfilePlayerSettings>() == null) return; // Remove the build profile's own Player settings, so that it uses the global Player settings again. profile.RemoveComponent<BuildProfilePlayerSettings>(); }}
Inheritance
Operators
Operator | Description |
|---|---|
| operator == | Compares two object references to see if they refer to the same object. |
| bool | Determines whether the object exists. |
| operator != | Compares if two objects refer to a different object. |