// Copyright (c) Microsoft Corporation.
// Licensed under the MIT License.
using Microsoft.MixedReality.Toolkit.Input.Utilities;
using Microsoft.MixedReality.Toolkit.Utilities;
using System;
using System.Collections.Generic;
using System.Reflection;
using UnityEditor;
using UnityEngine;
using UnityEngine.UI;
using UEditor = UnityEditor.Editor;
namespace Microsoft.MixedReality.Toolkit.Input
{
///
/// Helper class to get CanvasUtility onto Canvas objects.
///
[CanEditMultipleObjects]
[CustomEditor(typeof(Canvas))]
public class MixedRealityCanvasInspector : UEditor
{
private static readonly GUIContent MakeMRTKCanvas = new GUIContent("Convert to MRTK Canvas", "Configures the GameObject for MRTK use:\n1. Switches Canvas to world space\n2. Removes world space Camera\n3. Ensures GraphicRaycaster component\n4. Ensures CanvasUtility component");
private static readonly GUIContent RemoveMRTKCanvas = new GUIContent("Convert to Unity Canvas", "Configures the GameObject for regular use:\n1. Removes CanvasUtility component\n2. Removes NearInteractionTouchableUnityUI component");
private readonly List graphicsWhichRequireScaleMeshEffect = new List();
private Type canvasEditorType = null;
private UEditor internalEditor = null;
private Canvas canvas = null;
private bool isRootCanvas = false;
private void OnEnable()
{
canvasEditorType = Type.GetType("UnityEditor.CanvasEditor, UnityEditor");
if (canvasEditorType != null)
{
internalEditor = CreateEditor(targets, canvasEditorType);
canvas = target as Canvas;
isRootCanvas = canvas.transform.parent == null || canvas.transform.parent.GetComponentInParent