You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
iot/labs/EasyARDemo/Assets/EasyAR/Scripts/Editor/VideoCameraDeviceEditor.cs

46 lines
2.0 KiB

//================================================================================================================================
//
// Copyright (c) 2015-2019 VisionStar Information Technology (Shanghai) Co., Ltd. All Rights Reserved.
// EasyAR is the registered trademark or trademark of VisionStar Information Technology (Shanghai) Co., Ltd in China
// and other countries for the augmented reality technology developed by VisionStar Information Technology (Shanghai) Co., Ltd.
//
//================================================================================================================================
using UnityEngine;
using UnityEditor;
namespace easyar
{
[CustomEditor(typeof (VideoCameraDevice), true)]
public class VideoCameraDeviceEditor : Editor
{
CameraDevicePreference preference;
public void OnEnable()
{
preference = ((VideoCameraDevice)target).CameraPreference;
}
public override void OnInspectorGUI()
{
DrawDefaultInspector();
if (((VideoCameraDevice)target).CameraOpenMethod == VideoCameraDevice.CameraDeviceOpenMethod.DeviceType)
{
EditorGUILayout.PropertyField(serializedObject.FindProperty("CameraType"), true);
}
else
{
EditorGUILayout.PropertyField(serializedObject.FindProperty("CameraIndex"), true);
}
var cameraPreference = serializedObject.FindProperty("cameraPreference");
EditorGUILayout.PropertyField(cameraPreference, new GUIContent("Camera Preference"), true);
serializedObject.ApplyModifiedProperties();
if(preference != (CameraDevicePreference)cameraPreference.enumValueIndex)
{
((VideoCameraDevice)target).CameraPreference = (CameraDevicePreference)cameraPreference.enumValueIndex;
preference = (CameraDevicePreference)cameraPreference.enumValueIndex;
}
}
}
}