/// <summary> /// Returns true if the modes specified by the specified SupportedApplicationModes matches /// the current mode that the code is running in. /// </summary> /// <remarks> /// For example, if the code is currently running in editor mode (for testing in-editor /// simulation), this would return true if modes contained the SupportedApplicationModes.Editor /// bit. /// </remarks> private static bool IsSupportedApplicationMode(SupportedApplicationModes modes) { #if UNITY_EDITOR return((modes & SupportedApplicationModes.Editor) != 0); #else // !UNITY_EDITOR return((modes & SupportedApplicationModes.Player) != 0); #endif }
/// <summary> /// Updates the given SupportedApplicationModes by setting the bit associated with the /// currently active application mode. /// </summary> /// <remarks> /// For example, if the code is currently running in editor mode (for testing in-editor /// simulation), and modes is currently SupportedApplicationModes.Player | SupportedApplicationModes.Editor /// and enabled is 'false', this would return SupportedApplicationModes.Player. /// </remarks> private static SupportedApplicationModes UpdateSupportedApplicationMode(bool enabled, SupportedApplicationModes modes) { #if UNITY_EDITOR var bitValue = enabled ? SupportedApplicationModes.Editor : 0; return((modes & ~SupportedApplicationModes.Editor) | bitValue); #else // !UNITY_EDITOR var bitValue = enabled ? SupportedApplicationModes.Player : 0; return((modes & ~SupportedApplicationModes.Player) | bitValue); #endif }