/* * Copyright (c) Meta Platforms, Inc. and affiliates. * All rights reserved. * * Licensed under the Oculus SDK License Agreement (the "License"); * you may not use the Oculus SDK except in compliance with the License, * which is provided at the time of installation or download, or which * otherwise accompanies this software in either electronic or hard copy form. * * You may obtain a copy of the License at * * https://developer.oculus.com/licenses/oculussdk/ * * Unless required by applicable law or agreed to in writing, the Oculus SDK * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ using System; using System.Collections.Generic; using UnityEngine; /// /// Represents the semantic classification of a . /// /// /// Scene anchors can have one or more string labels associated with them that describes what the anchor represents, /// such as COUCH, or DESK. See for a list of possible labels. /// [DisallowMultipleComponent] [RequireComponent(typeof(OVRSceneAnchor))] public class OVRSemanticClassification : MonoBehaviour, IOVRSceneComponent { private readonly List _labels = new List(); /// /// A list of labels associated with an . /// /// public IReadOnlyList Labels => _labels; /// /// Searches for the given . /// /// /// This method performs a linear search over the . /// /// The label to find /// Returns true if exists in . public bool Contains(string label) { foreach (var item in _labels) { if (item == label) { return true; } } return false; } private void Awake() { if (GetComponent().Space.Valid) { ((IOVRSceneComponent)this).Initialize(); } } void IOVRSceneComponent.Initialize() { if (OVRPlugin.GetSpaceSemanticLabels(GetComponent().Space, out var labels)) { _labels.Clear(); _labels.AddRange(labels.Split(',')); } else { OVRSceneManager.Development.LogWarning(nameof(OVRSemanticClassification), $"[{GetComponent().Uuid}] {nameof(OVRSceneAnchor)} has no semantic labels."); } } }