Version 3.3.1.2

Odin has a dedicated attribute overview with examples

SceneObjectsOnlyAttribute class

Namespace: Sirenix.OdinInspector
Assembly: Sirenix.OdinInspector.Attributes
[AttributeUsage(AttributeTargets.Assembly | AttributeTargets.Module | AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Enum | AttributeTargets.Constructor | AttributeTargets.Method | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Event | AttributeTargets.Interface | AttributeTargets.Parameter | AttributeTargets.Delegate | AttributeTargets.ReturnValue | AttributeTargets.GenericParameter | AttributeTargets.All, AllowMultiple = false, Inherited = true)]
[Conditional("UNITY_EDITOR")]
public sealed class SceneObjectsOnlyAttribute : Attribute, _Attribute

SceneObjectsOnly is used on object properties, and restricts the property to scene objects, and not project assets.

Use this when you want to ensure an object is a scene object, and not from a project asset.

Inheritance
  • System.Object
  • System.Attribute
  • SceneObjectsOnlyAttribute
Example

The following example shows a component with a game object property, that must be from a scene, and not a prefab asset.

public MyComponent : MonoBehaviour
{
	[SceneObjectsOnly]
	public GameObject MyPrefab;
}

Constructors

SceneObjectsOnlyAttribute()
public SceneObjectsOnlyAttribute()