Version: 2020.3
LanguageEnglish
  • C#

ObjectSelectorHandlerWithTagsAttribute Constructor

Suggest a change

Success!

Thank you for helping us improve the quality of Unity Documentation. Although we cannot accept all submissions, we do read each suggested change from our users and will make updates where applicable.

Close

Submission failed

For some reason your suggested change could not be submitted. Please <a>try again</a> in a few minutes. And thank you for taking the time to help us improve the quality of Unity Documentation.

Close

Cancel

Declaration

public ObjectSelectorHandlerWithTagsAttribute(params string[] tags);

Parameters

tags An array of strings that represents the different tags to use as constraints.

Description

Constructor used to declare the ObjectSelectorHandlerWithTagsAttribute on a field.

The "tags" parameter represents the tags to use as constraints. If there is more than one tag, the object selector shows GameObjects or Components tagged with any of them.

using System;
using UnityEngine;
using UnityEngine.SearchService;

public class GameObjectComponent : MonoBehaviour { // Declare a field that only supports GameObjects tagged with "Trigger". [ObjectSelectorHandlerWithTags("Trigger")] public GameObject triggerTags;

// Declare a field that only supports GameObjects tagged with "Shape". [ObjectSelectorHandlerWithTags("Shape")] public GameObject shapeTags;

// Declare a field that supports GameObjects tagged with either "Trigger" or "Shape". [ObjectSelectorHandlerWithTags("Trigger", "Shape")] public GameObject triggerOrShapeTags;

// Start is called before the first frame update. void Start() { }

// Update is called once per frame. void Update() { } }