Esempio n. 1
0
        /************************************************************************************************************************/

        /// <summary>[Assert-Only] Disables the specified warnings and returns those that were previously enabled.</summary>
        /// <example><code>
        /// var warnings = OptionalWarning.All.DisableTemporarily();
        /// // Do stuff.
        /// warnings.Enable();
        /// </code></example>
        public static OptionalWarning DisableTemporarily(this OptionalWarning type)
        {
            var previous = type;

            type.Disable();
            return(previous & type);
        }
Esempio n. 2
0
        public static void SetEnabled(this OptionalWarning type, bool enable)
        {
#if UNITY_ASSERTIONS
            if (enable)
            {
                type.Enable();
            }
            else
            {
                type.Disable();
            }
#endif
        }
Esempio n. 3
0
        public static void Log(this OptionalWarning type, string message, object context = null)
        {
#if UNITY_ASSERTIONS
            if (message == null || type.IsDisabled())
            {
                return;
            }

            Debug.LogWarning($"Possible Bug Detected: {message}" +
                             $"\n\nThis warning can be disabled by calling {nameof(Animancer)}.{nameof(OptionalWarning)}.{type}.{nameof(Disable)}()" +
                             " and it will automatically be compiled out of Runtime Builds (except for Development Builds)." +
                             $" More information can be found at {Strings.DocsURLs.OptionalWarning}\n",
                             context as Object);
#endif
        }
Esempio n. 4
0
        /************************************************************************************************************************/

        /// <summary>[Assert-Only] Returns true if all of the specified warning types are disabled.</summary>
        public static bool IsDisabled(this OptionalWarning type) => (_DisabledWarnings & type) != 0;
Esempio n. 5
0
        public static void Enable(this OptionalWarning type)
        {
#if UNITY_ASSERTIONS
            _DisabledWarnings &= ~type;
#endif
        }