// Copyright (c) 2015 - 2023 Doozy Entertainment. All Rights Reserved.
// This code can only be used under the standard Unity Asset Store End User License Agreement
// A Copy of the EULA APPENDIX 1 is available at http://unity3d.com/company/legal/as_terms
// ReSharper disable RedundantUsingDirective
using System;
// ReSharper restore RedundantUsingDirective
using System.Collections;
using Doozy.Runtime.Common;
using Doozy.Runtime.Common.Attributes;
using Doozy.Runtime.Common.Utils;
using Doozy.Runtime.Mody;
using Doozy.Runtime.Signals;
using UnityEngine;
// ReSharper disable MemberCanBePrivate.Global
// ReSharper disable UnusedMember.Local
namespace Doozy.Runtime.UIManager.Orientation
{
///
/// Detects the current screen orientation of the target device.
///
[RequireComponent(typeof(RectTransform), typeof(Canvas))]
[DisallowMultipleComponent]
public class OrientationDetector : SingletonBehaviour
{
#if UNITY_EDITOR
[UnityEditor.MenuItem("GameObject/Doozy/Orientation/Orientation Detector", false, 8)]
private static void CreateComponent(UnityEditor.MenuCommand menuCommand)
{
GameObjectUtils.AddToScene("Orientation Detector", true, true);
}
#endif
// ReSharper disable MemberCanBePrivate.Global
private static string streamCategory => "Orientation";
private static string streamName => nameof(OrientationDetector);
// ReSharper restore MemberCanBePrivate.Global
[ClearOnReload]
private static SignalStream s_stream;
/// Signal stream for the OrientationDetector
public static SignalStream stream => s_stream ??= SignalsService.GetStream(streamCategory, streamName);
private RectTransform m_RectTransform;
/// Reference to the RectTransform component
public RectTransform rectTransform => m_RectTransform ? m_RectTransform : m_RectTransform = GetComponent();
private Canvas m_Canvas;
/// Reference to the Canvas component
public Canvas canvas => m_Canvas ? m_Canvas : m_Canvas = GetComponent