using System;
using System.Collections.Generic;
using UnityEditor;
using UnityEngine.Serialization;
namespace UnityEngine.Perception.GroundTruth
{
///
/// Defines a set of labels associated with the object and its descendants. A Labeling component will override any Labeling components on the object's ancestors.
///
[AddComponentMenu("Perception/Labeling/Labeling")]
public class Labeling : MonoBehaviour
{
static LabelManager labelManager => LabelManager.singleton;
///
/// The label names to associate with the GameObject. Modifications to this list after the Update() step of the frame the object is created in are
/// not guaranteed to be reflected by labelers.
///
[FormerlySerializedAs("classes")]
public List labels = new List();
///
/// Whether this labeling component is currently using an automatic labeling scheme. When this is enabled, the asset can have only one label (the automatic one) and the user cannot add more labels.
///
public bool useAutoLabeling;
///
/// The specific subtype of AssetLabelingScheme that this component is using, if useAutoLabeling is enabled.
///
public string autoLabelingSchemeType = string.Empty;
///
/// The unique id of this labeling component instance
///
public uint instanceId { get; private set; }
void OnDestroy()
{
labelManager.Unregister(this);
}
void OnEnable()
{
RefreshLabeling();
}
void OnDisable()
{
RefreshLabeling();
}
void Reset()
{
labels.Clear();
useAutoLabeling = false;
autoLabelingSchemeType = string.Empty;
#if UNITY_EDITOR
EditorUtility.SetDirty(gameObject);
#endif
}
///
/// Refresh ground truth generation for the labeling of the attached GameObject. This is necessary when the
/// list of labels changes or when renderers or materials change on objects in the hierarchy.
///
public void RefreshLabeling()
{
labelManager.RefreshLabeling(this);
}
internal void SetInstanceId(uint id)
{
instanceId = id;
}
}
}