Documentation

Unity Engine

Unity Engine

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

[ExcludeFromObjectFactory]public sealed class BuildProfilePlayerSettings : Object

Remarks

A build profile has at most one
BuildProfilePlayerSettings
component. A build profile without this component uses the global Player settings.
Use the following methods to manage the component:
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

Inherited Members

Operators

Operator

Description

operator ==Compares two object references to see if they refer to the same object.
boolDetermines whether the object exists.
operator !=Compares if two objects refer to a different object.