123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473 |
- using System;
- using UnityEngine;
- using UnityEngine.Playables;
- using Object = UnityEngine.Object;
- namespace Animancer
- {
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- [Flags]
- public enum OptionalWarning
- {
-
-
-
-
-
-
-
-
-
-
-
-
-
- ProOnly = 1 << 0,
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- CreateGraphWhileDisabled = 1 << 1,
-
-
-
-
-
-
-
-
-
- CreateGraphDuringGuiEvent = 1 << 2,
-
-
-
-
-
-
-
-
-
-
-
-
- NativeControllerHumanoid = 1 << 3,
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- NativeControllerHybrid = 1 << 4,
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- DuplicateEvent = 1 << 5,
-
-
-
-
-
-
-
-
-
-
-
-
- EndEventInterrupt = 1 << 6,
-
-
-
-
-
-
-
- UselessEvent = 1 << 7,
-
-
-
-
-
-
-
-
-
-
- LockedEvents = 1 << 8,
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- UnsupportedEvents = 1 << 9,
-
-
-
-
-
-
-
-
-
-
-
- UnsupportedSpeed = 1 << 10,
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- UnsupportedIK = 1 << 11,
-
-
-
-
-
-
-
-
-
-
-
- MixerMinChildren = 1 << 12,
-
-
-
-
-
-
-
-
-
-
-
- MixerSynchronizeZeroLength = 1 << 13,
-
-
-
-
-
-
-
-
-
-
-
-
-
- CustomFadeBounds = 1 << 14,
-
-
-
-
-
-
-
-
-
-
- CustomFadeNotNull = 1 << 15,
-
-
-
-
-
-
-
-
-
- AnimatorSpeed = 1 << 16,
-
-
-
-
-
-
-
-
-
-
- UnusedNode = 1 << 17,
-
-
-
-
-
-
-
- PlayableAssetAnimatorBinding = 1 << 18,
-
-
-
-
-
-
-
-
-
- MaxStateDepth = 1 << 19,
-
- All = ~0,
- }
-
- public static partial class Validate
- {
-
- #if UNITY_ASSERTIONS
-
- private static OptionalWarning _DisabledWarnings;
- #endif
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- [System.Diagnostics.Conditional(Strings.Assertions)]
- public static void Disable(this OptionalWarning type)
- {
- #if UNITY_ASSERTIONS
- _DisabledWarnings |= type;
- #endif
- }
-
-
-
-
- [System.Diagnostics.Conditional(Strings.Assertions)]
- public static void Enable(this OptionalWarning type)
- {
- #if UNITY_ASSERTIONS
- _DisabledWarnings &= ~type;
- #endif
- }
-
-
-
-
- [System.Diagnostics.Conditional(Strings.Assertions)]
- public static void SetEnabled(this OptionalWarning type, bool enable)
- {
- #if UNITY_ASSERTIONS
- if (enable)
- type.Enable();
- else
- type.Disable();
- #endif
- }
-
-
-
-
- [System.Diagnostics.Conditional(Strings.Assertions)]
- 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 via the " +
- $"Settings in '{Strings.AnimancerToolsMenuPath}'" +
- $" or 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
- }
-
- #if UNITY_ASSERTIONS
-
-
- public static bool IsEnabled(this OptionalWarning type) => (_DisabledWarnings & type) == 0;
-
-
- public static bool IsDisabled(this OptionalWarning type) => (_DisabledWarnings & type) == type;
-
-
-
-
-
- public static OptionalWarning DisableTemporarily(this OptionalWarning type)
- {
- var previous = _DisabledWarnings;
- type.Disable();
- return ~previous & type;
- }
-
- private const string PermanentlyDisabledWarningsKey = nameof(Animancer) + "." + nameof(PermanentlyDisabledWarnings);
-
- public static OptionalWarning PermanentlyDisabledWarnings
- {
- #if NO_RUNTIME_PLAYER_PREFS && ! UNITY_EDITOR
- get => default;
- set
- {
- _DisabledWarnings = value;
- }
- #else
- get => (OptionalWarning)PlayerPrefs.GetInt(PermanentlyDisabledWarningsKey);
- set
- {
- _DisabledWarnings = value;
- PlayerPrefs.SetInt(PermanentlyDisabledWarningsKey, (int)value);
- }
- #endif
- }
- #if UNITY_EDITOR
- [UnityEditor.InitializeOnLoadMethod]
- #endif
- [RuntimeInitializeOnLoadMethod(RuntimeInitializeLoadType.SubsystemRegistration)]
- private static void InitializePermanentlyDisabledWarnings()
- {
- _DisabledWarnings |= PermanentlyDisabledWarnings;
- }
-
- #endif
-
- }
- }
|