Documentation

Unity Engine


User Manual

Script Reference

Unity Engine


ReplacementComponentAttribute(string, string)

Initializes the attribute with the replacement type name and an optional display name.
Read time 1 minuteLast updated 6 days ago

Definition

  • Type: Constructor
  • Namespace: UnityEngine
  • Assembly: UnityEngine.CoreModule
public ReplacementComponentAttribute(string typeName, string displayName = null)

Parameters

typeName

The full type name of the replacement component including its namespace.

displayName

Optional display name to display in the Inspector button. If it's not specified, Unity derives a name from
typeName
.

Remarks

When you annotate a deprecated component with this attribute, Unity displays a button on the component’s UI in the Inspector window. When you click this button, Unity adds an instance of the replacement component to the same GameObject.

Examples

using UnityEngine;[System.ObsoleteAttribute("The ObsoleteMonoBehaviour component is deprecated.", false)][ReplacementComponent("UnityEngine.Camera", "Example Component")]public class ObsoleteMonoBehaviour : MonoBehaviour{}