文档

Unity Engine

Unity Engine

CreateComponent<T>()

Creates a new instance of a given scriptable object and adds it as a sub-asset to the build profile. Only one instance per type can be embedded within a build profile.
阅读时间1 分钟最后更新于 14 天前

Definition

public T CreateComponent<T>() where T : Object

Returns

Type

Description

TScriptableObject type to instantiate.

Remarks

Use this method to add BuildProfilePlayerSettings, BuildProfileGraphicsSettings, or BuildProfileQualitySettings to a build profile. Unity initializes the new component as follows:
If you pass PlayerSettings as
T
, this method throws an
ArgumentException
. To give a build profile its own Player settings, pass BuildProfilePlayerSettings as
T
. The method throws an
InvalidOperationException
if you add BuildProfilePlayerSettings for a platform profile from the Platforms pane.
Note: This method is restricted to ScriptableObject types and doesn't support all settings visible in the Build Profiles window.