using System.Collections; using System.Collections.Generic; using UnityEngine; using UnityEngine.Events; /// /// Switches between manual and automatic calibration mode, enabling and disabling objects as specified. /// public class CalibModeSwitcher : MonoBehaviour { /// /// Objects that will only be enabled when in manual mode, and disabled otherwise. /// [Tooltip("Objects that will only be enabled when in manual mode, and disabled otherwise. ")] public List enabledInManualMode = new List(); /// /// Objects that will only be enabled when in automatic mode, and disabled otherwise. /// [Tooltip("Objects that will only be enabled when in automatic mode, and disabled otherwise. ")] public List enabledInAutomaticMode = new List(); /// /// Methods called when switching to manual mode. /// [Space(5)] [Tooltip("Methods called when switching to manual mode. ")] public UnityEvent OnManualModeEntered; /// /// Methods called when switching to automatic mode. /// [Tooltip("Methods called when switching to automatic mode. ")] public UnityEvent OnAutomaticModeEntered; /// /// The mode options, set by SetCalibrationMode. /// public enum MRCalibrationMode { Manual = 0, Automatic = 1 } /// /// Changes the calibration mode to the one provided by enabling/disabling objecs as needed /// and calling relevant events. /// Override that takes an int, so that it can be set via Unity's Inspector. 0 = Manual, 1 = Automatic. /// public void SetCalibrationMode(int newmode) { SetCalibrationMode((MRCalibrationMode)newmode); } /// /// Changes the calibration mode to the one provided by enabling/disabling objecs as needed /// and calling relevant events. /// public void SetCalibrationMode(MRCalibrationMode newmode) { foreach(GameObject mobj in enabledInManualMode) { mobj.SetActive(newmode == MRCalibrationMode.Manual); } foreach(GameObject aobj in enabledInAutomaticMode) { aobj.SetActive(newmode == MRCalibrationMode.Automatic); } if (newmode == MRCalibrationMode.Manual) OnManualModeEntered.Invoke(); else if (newmode == MRCalibrationMode.Automatic) OnAutomaticModeEntered.Invoke(); } }