Skip to main content

Prefab

namespace: qASIC

Introduction

The Prefab Attribute forces it's targetted field to only accept objects that are prefabs.

Setup

Add the Prefab Attribute to the targeted field.

public class ExampleClass : MonoBehaviour
{
//This field will reject every GameObject which isn't
//a prefab or is located in the scene
[Prefab]
public GameObject prefab;

//This field will reject every GameObject which isn't
//a prefab and it will accept objects that are in the
//scene
[Prefab(canBeInScene = true)]
public GameObject scenePrefab;

//It also works for MonoBehaviours
[Prefab]
public MonoBehaviour behaviourPrefab;
}