1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192 |
- using System;
- using UnityEngine;
- namespace Leap.Unity
- {
- [Serializable]
- public class EyeType
- {
- public EyeType(EyeType.OrderType type)
- {
- this._orderType = type;
- }
- public EyeType.OrderType Type
- {
- get
- {
- return this._orderType;
- }
- }
- public bool IsLeftEye
- {
- get
- {
- if (!this._hasBegun)
- {
- throw new Exception("Cannot call IsLeftEye or IsRightEye before BeginCamera has been called!");
- }
- switch (this._orderType)
- {
- case EyeType.OrderType.LEFT:
- return true;
- case EyeType.OrderType.RIGHT:
- return false;
- case EyeType.OrderType.CENTER:
- return this._isOnFirst;
- default:
- throw new Exception("Unexpected order type " + this._orderType);
- }
- }
- }
- public bool IsRightEye
- {
- get
- {
- return !this.IsLeftEye;
- }
- }
- public void BeginCamera()
- {
- if (!this._hasBegun)
- {
- this._isOnFirst = true;
- this._hasBegun = true;
- }
- else
- {
- this._isOnFirst = !this._isOnFirst;
- }
- }
- public void Reset()
- {
- this._hasBegun = false;
- }
- private const string TARGET_EYE_PROPERTY_NAME = "m_TargetEye";
- private const int TARGET_EYE_LEFT_INDEX = 1;
- private const int TARGET_EYE_RIGHT_INDEX = 2;
- private const int TARGET_EYE_CENTER_INDEX = 3;
- [SerializeField]
- private EyeType.OrderType _orderType = EyeType.OrderType.LEFT;
- private bool _isOnFirst;
- private bool _hasBegun;
- public enum OrderType
- {
- LEFT = 1,
- RIGHT,
- CENTER
- }
- }
- }
|