// 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
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using Doozy.Runtime.Common.Extensions;
using Doozy.Runtime.Common.Utils;
using Doozy.Runtime.Global;
using Doozy.Runtime.Mody;
using Doozy.Runtime.Reactor;
using Doozy.Runtime.Reactor.Internal;
using Doozy.Runtime.Reactor.Reactions;
using Doozy.Runtime.UIManager.Events;
using Doozy.Runtime.UIManager.Input;
using Doozy.Runtime.UIManager.ScriptableObjects;
using UnityEngine;
using UnityEngine.Events;
using UnityEngine.EventSystems;
using UnityEngine.UI;
// ReSharper disable MemberCanBeProtected.Global
// ReSharper disable MemberCanBePrivate.Global
// ReSharper disable UnusedMember.Local
// ReSharper disable VirtualMemberNeverOverridden.Global
// ReSharper disable UnusedMember.Global
namespace Doozy.Runtime.UIManager.Containers
{
///
/// Basic container with show and hide capabilities.
/// All other containers use this as their base.
///
[RequireComponent(typeof(Canvas))]
// [RequireComponent(typeof(GraphicRaycaster))]
[RequireComponent(typeof(RectTransform))]
[AddComponentMenu("Doozy/UI/Containers/UIContainer")]
[SelectionBase]
public class UIContainer : MonoBehaviour, ICanvasElement, IUseMultiplayerInfo
{
#if UNITY_EDITOR
[UnityEditor.MenuItem("GameObject/Doozy/UI/Containers/UIContainer", false, 8)]
private static void CreateComponent(UnityEditor.MenuCommand menuCommand)
{
GameObjectUtils.AddToScene("UIContainer", false, true);
}
#endif
/// Stream category name
public const string k_StreamCategory = nameof(UIContainer);
/// Default animation duration
public const float k_DefaultAnimationDuration = 0.3f;
#region MultiplayerInfo
[SerializeField] private MultiplayerInfo MultiplayerInfo;
/// Reference to the MultiPlayerInfo component
public MultiplayerInfo multiplayerInfo => MultiplayerInfo;
/// Check if a MultiplayerInfo has been referenced
public bool hasMultiplayerInfo => multiplayerInfo != null;
/// Player index for this component
public int playerIndex => multiplayerMode & hasMultiplayerInfo ? multiplayerInfo.playerIndex : inputSettings.defaultPlayerIndex;
/// Set the a reference to a MultiplayerInfo
/// MultiplayerInfo reference
public void SetMultiplayerInfo(MultiplayerInfo reference) =>
MultiplayerInfo = reference;
#endregion
/// Reference to the UIManager Input Settings
public static UIManagerInputSettings inputSettings => UIManagerInputSettings.instance;
/// Check if Multiplayer Mode is enabled
public static bool multiplayerMode => inputSettings.multiplayerMode;
private Canvas m_Canvas;
/// Reference to the Canvas component attached to this GameObject
public Canvas canvas => m_Canvas ? m_Canvas : m_Canvas = GetComponent