Skip to main content

Object Requires

namespace: qASIC

Introduction

The Object Requires Attribute forces it's targetted field to only accept objects that contain the specified components.

Setup

Add the Object Requires Attribute to the targeted field.

public class ExampleClass : MonoBehaviour
{
//This field will reject every GameObject which doesn't
//have the component 'Rigidbody'
[ObjectRequires(typeof(Rigidbody))]
public GameObject obj;

//This field will reject every GameObject which doesn't
//have the component 'Rigidbody' and the component
//'CapsuleCollider'
[ObjectRequires(typeof(Rigidbody), typeof(CapsuleCollider))]
public GameObject obj2;
}