├── .editorconfig ├── .gitignore ├── Editor.meta ├── Editor ├── AutohookDrawer.cs ├── AutohookDrawer.cs.meta ├── AutohookEditorSettingsProvider.cs ├── AutohookEditorSettingsProvider.cs.meta ├── AutohookSettings.cs ├── AutohookSettings.cs.meta ├── CameraProjectionBlenderEditor.cs ├── CameraProjectionBlenderEditor.cs.meta ├── Constants.cs ├── Constants.cs.meta ├── CustomEditorBase.cs ├── CustomEditorBase.cs.meta ├── CustomPopupWindowContent.cs ├── CustomPopupWindowContent.cs.meta ├── CustomPropertyDrawer.cs ├── CustomPropertyDrawer.cs.meta ├── DebugOnlyProcessorEditor.cs ├── DebugOnlyProcessorEditor.cs.meta ├── DrivenTransformEditor.cs ├── DrivenTransformEditor.cs.meta ├── Dynamics.meta ├── Dynamics │ ├── DynamicsGraphRenderer.cs │ ├── DynamicsGraphRenderer.cs.meta │ ├── DynamicsQuaternionDrawer.cs │ ├── DynamicsQuaternionDrawer.cs.meta │ ├── DynamicsSimulationConfig.cs │ ├── DynamicsSimulationConfig.cs.meta │ ├── DynamicsTransformComponentDrawer.cs │ ├── DynamicsTransformComponentDrawer.cs.meta │ ├── DynamicsTransformComponentPresetsPopup.cs │ ├── DynamicsTransformComponentPresetsPopup.cs.meta │ ├── DynamicsTransformEditor.cs │ ├── DynamicsTransformEditor.cs.meta │ ├── DynamicsTransformEditorDropdown.cs │ ├── DynamicsTransformEditorDropdown.cs.meta │ ├── DynamicsTransformMutatorDrawer.cs │ ├── DynamicsTransformMutatorDrawer.cs.meta │ ├── DynamicsVector3Drawer.cs │ ├── DynamicsVector3Drawer.cs.meta │ ├── SecondOrderDrawer.cs │ └── SecondOrderDrawer.cs.meta ├── EditorGUILayoutEx.cs ├── EditorGUILayoutEx.cs.meta ├── EditorGUIUtilityEx.cs ├── EditorGUIUtilityEx.cs.meta ├── EditorIconCache.cs ├── EditorIconCache.cs.meta ├── EditorIconData.cs ├── EditorIconData.cs.meta ├── EditorIcons.cs ├── EditorIcons.cs.meta ├── EnumFlagsDrawer.cs ├── EnumFlagsDrawer.cs.meta ├── EnumMaskDrawer.cs ├── EnumMaskDrawer.cs.meta ├── GUIStyleExtensions.cs ├── GUIStyleExtensions.cs.meta ├── Graph.cs ├── Graph.cs.meta ├── GraphDimensions.cs ├── GraphDimensions.cs.meta ├── GraphLine.cs ├── GraphLine.cs.meta ├── HeldButtonEditor.cs ├── HeldButtonEditor.cs.meta ├── HexDrawer.cs ├── HexDrawer.cs.meta ├── IconSize.cs ├── IconSize.cs.meta ├── InputActionEventsEditor.cs ├── InputActionEventsEditor.cs.meta ├── LayerDrawer.cs ├── LayerDrawer.cs.meta ├── MinMaxDrawer.cs ├── MinMaxDrawer.cs.meta ├── MonoScriptIconInspector.cs ├── MonoScriptIconInspector.cs.meta ├── OptionalPropertyDrawer.cs ├── OptionalPropertyDrawer.cs.meta ├── RangedDrawer.cs ├── RangedDrawer.cs.meta ├── ReadOnlyDrawer.cs ├── ReadOnlyDrawer.cs.meta ├── RectExtensions.cs ├── RectExtensions.cs.meta ├── RequireInterfaceDrawer.cs ├── RequireInterfaceDrawer.cs.meta ├── RipoffParticleUI.meta ├── RipoffParticleUI │ ├── Context.cs │ ├── Context.cs.meta │ ├── Element.cs │ ├── Element.cs.meta │ ├── Header.cs │ ├── Header.cs.meta │ ├── IElement.cs │ ├── IElement.cs.meta │ ├── IPropertyContainer.cs │ ├── IPropertyContainer.cs.meta │ ├── ISimplePropertyContainer.cs │ ├── ISimplePropertyContainer.cs.meta │ ├── PropertyElement.cs │ ├── PropertyElement.cs.meta │ ├── SimpleProperty.cs │ ├── SimpleProperty.cs.meta │ ├── SimplePropertyContainer.cs │ ├── SimplePropertyContainer.cs.meta │ ├── Style.cs │ ├── Style.cs.meta │ ├── SubHeader.cs │ ├── SubHeader.cs.meta │ ├── UIRoot.cs │ └── UIRoot.cs.meta ├── SerializableGuidDrawer.cs ├── SerializableGuidDrawer.cs.meta ├── SerializedObjectExtensions.cs ├── SerializedObjectExtensions.cs.meta ├── SerializedPropertyExtensions.cs ├── SerializedPropertyExtensions.cs.meta ├── SerializedPropertyViewer.cs ├── SerializedPropertyViewer.cs.meta ├── ShowGizmoEditor.cs ├── ShowGizmoEditor.cs.meta ├── StringExtensions.cs ├── StringExtensions.cs.meta ├── TagSelectorDrawer.cs ├── TagSelectorDrawer.cs.meta ├── Toolbar.cs ├── Toolbar.cs.meta ├── ToolbarChoice.cs ├── ToolbarChoice.cs.meta ├── ToolbarToggleState.cs ├── ToolbarToggleState.cs.meta ├── ValueRangeDrawer.cs ├── ValueRangeDrawer.cs.meta ├── ValueRangeLimitEditPopup.cs ├── ValueRangeLimitEditPopup.cs.meta ├── cmdwtf.UnityTools.Editor.asmdef └── cmdwtf.UnityTools.Editor.asmdef.meta ├── LICENSE ├── LICENSE.meta ├── README.md ├── README.md.meta ├── Runtime.meta ├── Runtime ├── ArrayExtensions.cs ├── ArrayExtensions.cs.meta ├── AssemblyInfo.cs ├── AssemblyInfo.cs.meta ├── Attributes.meta ├── Attributes │ ├── AutohookAttribute.cs │ ├── AutohookAttribute.cs.meta │ ├── AutohookContext.cs │ ├── AutohookContext.cs.meta │ ├── AutohookExtensions.cs │ ├── AutohookExtensions.cs.meta │ ├── AutohookInjection.cs │ ├── AutohookInjection.cs.meta │ ├── AutohookShorthands.cs │ ├── AutohookShorthands.cs.meta │ ├── AutohookTemporality.cs │ ├── AutohookTemporality.cs.meta │ ├── AutohookVisibility.cs │ ├── AutohookVisibility.cs.meta │ ├── EnumFlagsAttribute.cs │ ├── EnumFlagsAttribute.cs.meta │ ├── EnumMaskAttribute.cs │ ├── EnumMaskAttribute.cs.meta │ ├── HexAttribute.cs │ ├── HexAttribute.cs.meta │ ├── LayerAttribute.cs │ ├── LayerAttribute.cs.meta │ ├── MinMaxAttribute.cs │ ├── MinMaxAttribute.cs.meta │ ├── RangedAttribute.cs │ ├── RangedAttribute.cs.meta │ ├── ReadOnlyAttribute.cs │ ├── ReadOnlyAttribute.cs.meta │ ├── RequireInterfaceAttribute.cs │ ├── RequireInterfaceAttribute.cs.meta │ ├── TagSelectorAttribute.cs │ └── TagSelectorAttribute.cs.meta ├── Axis.cs ├── Axis.cs.meta ├── CameraProjectionBlender.cs ├── CameraProjectionBlender.cs.meta ├── CollectionExtensions.cs ├── CollectionExtensions.cs.meta ├── Collections.meta ├── Collections │ ├── CollectionHelpers.cs │ ├── CollectionHelpers.cs.meta │ ├── Deque.cs │ ├── Deque.cs.meta │ ├── IndexedQueue.Collection.cs │ ├── IndexedQueue.Collection.cs.meta │ ├── IndexedQueue.Enumerable.cs │ ├── IndexedQueue.Enumerable.cs.meta │ ├── IndexedQueue.cs │ └── IndexedQueue.cs.meta ├── ColorExtensions.cs ├── ColorExtensions.cs.meta ├── ColorTools.cs ├── ColorTools.cs.meta ├── Colors.cs ├── Colors.cs.meta ├── ComponentExtensions.cs ├── ComponentExtensions.cs.meta ├── DateTimeExtensions.cs ├── DateTimeExtensions.cs.meta ├── DebugTools.cs ├── DebugTools.cs.meta ├── DotNetTimeProvider.cs ├── DotNetTimeProvider.cs.meta ├── Dynamics.meta ├── Dynamics │ ├── DeltaTimeSource.cs │ ├── DeltaTimeSource.cs.meta │ ├── DynamicsLineColorAttribute.cs │ ├── DynamicsLineColorAttribute.cs.meta │ ├── DynamicsModifierType.cs │ ├── DynamicsModifierType.cs.meta │ ├── DynamicsPosition.cs │ ├── DynamicsPosition.cs.meta │ ├── DynamicsQuaternion.cs │ ├── DynamicsQuaternion.cs.meta │ ├── DynamicsQuaternionRotationType.cs │ ├── DynamicsQuaternionRotationType.cs.meta │ ├── DynamicsRotation.cs │ ├── DynamicsRotation.cs.meta │ ├── DynamicsScale.cs │ ├── DynamicsScale.cs.meta │ ├── DynamicsTransform.cs │ ├── DynamicsTransform.cs.meta │ ├── DynamicsTransformMutator.cs │ ├── DynamicsTransformMutator.cs.meta │ ├── DynamicsTransformSpace.cs │ ├── DynamicsTransformSpace.cs.meta │ ├── DynamicsUpdateMode.cs │ ├── DynamicsUpdateMode.cs.meta │ ├── DynamicsVector3.cs │ ├── DynamicsVector3.cs.meta │ ├── IDynamicsPreset.cs │ ├── IDynamicsPreset.cs.meta │ ├── IDynamicsSystem.cs │ ├── IDynamicsSystem.cs.meta │ ├── IDynamicsTransformComponent.cs │ ├── IDynamicsTransformComponent.cs.meta │ ├── IMultidimensionalDynamicsProvider.cs │ ├── IMultidimensionalDynamicsProvider.cs.meta │ ├── ISecondOrderSolvingStrategy.cs │ ├── ISecondOrderSolvingStrategy.cs.meta │ ├── ISimulatableDynamicsSystem.cs │ ├── ISimulatableDynamicsSystem.cs.meta │ ├── SamplingMode.cs │ ├── SamplingMode.cs.meta │ ├── SecondOrderDynamics.cs │ ├── SecondOrderDynamics.cs.meta │ ├── SecondOrderDynamicsPreset.cs │ ├── SecondOrderDynamicsPreset.cs.meta │ ├── SecondOrderSettings.cs │ ├── SecondOrderSettings.cs.meta │ ├── SecondOrderSolvingStrategy.cs │ ├── SecondOrderSolvingStrategy.cs.meta │ ├── SecondOrderSolvingStrategyBase.cs │ ├── SecondOrderSolvingStrategyBase.cs.meta │ ├── SecondOrderSolvingStrategyEuler.cs │ ├── SecondOrderSolvingStrategyEuler.cs.meta │ ├── SecondOrderSolvingStrategyEulerStableClampedK2.cs │ ├── SecondOrderSolvingStrategyEulerStableClampedK2.cs.meta │ ├── SecondOrderSolvingStrategyEulerStableForcedIterations.cs │ ├── SecondOrderSolvingStrategyEulerStableForcedIterations.cs.meta │ ├── SecondOrderSolvingStrategyEulerStableNoJitter.cs │ ├── SecondOrderSolvingStrategyEulerStableNoJitter.cs.meta │ ├── SecondOrderSolvingStrategyLinear.cs │ ├── SecondOrderSolvingStrategyLinear.cs.meta │ ├── SecondOrderSolvingStrategyNone.cs │ ├── SecondOrderSolvingStrategyNone.cs.meta │ ├── SecondOrderSolvingStrategyPoleZeroMatching.cs │ ├── SecondOrderSolvingStrategyPoleZeroMatching.cs.meta │ ├── SecondOrderState.cs │ ├── SecondOrderState.cs.meta │ ├── SecondOrderStrategyRegistry.cs │ ├── SecondOrderStrategyRegistry.cs.meta │ ├── StabilityState.cs │ ├── StabilityState.cs.meta │ ├── UnstableHandlingMode.cs │ └── UnstableHandlingMode.cs.meta ├── Filters.meta ├── Filters │ ├── AverageBase.cs │ ├── AverageBase.cs.meta │ ├── Butterworth.cs │ ├── Butterworth.cs.meta │ ├── ButterworthMultiple.cs │ ├── ButterworthMultiple.cs.meta │ ├── ButterworthPassType.cs │ ├── ButterworthPassType.cs.meta │ ├── ButterworthQuaternion.cs │ ├── ButterworthQuaternion.cs.meta │ ├── ButterworthVector2.cs │ ├── ButterworthVector2.cs.meta │ ├── ButterworthVector3.cs │ ├── ButterworthVector3.cs.meta │ ├── ButterworthVector4.cs │ ├── ButterworthVector4.cs.meta │ ├── Butterworth`1.cs │ ├── Butterworth`1.cs.meta │ ├── ExponentialMovingAverage.cs │ ├── ExponentialMovingAverage.cs.meta │ ├── ExponentialMovingAverageTimeBased.cs │ ├── ExponentialMovingAverageTimeBased.cs.meta │ ├── FilterBase.cs │ ├── FilterBase.cs.meta │ ├── FilterExtensions.cs │ ├── FilterExtensions.cs.meta │ ├── FilterSequence.cs │ ├── FilterSequence.cs.meta │ ├── FilterType.cs │ ├── FilterType.cs.meta │ ├── IAverage.cs │ ├── IAverage.cs.meta │ ├── IBiQuadFilter.cs │ ├── IBiQuadFilter.cs.meta │ ├── IFilter.cs │ ├── IFilter.cs.meta │ ├── ModifiedMovingAverage.cs │ ├── ModifiedMovingAverage.cs.meta │ ├── NoiseRejection.cs │ ├── NoiseRejection.cs.meta │ ├── NoiseRejectionReplacementStrategy.cs │ ├── NoiseRejectionReplacementStrategy.cs.meta │ ├── NopAverage.cs │ ├── NopAverage.cs.meta │ ├── NopFilter.cs │ ├── NopFilter.cs.meta │ ├── ScaleF.cs │ ├── ScaleF.cs.meta │ ├── SimpleMovingAverage.cs │ ├── SimpleMovingAverage.cs.meta │ ├── SmoothDamp.cs │ ├── SmoothDamp.cs.meta │ ├── StandardDeviation.cs │ ├── StandardDeviation.cs.meta │ ├── StandardDeviationType.cs │ ├── StandardDeviationType.cs.meta │ ├── StandardDeviationsFromMean.cs │ ├── StandardDeviationsFromMean.cs.meta │ ├── TimeBasedMovingAverage.cs │ ├── TimeBasedMovingAverage.cs.meta │ ├── TransformBase.cs │ ├── TransformBase.cs.meta │ ├── VirtualWindowAverage.cs │ ├── VirtualWindowAverage.cs.meta │ ├── WeightedMovingAverage.cs │ ├── WeightedMovingAverage.cs.meta │ ├── WeightedMovingAverageStrong.cs │ └── WeightedMovingAverageStrong.cs.meta ├── FrequencyCounterBase.cs ├── FrequencyCounterBase.cs.meta ├── GUITools.cs ├── GUITools.cs.meta ├── GameObjectExtensions.cs ├── GameObjectExtensions.cs.meta ├── GameObjectTools.cs ├── GameObjectTools.cs.meta ├── Gizmos.meta ├── Gizmos │ ├── BatchGizmoDrawCommand.cs │ ├── BatchGizmoDrawCommand.cs.meta │ ├── IBatchGizmoDrawCommand.cs │ ├── IBatchGizmoDrawCommand.cs.meta │ ├── ShowIcon.cs │ ├── ShowIcon.cs.meta │ ├── Sorted.cs │ └── Sorted.cs.meta ├── GradientExtensions.cs ├── GradientExtensions.cs.meta ├── IFrequencyCounter.cs ├── IFrequencyCounter.cs.meta ├── ITimeProvider.cs ├── ITimeProvider.cs.meta ├── ITransformComponentDriver.cs ├── ITransformComponentDriver.cs.meta ├── ITransformDriver.cs ├── ITransformDriver.cs.meta ├── ITransformPositionDriver.cs ├── ITransformPositionDriver.cs.meta ├── ITransformRotationDriver.cs ├── ITransformRotationDriver.cs.meta ├── ITransformScaleDriver.cs ├── ITransformScaleDriver.cs.meta ├── Input.meta ├── Input │ ├── DebugOnlyProcessor.cs │ ├── DebugOnlyProcessor.cs.meta │ ├── InputActionEvent.cs │ ├── InputActionEvent.cs.meta │ ├── InputActionEvents.cs │ └── InputActionEvents.cs.meta ├── InstantaneousFrequencyCounter.cs ├── InstantaneousFrequencyCounter.cs.meta ├── LayerExtensions.cs ├── LayerExtensions.cs.meta ├── MarshalExtensions.cs ├── MarshalExtensions.cs.meta ├── Math.cs ├── Math.cs.meta ├── MathExtensions.cs ├── MathExtensions.cs.meta ├── NetLegacy.cs ├── NetLegacy.cs.meta ├── NumberExtensions.cs ├── NumberExtensions.cs.meta ├── ObjectExtensions.cs ├── ObjectExtensions.cs.meta ├── ObjectPool.cs ├── ObjectPool.cs.meta ├── Optional.cs ├── Optional.cs.meta ├── PersistantData.cs ├── PersistantData.cs.meta ├── RuntimePlatformExtensions.cs ├── RuntimePlatformExtensions.cs.meta ├── ScriptableObjectBase.cs ├── ScriptableObjectBase.cs.meta ├── SerializableGuid.cs ├── SerializableGuid.cs.meta ├── StreamingAssets.SettingsCollection.cs ├── StreamingAssets.SettingsCollection.cs.meta ├── StreamingAssets.cs ├── StreamingAssets.cs.meta ├── StringExtensions.cs ├── StringExtensions.cs.meta ├── Tasks.meta ├── Tasks │ ├── UnityTask.cs │ ├── UnityTask.cs.meta │ ├── UnityTaskComponent.cs │ ├── UnityTaskComponent.cs.meta │ ├── UnityTaskEventArgs.cs │ ├── UnityTaskEventArgs.cs.meta │ ├── WaitForCompletion.cs │ └── WaitForCompletion.cs.meta ├── TerrainExtensions.cs ├── TerrainExtensions.cs.meta ├── Texture2DExtensions.cs ├── Texture2DExtensions.cs.meta ├── TimeProviderBase.cs ├── TimeProviderBase.cs.meta ├── TimeProviders.cs ├── TimeProviders.cs.meta ├── TransformExtensions.cs ├── TransformExtensions.cs.meta ├── UI.meta ├── UI │ ├── DefaultPageManager.cs │ ├── DefaultPageManager.cs.meta │ ├── HeldButton.cs │ ├── HeldButton.cs.meta │ ├── IPageContainer.cs │ ├── IPageContainer.cs.meta │ ├── IPageDescription.cs │ ├── IPageDescription.cs.meta │ ├── Page.cs │ ├── Page.cs.meta │ ├── PageContainer.cs │ ├── PageContainer.cs.meta │ ├── PageDescription.cs │ ├── PageDescription.cs.meta │ ├── PageManager.cs │ └── PageManager.cs.meta ├── UniqueNamespaceAttribute.cs ├── UniqueNamespaceAttribute.cs.meta ├── UniqueScriptableObject.cs ├── UniqueScriptableObject.cs.meta ├── UnityTaskManager.meta ├── UnityTaskManager │ ├── InterpolationType.cs │ ├── InterpolationType.cs.meta │ ├── LICENSE │ ├── LICENSE.meta │ ├── ListPool.cs │ ├── ListPool.cs.meta │ ├── ObjectPool.cs │ ├── ObjectPool.cs.meta │ ├── OriginalSource.meta │ ├── OriginalSource │ │ ├── UnityTaskManager.zip │ │ └── UnityTaskManager.zip.meta │ ├── README.md │ ├── README.md.meta │ ├── Task.cs │ ├── Task.cs.meta │ ├── TaskManager.cs │ ├── TaskManager.cs.meta │ ├── TaskState.cs │ └── TaskState.cs.meta ├── UnityThreadingHelper.meta ├── UnityThreadingHelper │ ├── ActionExtension.cs │ ├── ActionExtension.cs.meta │ ├── Channel.cs │ ├── Channel.cs.meta │ ├── Dispatcher.cs │ ├── Dispatcher.cs.meta │ ├── EnumerableExtension.cs │ ├── EnumerableExtension.cs.meta │ ├── EnumeratorExtension.cs │ ├── EnumeratorExtension.cs.meta │ ├── ObjectExtension.cs │ ├── ObjectExtension.cs.meta │ ├── OriginalSource.meta │ ├── OriginalSource │ │ ├── $UnityThreading.zip │ │ └── $UnityThreading.zip.meta │ ├── SwitchTo.cs │ ├── SwitchTo.cs.meta │ ├── Task.cs │ ├── Task.cs.meta │ ├── TaskDistributer.cs │ ├── TaskDistributer.cs.meta │ ├── TaskExtension.cs │ ├── TaskExtension.cs.meta │ ├── Thread.cs │ ├── Thread.cs.meta │ ├── UnityThreadHelper.cs │ ├── UnityThreadHelper.cs.meta │ ├── WaitOneExtension.cs │ └── WaitOneExtension.cs.meta ├── UnityTimeProvider.cs ├── UnityTimeProvider.cs.meta ├── ValueRange.cs ├── ValueRange.cs.meta ├── ValueRangeSampleMode.cs ├── ValueRangeSampleMode.cs.meta ├── VectorExtensions.cs ├── VectorExtensions.cs.meta ├── WWWExtensions.cs ├── WWWExtensions.cs.meta ├── Wildcard.cs ├── Wildcard.cs.meta ├── WindowedFrequencyCounter.cs ├── WindowedFrequencyCounter.cs.meta ├── cmdwtf.UnityTools.asmdef ├── cmdwtf.UnityTools.asmdef.meta ├── iGUITools.cs ├── iGUITools.cs.meta ├── iOSTools.cs └── iOSTools.cs.meta ├── copyright ├── copyright.meta ├── package.json └── package.json.meta /.gitignore: -------------------------------------------------------------------------------- 1 | *.resharper 2 | *.cache 3 | *.suo 4 | *.user 5 | -------------------------------------------------------------------------------- /Editor.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 12c20a4801dd71e4f9848a586ce19c96 3 | folderAsset: yes 4 | DefaultImporter: 5 | externalObjects: {} 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Editor/AutohookDrawer.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 3ddddd5da2847d54a95a11bbf130f69c 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Editor/AutohookEditorSettingsProvider.cs: -------------------------------------------------------------------------------- 1 | using System.Collections.Generic; 2 | 3 | using cmdwtf.UnityTools.Attributes; 4 | 5 | using UnityEditor; 6 | 7 | using UnityEngine; 8 | 9 | namespace cmdwtf.UnityTools.Editor 10 | { 11 | internal static class AutohookEditorSettingsProvider 12 | { 13 | [SettingsProvider] 14 | public static SettingsProvider CreateAutohookSettingsProvider() 15 | { 16 | var provider = new SettingsProvider("Project/Autohook Settings", SettingsScope.Project) 17 | { 18 | guiHandler = (searchContext) => 19 | { 20 | var settings = AutohookSettings.GetOrCreateSettings(); 21 | 22 | EditorGUI.BeginChangeCheck(); 23 | settings.defaultVisibility = 24 | (AutohookVisibility)EditorGUILayout.EnumPopup("Default Visibility", settings.defaultVisibility); 25 | 26 | if (!EditorGUI.EndChangeCheck()) 27 | { 28 | return; 29 | } 30 | 31 | settings.Validate(); 32 | settings.MarkDirty(); 33 | }, 34 | 35 | // Populate the search keywords to enable smart search filtering and label highlighting: 36 | keywords = new HashSet(new[] { "Autohook", "Visibility" }), 37 | }; 38 | 39 | return provider; 40 | } 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /Editor/AutohookEditorSettingsProvider.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: fe04aaac18d944eb85ca37d4775e3c1f 3 | timeCreated: 1555067167 -------------------------------------------------------------------------------- /Editor/AutohookSettings.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: f476b20b8f7542ce93a8201ae6915f22 3 | timeCreated: 1635429196 -------------------------------------------------------------------------------- /Editor/CameraProjectionBlenderEditor.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 7284dacdab8447e4a8c1a6d743496296 3 | timeCreated: 1661452357 -------------------------------------------------------------------------------- /Editor/Constants.cs: -------------------------------------------------------------------------------- 1 | using UnityEditor; 2 | 3 | using UnityEngine; 4 | 5 | namespace cmdwtf.UnityTools.Editor 6 | { 7 | internal static class Constants 8 | { 9 | public static float StandardHorizontalSpacing { get; } = EditorGUIUtility.standardVerticalSpacing * 2; 10 | 11 | public static float StandardLineHeight { get; } = 12 | EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing; 13 | 14 | public const string RefreshSymbol = "↻"; 15 | 16 | public static readonly Color NearlyBlack = new(0.0625f, 0.0625f, 0.0625f, 1f); 17 | public static readonly Color VeryDarkGray = new(0.125f, 0.125f, 0.125f, 1f); 18 | public static readonly Color DarkerGray = new(0.2f, 0.2f, 0.2f, 1f); 19 | public static readonly Color DarkGray = new(0.25f, 0.25f, 0.25f, 1f); 20 | 21 | public static readonly Color DarkRed = new(0.33f, 0f, 0f, 1f); 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /Editor/Constants.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 16479a64333d4e5797d26d936d5753c0 3 | timeCreated: 1655217130 -------------------------------------------------------------------------------- /Editor/CustomEditorBase.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 5e36f4987d9b432089495a7587115f8a 3 | timeCreated: 1631191822 -------------------------------------------------------------------------------- /Editor/CustomPopupWindowContent.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 544b6ee9c9524969be2923b36da0220f 3 | timeCreated: 1657313643 -------------------------------------------------------------------------------- /Editor/CustomPropertyDrawer.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: c6324bc65c6f4e7096f871c1c24eb901 3 | timeCreated: 1634830067 -------------------------------------------------------------------------------- /Editor/DebugOnlyProcessorEditor.cs: -------------------------------------------------------------------------------- 1 | using cmdwtf.UnityTools.Input; 2 | 3 | using UnityEditor; 4 | 5 | using UnityEngine; 6 | using UnityEngine.InputSystem.Editor; 7 | 8 | namespace cmdwtf.UnityTools.Editor 9 | { 10 | public class DebugOnlyProcessorEditor : InputParameterEditor 11 | { 12 | private const string Prefix = "Allow In "; 13 | private readonly GUIContent _inEditorContent = new GUIContent(Prefix + "Editor"); 14 | private readonly GUIContent _inDebugBuildContent = new GUIContent(Prefix + "Debug Build"); 15 | private readonly GUIContent _inReleaseBuildContent = new GUIContent(Prefix + "Release Build"); 16 | 17 | public override void OnGUI() 18 | { 19 | target._allowInReleaseBuild = EditorGUILayout.Toggle(_inReleaseBuildContent, target._allowInReleaseBuild); 20 | 21 | GUITools.PushEnabled(!target._allowInReleaseBuild); 22 | 23 | target._allowInDebugBuild = EditorGUILayout.Toggle(_inDebugBuildContent, target._allowInDebugBuild || target._allowInReleaseBuild); 24 | 25 | GUI.enabled = !target._allowInDebugBuild; 26 | 27 | target._allowInEditor = EditorGUILayout.Toggle(_inEditorContent, target._allowInEditor || target._allowInDebugBuild); 28 | 29 | GUITools.PopEnabled(); 30 | } 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /Editor/DebugOnlyProcessorEditor.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 87b4d589b9244992b71c7beb3cf1f0a6 3 | timeCreated: 1638304279 -------------------------------------------------------------------------------- /Editor/DrivenTransformEditor.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 181961cc88354c36acad7254612b0df6 3 | timeCreated: 1657470683 -------------------------------------------------------------------------------- /Editor/Dynamics.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 2729dbe41ed64cc4ba4d4c37de930e29 3 | timeCreated: 1657563158 -------------------------------------------------------------------------------- /Editor/Dynamics/DynamicsGraphRenderer.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: fc706a2b303f40ae80860bfec6f139d4 3 | timeCreated: 1657674735 -------------------------------------------------------------------------------- /Editor/Dynamics/DynamicsQuaternionDrawer.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 9932afdbb711418f9dd5bb02608359b3 3 | timeCreated: 1657817037 -------------------------------------------------------------------------------- /Editor/Dynamics/DynamicsSimulationConfig.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 02b42b4ac4044648a5f465297175b33e 3 | timeCreated: 1657715440 -------------------------------------------------------------------------------- /Editor/Dynamics/DynamicsTransformComponentDrawer.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 2251d9c9b02f47f99bf4deda94135700 3 | timeCreated: 1657540978 -------------------------------------------------------------------------------- /Editor/Dynamics/DynamicsTransformComponentPresetsPopup.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 4240350e5646485e926315cc37519bb8 3 | timeCreated: 1658165653 -------------------------------------------------------------------------------- /Editor/Dynamics/DynamicsTransformEditor.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: bd967d2c12f6436e8002ab68a8cd266e 3 | timeCreated: 1657491879 -------------------------------------------------------------------------------- /Editor/Dynamics/DynamicsTransformEditorDropdown.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: b6dd2779a33a419281e16f3fb964ac58 3 | timeCreated: 1657890444 -------------------------------------------------------------------------------- /Editor/Dynamics/DynamicsTransformMutatorDrawer.cs: -------------------------------------------------------------------------------- 1 | using System.Collections.Generic; 2 | using System.Linq; 3 | 4 | using cmdwtf.UnityTools.Dynamics; 5 | 6 | using UnityEditor; 7 | 8 | using UnityEngine; 9 | 10 | namespace cmdwtf.UnityTools.Editor.Dynamics 11 | { 12 | [UnityEditor.CustomPropertyDrawer(typeof(DynamicsTransformMutator), useForChildren: true)] 13 | public class DynamicsTransformMutatorDrawer : CustomPropertyDrawer 14 | { 15 | private static readonly HashSet SkipProperties = new() { nameof(DynamicsTransformMutator.enabled) }; 16 | 17 | #region Overrides of CustomPropertyDrawer 18 | 19 | /// 20 | protected override int PropertyLineCount { get; set; } = 0; 21 | 22 | /// 23 | protected override int GetPropertyLineCount(SerializedProperty property, GUIContent label) => 0; 24 | 25 | /// 26 | public override float GetPropertyHeight(SerializedProperty property, GUIContent label) => 0; 27 | 28 | // rather than rendering the property directly, we'll do the kids! 29 | /// 30 | public override void OnGUI(Rect position, SerializedProperty property, GUIContent label) 31 | => ChildrenPropertyFieldsLayout(property, SkipProperties); 32 | 33 | #endregion 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /Editor/Dynamics/DynamicsTransformMutatorDrawer.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 3d86d7db1e5244fb840b5d219f6765d2 3 | timeCreated: 1657564252 -------------------------------------------------------------------------------- /Editor/Dynamics/DynamicsVector3Drawer.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: c0e6b6d8588e49dfb7b759212a00bb4d 3 | timeCreated: 1657817025 -------------------------------------------------------------------------------- /Editor/Dynamics/SecondOrderDrawer.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: ae76188d717ba4441b43635eee9abae6 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Editor/EditorGUILayoutEx.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 76a565d4ac06b254ea9775b81964b808 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Editor/EditorGUIUtilityEx.cs: -------------------------------------------------------------------------------- 1 | using System.Collections.Generic; 2 | 3 | using UnityEditor; 4 | 5 | namespace cmdwtf.UnityTools.Editor 6 | { 7 | /// 8 | /// Utilities specific to the class. 9 | /// 10 | public static class EditorGUIUtilityEx 11 | { 12 | private static readonly Stack _labelWidths = new(); 13 | private static readonly Stack _fieldWidths = new(); 14 | 15 | public static void PushLabelWidth(float width) 16 | { 17 | _labelWidths.Push(EditorGUIUtility.labelWidth); 18 | EditorGUIUtility.labelWidth = width; 19 | } 20 | 21 | public static bool PopLabelWidth() 22 | { 23 | if (!_labelWidths.TryPop(out float width)) 24 | { 25 | return false; 26 | } 27 | 28 | EditorGUIUtility.labelWidth = width; 29 | return true; 30 | 31 | } 32 | 33 | public static void PushFieldWidth(float width) 34 | { 35 | _fieldWidths.Push(EditorGUIUtility.fieldWidth); 36 | EditorGUIUtility.fieldWidth = width; 37 | } 38 | 39 | public static bool PopFieldWidth() 40 | { 41 | if (!_fieldWidths.TryPop(out float width)) 42 | { 43 | return false; 44 | } 45 | 46 | EditorGUIUtility.fieldWidth = width; 47 | return true; 48 | 49 | } 50 | } 51 | } 52 | -------------------------------------------------------------------------------- /Editor/EditorGUIUtilityEx.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: e2fa036feed4470fb2a45b0317f4c031 3 | timeCreated: 1657411188 -------------------------------------------------------------------------------- /Editor/EditorIconCache.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: f0a041a00bbf4a9faac75940e0c2c8e4 3 | timeCreated: 1671126300 -------------------------------------------------------------------------------- /Editor/EditorIconData.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 363ee3fe42a94774807ca3e37fce3c0d 3 | timeCreated: 1671030497 -------------------------------------------------------------------------------- /Editor/EditorIcons.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 8574a4b018e486e4f8509828308d6b97 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {fileID: 4058739119320582626, guid: 0000000000000000d000000000000000, type: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Editor/EnumFlagsDrawer.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 76404bca294c29c42b27fc35678d8b33 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Editor/EnumMaskDrawer.cs: -------------------------------------------------------------------------------- 1 | using cmdwtf.UnityTools.Attributes; 2 | 3 | using UnityEditor; 4 | 5 | using UnityEngine; 6 | 7 | namespace cmdwtf.UnityTools.Editor 8 | { 9 | [UnityEditor.CustomPropertyDrawer(typeof(EnumMaskAttribute))] 10 | public class EnumMaskAttributeDrawer : CustomPropertyDrawer 11 | { 12 | public override void OnGUI(Rect position, SerializedProperty property, GUIContent label) 13 | { 14 | EditorGUI.BeginChangeCheck(); 15 | 16 | int enumValue = EditorGUI.MaskField(position, label, property.intValue, property.enumNames); 17 | 18 | if (EditorGUI.EndChangeCheck()) { 19 | property.intValue = enumValue; 20 | } 21 | } 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /Editor/EnumMaskDrawer.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: a7fb6c3b29119d747b91a50256ad8fd9 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Editor/GUIStyleExtensions.cs: -------------------------------------------------------------------------------- 1 | using UnityEngine; 2 | 3 | namespace cmdwtf.UnityTools.Editor 4 | { 5 | public static class GUIStyleExtensions 6 | { 7 | public static GUIStyle UpperLeft(this GUIStyle s) => s.WithAnchor(TextAnchor.UpperLeft); 8 | public static GUIStyle UpperCenter(this GUIStyle s) => s.WithAnchor(TextAnchor.UpperCenter); 9 | public static GUIStyle UpperRight(this GUIStyle s) => s.WithAnchor(TextAnchor.UpperRight); 10 | public static GUIStyle MiddleLeft(this GUIStyle s) => s.WithAnchor(TextAnchor.MiddleLeft); 11 | public static GUIStyle MiddleCenter(this GUIStyle s) => s.WithAnchor(TextAnchor.MiddleCenter); 12 | public static GUIStyle MiddleRight(this GUIStyle s) => s.WithAnchor(TextAnchor.MiddleRight); 13 | public static GUIStyle LowerLeft(this GUIStyle s) => s.WithAnchor(TextAnchor.LowerLeft); 14 | public static GUIStyle LowerCenter(this GUIStyle s) => s.WithAnchor(TextAnchor.LowerCenter); 15 | public static GUIStyle LowerRight(this GUIStyle s) => s.WithAnchor(TextAnchor.LowerRight); 16 | 17 | public static GUIStyle Left(this GUIStyle s) => s.WithAnchor(TextAnchor.MiddleLeft); 18 | public static GUIStyle Center(this GUIStyle s) => s.WithAnchor(TextAnchor.MiddleCenter); 19 | public static GUIStyle Right(this GUIStyle s) => s.WithAnchor(TextAnchor.MiddleRight); 20 | 21 | 22 | private static GUIStyle WithAnchor(this GUIStyle s, TextAnchor align) 23 | => new(s) { alignment = align,}; 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /Editor/GUIStyleExtensions.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 8b11c909f41844b792ece3575400b426 3 | timeCreated: 1657327192 -------------------------------------------------------------------------------- /Editor/Graph.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: b604a5d6daa9466c91856377279cd4f8 3 | timeCreated: 1657342862 -------------------------------------------------------------------------------- /Editor/GraphDimensions.cs: -------------------------------------------------------------------------------- 1 | namespace cmdwtf.UnityTools.Editor 2 | { 3 | internal struct GraphDimensions 4 | { 5 | public float MinimumX; 6 | public float MaximumX; 7 | public float MinimumY; 8 | public float MaximumY; 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /Editor/GraphDimensions.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: ce1da2663fbd49e183f7b5d59ce1f292 3 | timeCreated: 1657401118 -------------------------------------------------------------------------------- /Editor/GraphLine.cs: -------------------------------------------------------------------------------- 1 | using UnityEngine; 2 | 3 | namespace cmdwtf.UnityTools.Editor 4 | { 5 | internal class GraphLine 6 | { 7 | public Vector3[] UIPoints; 8 | public Color Color; 9 | public bool Focused; 10 | public bool Visible; 11 | public object UserData; 12 | public float[] OriginalSamples; 13 | public float SampleMinimum; 14 | public float SampleMaximum; 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /Editor/GraphLine.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: d53332734ff84d3e9e3ff06fbec87a72 3 | timeCreated: 1657401100 -------------------------------------------------------------------------------- /Editor/HeldButtonEditor.cs: -------------------------------------------------------------------------------- 1 | using cmdwtf.UnityTools.UI; 2 | 3 | using UnityEditor; 4 | using UnityEditor.UI; 5 | 6 | namespace cmdwtf.UnityTools.Editor 7 | { 8 | /// 9 | /// An editor for to allow them to be multi-edited. 10 | /// 11 | [CustomEditor(typeof(HeldButton), true)] 12 | [CanEditMultipleObjects] 13 | public class HeldButtonEditor : ButtonEditor 14 | { 15 | private SerializedProperty _onPressedProperty; 16 | private SerializedProperty _onReleasedProperty; 17 | 18 | #region Overrides of ButtonEditor 19 | 20 | /// 21 | protected override void OnEnable() 22 | { 23 | base.OnEnable(); 24 | _onPressedProperty = serializedObject.FindProperty(nameof(HeldButton._onPress)); 25 | _onReleasedProperty = serializedObject.FindProperty(nameof(HeldButton._onRelease)); 26 | } 27 | 28 | /// 29 | public override void OnInspectorGUI() 30 | { 31 | base.OnInspectorGUI(); 32 | 33 | serializedObject.Update(); 34 | EditorGUILayout.PropertyField(_onPressedProperty); 35 | EditorGUILayout.PropertyField(_onReleasedProperty); 36 | serializedObject.ApplyModifiedProperties(); 37 | } 38 | 39 | #endregion 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /Editor/HeldButtonEditor.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: cd7faad0831845c190c6f350874f54cb 3 | timeCreated: 1670939196 -------------------------------------------------------------------------------- /Editor/HexDrawer.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 466b7acbd435277439e659c5ddd6b72e 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Editor/IconSize.cs: -------------------------------------------------------------------------------- 1 | namespace cmdwtf.UnityTools.Editor 2 | { 3 | internal enum IconSize 4 | { 5 | Small = 0, 6 | Medium, 7 | Large, 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /Editor/IconSize.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 1b944b5156c14ecab597e0512ac1389a 3 | timeCreated: 1671116051 -------------------------------------------------------------------------------- /Editor/InputActionEventsEditor.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 9c968282640542b2a41cfb2504a77310 3 | timeCreated: 1638276553 -------------------------------------------------------------------------------- /Editor/LayerDrawer.cs: -------------------------------------------------------------------------------- 1 | using cmdwtf.UnityTools.Attributes; 2 | 3 | using UnityEditor; 4 | 5 | using UnityEngine; 6 | 7 | namespace cmdwtf.UnityTools.Editor 8 | { 9 | // via https://answers.unity.com/questions/609385/type-for-layer-selection.html 10 | [UnityEditor.CustomPropertyDrawer(typeof(LayerAttribute))] 11 | public class LayerDrawer : CustomPropertyDrawer 12 | { 13 | private const int MinLayerValue = 0; 14 | private const int MaxLayerValue = 31; 15 | 16 | public override void OnGUI(Rect position, SerializedProperty property, GUIContent label) 17 | { 18 | EditorGUI.BeginProperty(position, label, property); 19 | int index = property.intValue; 20 | if (index > MaxLayerValue) 21 | { 22 | Debug.LogWarning($"{nameof(LayerDrawer)}: layer index is to high: '{index}', is set to {MaxLayerValue}"); 23 | index = MaxLayerValue; 24 | } 25 | else if (index < MinLayerValue) 26 | { 27 | Debug.LogWarning($"{nameof(LayerDrawer)}: layer index is to low: '{index}', is set to {MinLayerValue}"); 28 | index = MinLayerValue; 29 | } 30 | property.intValue = EditorGUI.LayerField(position, label, index); 31 | EditorGUI.EndProperty(); 32 | } 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /Editor/LayerDrawer.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 51de8dc45f88492babd910464d140f36 3 | timeCreated: 1636575664 -------------------------------------------------------------------------------- /Editor/MinMaxDrawer.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: aed969fd954a4b47a4927265bf133008 3 | timeCreated: 1631198952 -------------------------------------------------------------------------------- /Editor/MonoScriptIconInspector.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 63997632c4ba425c9b2d25903d053545 3 | timeCreated: 1657433182 -------------------------------------------------------------------------------- /Editor/OptionalPropertyDrawer.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 7f5d9d7540474d6fadf38e1c6a87824b 3 | timeCreated: 1655215133 -------------------------------------------------------------------------------- /Editor/RangedDrawer.cs: -------------------------------------------------------------------------------- 1 | using cmdwtf.UnityTools.Attributes; 2 | 3 | using UnityEditor; 4 | 5 | using UnityEngine; 6 | 7 | namespace cmdwtf.UnityTools.Editor 8 | { 9 | [UnityEditor.CustomPropertyDrawer(typeof(RangedAttribute))] 10 | public class RangedDrawer : CustomPropertyDrawer 11 | { 12 | public override float GetPropertyHeight(SerializedProperty property, GUIContent label) 13 | { 14 | if (attribute is not RangedAttribute boundedCurve) 15 | { 16 | return EditorGUIUtility.singleLineHeight; 17 | } 18 | 19 | return EditorGUIUtility.singleLineHeight * boundedCurve.GUIHeight; 20 | } 21 | 22 | public override void OnGUI(Rect position, SerializedProperty property, GUIContent label) 23 | { 24 | if (attribute is not RangedAttribute boundedCurve) 25 | { 26 | EditorGUI.HelpBox(position, $"Invalid attribute type. Expected {nameof(RangedAttribute)}.", MessageType.Error); 27 | return; 28 | } 29 | 30 | EditorGUI.BeginProperty(position, label, property); 31 | property.animationCurveValue = EditorGUI.CurveField( 32 | position, 33 | label, 34 | property.animationCurveValue, 35 | Color.white, 36 | boundedCurve.Bounds 37 | ); 38 | EditorGUI.EndProperty(); 39 | } 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /Editor/RangedDrawer.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: e2f98f3c1e2a4b74b4e01493abd12af1 3 | timeCreated: 1670862217 -------------------------------------------------------------------------------- /Editor/ReadOnlyDrawer.cs: -------------------------------------------------------------------------------- 1 | using cmdwtf.UnityTools.Attributes; 2 | 3 | using UnityEditor; 4 | 5 | using UnityEngine; 6 | 7 | namespace cmdwtf.UnityTools.Editor 8 | { 9 | [UnityEditor.CustomPropertyDrawer(typeof(ReadOnlyAttribute))] 10 | public class ReadOnlyDrawer : CustomPropertyDrawer 11 | { 12 | public override void OnGUI(Rect position, SerializedProperty property, GUIContent label) 13 | { 14 | GUI.enabled = false; 15 | EditorGUI.PropertyField(position, property, label, true); 16 | GUI.enabled = true; 17 | } 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /Editor/ReadOnlyDrawer.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 062d95f1e7554507ab16e93f8bfeebf6 3 | timeCreated: 1631203048 -------------------------------------------------------------------------------- /Editor/RectExtensions.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 168511b9fac3436f809cf6f57e6dceec 3 | timeCreated: 1634833483 -------------------------------------------------------------------------------- /Editor/RequireInterfaceDrawer.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 60170630379ab834bbc96d67ada27663 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Editor/RipoffParticleUI.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 8a3b342a6f1a41edbd064f4826bfa581 3 | timeCreated: 1657504000 -------------------------------------------------------------------------------- /Editor/RipoffParticleUI/Context.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | 4 | using UnityEditor; 5 | 6 | namespace cmdwtf.UnityTools.Editor.RipoffParticleUI 7 | { 8 | /// 9 | /// The drawing context passed through the steps of rendering a tree. 10 | /// 11 | public class Context 12 | { 13 | private SerializedObject _serializedObject; 14 | 15 | /// 16 | /// The serialized object associated with this draw phase. 17 | /// 18 | public SerializedObject SerializedObject 19 | { 20 | get => _serializedObject; 21 | set 22 | { 23 | _serializedObject = value; 24 | CurrentSerializedProperty = null; 25 | } 26 | } 27 | 28 | /// 29 | /// A helper to quickly access the root property of the . 30 | /// 31 | public SerializedProperty RootProperty => SerializedObject.GetIterator(); 32 | 33 | /// 34 | /// The property currently being referenced by a given . This value should 35 | /// be considered ephemeral, and only valid in the context of any given element. 36 | /// 37 | public SerializedProperty CurrentSerializedProperty { get; set; } 38 | 39 | /// 40 | /// UI Styles for the to use. 41 | /// 42 | public Style Styles { get; } = new(); 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /Editor/RipoffParticleUI/Context.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 9adad89b369445129aba3dcc71f5bbc5 3 | timeCreated: 1657504076 -------------------------------------------------------------------------------- /Editor/RipoffParticleUI/Element.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 0653b7694ffb4b1c9fa170bd88088672 3 | timeCreated: 1657504232 -------------------------------------------------------------------------------- /Editor/RipoffParticleUI/Header.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 269e75c009c741b394f52c2c350e6cfe 3 | timeCreated: 1657504018 -------------------------------------------------------------------------------- /Editor/RipoffParticleUI/IElement.cs: -------------------------------------------------------------------------------- 1 | namespace cmdwtf.UnityTools.Editor.RipoffParticleUI 2 | { 3 | /// 4 | /// An interface representing a UI Element. 5 | /// 6 | public interface IElement 7 | { 8 | 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /Editor/RipoffParticleUI/IElement.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: c396d143994e4bfe97474a6890aca4d3 3 | timeCreated: 1657541889 -------------------------------------------------------------------------------- /Editor/RipoffParticleUI/IPropertyContainer.cs: -------------------------------------------------------------------------------- 1 | namespace cmdwtf.UnityTools.Editor.RipoffParticleUI 2 | { 3 | /// 4 | /// An interface representing a type that contains properties. 5 | /// 6 | public interface IPropertyContainer 7 | { 8 | /// 9 | /// Will be called when the type should draw any properties it contains. 10 | /// 11 | /// The drawing context. 12 | void OnDrawProperties(Context context); 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /Editor/RipoffParticleUI/IPropertyContainer.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: ccec324f431e466b9e510b35ee25fb79 3 | timeCreated: 1657543404 -------------------------------------------------------------------------------- /Editor/RipoffParticleUI/ISimplePropertyContainer.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: a721e158f87b45d59d1d47b5e773aebb 3 | timeCreated: 1657541780 -------------------------------------------------------------------------------- /Editor/RipoffParticleUI/PropertyElement.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 489626d97ef145fdb4cc196c68c05ec4 3 | timeCreated: 1657553218 -------------------------------------------------------------------------------- /Editor/RipoffParticleUI/SimpleProperty.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: b827322e718947ad8780f9ec1910a768 3 | timeCreated: 1657506216 -------------------------------------------------------------------------------- /Editor/RipoffParticleUI/SimplePropertyContainer.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: f0a4c568004d455aa637dcafc414d588 3 | timeCreated: 1657541868 -------------------------------------------------------------------------------- /Editor/RipoffParticleUI/Style.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 3c2e2e6c2c6342bdb11c92726e0743d4 3 | timeCreated: 1657504123 -------------------------------------------------------------------------------- /Editor/RipoffParticleUI/SubHeader.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: abb7d9f27a0641bd8db7285797c31382 3 | timeCreated: 1657504045 -------------------------------------------------------------------------------- /Editor/RipoffParticleUI/UIRoot.cs: -------------------------------------------------------------------------------- 1 | using UnityEditor; 2 | 3 | namespace cmdwtf.UnityTools.Editor.RipoffParticleUI 4 | { 5 | /// 6 | /// An element that represents the root of a UI tree. 7 | /// 8 | public class UIRoot : Element 9 | { 10 | /// 11 | public override bool IsExpanded => true; 12 | 13 | /// 14 | public override bool Visible => true; 15 | 16 | private Context _context = null; 17 | 18 | /// 19 | /// Draws the UI. 20 | /// 21 | /// The serialized object the UI should be drawn for. 22 | /// if the UI detected a change, otherwise . 23 | public bool Draw(SerializedObject serialized) 24 | { 25 | EditorGUI.BeginChangeCheck(); 26 | using EditorGUI.IndentLevelScope indentReset = new(-EditorGUI.indentLevel - 1); 27 | _context ??= new Context(); 28 | _context.SerializedObject = serialized; 29 | OnBeforeDraw(_context); 30 | OnDraw(_context); 31 | OnAfterDraw(_context); 32 | return EditorGUI.EndChangeCheck(); 33 | } 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /Editor/RipoffParticleUI/UIRoot.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 5f61b66ba63346e59703a3c7d0ff99ad 3 | timeCreated: 1657504033 -------------------------------------------------------------------------------- /Editor/SerializableGuidDrawer.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 1ce2c35117a5464d836114b37c8006de 3 | timeCreated: 1638290713 -------------------------------------------------------------------------------- /Editor/SerializedObjectExtensions.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: fe3a618755be4ae3b424eaf5857d1361 3 | timeCreated: 1657474385 -------------------------------------------------------------------------------- /Editor/SerializedPropertyExtensions.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 9711d3cdd00d462b854e272460184e99 3 | timeCreated: 1634831295 -------------------------------------------------------------------------------- /Editor/SerializedPropertyViewer.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 11e1db1ec13241d8ab2476526b88aff8 3 | timeCreated: 1638286775 -------------------------------------------------------------------------------- /Editor/ShowGizmoEditor.cs: -------------------------------------------------------------------------------- 1 | using cmdwtf.UnityTools.Gizmos; 2 | 3 | using UnityEditor; 4 | 5 | namespace cmdwtf.UnityTools.Editor 6 | { 7 | [CustomEditor(typeof(Gizmos.ShowIcon))] 8 | public class ShowGizmoEditor : CustomEditorBase 9 | { 10 | protected override bool ShouldHideOpenButton() => false; 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /Editor/ShowGizmoEditor.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 53660cdd87a54bfaacae7cea464c270d 3 | timeCreated: 1631192048 -------------------------------------------------------------------------------- /Editor/StringExtensions.cs: -------------------------------------------------------------------------------- 1 | using UnityEngine; 2 | 3 | namespace cmdwtf.UnityTools.Editor 4 | { 5 | public static class StringExtensions 6 | { 7 | public static GUIContent ToContent(this string s) => new GUIContent(s, s); 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /Editor/StringExtensions.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: d7f4b34a16364f2dbc29e5ea566b8a49 3 | timeCreated: 1657339615 -------------------------------------------------------------------------------- /Editor/TagSelectorDrawer.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 6ce36f3df9ff47dc8209f07ec507de90 3 | timeCreated: 1631705146 -------------------------------------------------------------------------------- /Editor/Toolbar.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: ec25dba7f90c4232898be5bb2ea91864 3 | timeCreated: 1657818169 -------------------------------------------------------------------------------- /Editor/ToolbarChoice.cs: -------------------------------------------------------------------------------- 1 | using UnityEngine; 2 | 3 | namespace cmdwtf.UnityTools.Editor 4 | { 5 | internal class ToolbarChoice 6 | { 7 | public string Text => Display.text; 8 | public GUIContent Display { get; } 9 | public T Data { get; } 10 | public ToolbarToggleState ToggleState { get; internal set; } 11 | 12 | public ToolbarChoice(T data, bool toggled) 13 | : this(data, toggled.ToToggleState()) 14 | { } 15 | 16 | public ToolbarChoice(string displayText, T data, bool toggled) 17 | : this(new GUIContent(displayText), data, toggled.ToToggleState()) 18 | { } 19 | 20 | public ToolbarChoice(GUIContent display, T data, bool toggled) 21 | : this(display, data, toggled.ToToggleState()) 22 | { } 23 | 24 | public ToolbarChoice(T data, ToolbarToggleState tts = ToolbarToggleState.Normal) 25 | : this(GUIContent.none, data, tts) 26 | { } 27 | 28 | public ToolbarChoice(string displayText, T data, ToolbarToggleState tts = ToolbarToggleState.Normal) 29 | : this(new GUIContent(displayText), data, tts) 30 | { } 31 | 32 | public ToolbarChoice(GUIContent display, T data, ToolbarToggleState tts = ToolbarToggleState.Normal) 33 | { 34 | Data = data; 35 | Display = display; 36 | ToggleState = tts; 37 | } 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /Editor/ToolbarChoice.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: b324889b29fc462f87307f9d0e6cfb68 3 | timeCreated: 1657912031 -------------------------------------------------------------------------------- /Editor/ToolbarToggleState.cs: -------------------------------------------------------------------------------- 1 | namespace cmdwtf.UnityTools.Editor 2 | { 3 | internal enum ToolbarToggleState 4 | { 5 | Normal, 6 | Toggled, 7 | Mixed, 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /Editor/ToolbarToggleState.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 8e5c7902cb4c490680dc39604b75f0b2 3 | timeCreated: 1657912043 -------------------------------------------------------------------------------- /Editor/ValueRangeDrawer.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: d383b2aa16294b3eaf0da893e5aa0d82 3 | timeCreated: 1634829979 -------------------------------------------------------------------------------- /Editor/ValueRangeLimitEditPopup.cs: -------------------------------------------------------------------------------- 1 | using UnityEditor; 2 | 3 | using UnityEngine; 4 | 5 | namespace cmdwtf.UnityTools.Editor 6 | { 7 | public class ValueRangeLimitEditPopup: CustomPopupWindowContent 8 | { 9 | private ValueRange _value; 10 | public ValueRange Value => _value; 11 | 12 | public ValueRangeLimitEditPopup(ValueRange value) 13 | : base("Range Limits") 14 | { 15 | _value = value; 16 | } 17 | 18 | protected override void ShouldDrawGUI(Rect rect) 19 | { 20 | _value.minimumLimit = EditorGUILayout.FloatField($"Minimum Value", _value.minimumLimit); 21 | _value.maximumLimit = EditorGUILayout.FloatField($"Maximum Value", _value.maximumLimit); 22 | 23 | if (_value.maximumLimit < _value.minimumLimit) 24 | { 25 | _value.maximumLimit = _value.minimumLimit; 26 | } 27 | } 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /Editor/ValueRangeLimitEditPopup.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 4ac3960226164c08b426201f55cfc724 3 | timeCreated: 1657312971 -------------------------------------------------------------------------------- /Editor/cmdwtf.UnityTools.Editor.asmdef: -------------------------------------------------------------------------------- 1 | { 2 | "name": "cmdwtf.UnityTools.Editor", 3 | "rootNamespace": "cmdwtf.UnityTools.Editor", 4 | "references": [ 5 | "GUID:c5269df1601f2694ea7cc39324c42246", 6 | "GUID:75469ad4d38634e559750d17036d5f7c" 7 | ], 8 | "includePlatforms": [ 9 | "Editor" 10 | ], 11 | "excludePlatforms": [], 12 | "allowUnsafeCode": false, 13 | "overrideReferences": false, 14 | "precompiledReferences": [], 15 | "autoReferenced": true, 16 | "defineConstraints": [], 17 | "versionDefines": [], 18 | "noEngineReferences": false 19 | } -------------------------------------------------------------------------------- /Editor/cmdwtf.UnityTools.Editor.asmdef.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 0ad47f17b5b91ff4594f31cb97d9b8fa 3 | AssemblyDefinitionImporter: 4 | externalObjects: {} 5 | userData: 6 | assetBundleName: 7 | assetBundleVariant: 8 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | 2 | Copyright (C) 2021 by Chris Marc Dailey (nitz) 3 | 4 | Permission to use, copy, modify, and/or distribute this software for any 5 | purpose with or without fee is hereby granted. 6 | 7 | THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES 8 | WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF 9 | MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR 10 | ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES 11 | WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN 12 | ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF 13 | OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. -------------------------------------------------------------------------------- /LICENSE.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 528548d3debfb0a4e916bbd38570a655 3 | TextScriptImporter: 4 | externalObjects: {} 5 | userData: 6 | assetBundleName: 7 | assetBundleVariant: 8 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # cmd.wtf Unity Tools 2 | -------------------------------------------------------------------------------- /README.md.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: f3e04b111c5d97540a80d6f7312c6076 3 | TextScriptImporter: 4 | externalObjects: {} 5 | userData: 6 | assetBundleName: 7 | assetBundleVariant: 8 | -------------------------------------------------------------------------------- /Runtime.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: d0c8d1c49cd16104182108f86494e029 3 | folderAsset: yes 4 | DefaultImporter: 5 | externalObjects: {} 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Runtime/ArrayExtensions.cs: -------------------------------------------------------------------------------- 1 | namespace cmdwtf.UnityTools 2 | { 3 | public static class ArrayExtensions 4 | { 5 | public static T[] SetAllValues(this T[] array, T value) where T : struct 6 | { 7 | for (int scan = 0; scan < array.Length; scan++) 8 | { 9 | array[scan] = value; 10 | } 11 | 12 | return array; 13 | } 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /Runtime/ArrayExtensions.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 9473417ec4864cda966a5673f415e55f 3 | timeCreated: 1634567261 -------------------------------------------------------------------------------- /Runtime/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | using System.Runtime.CompilerServices; 2 | 3 | [assembly: InternalsVisibleTo("cmdwtf.UnityTools.Editor")] 4 | -------------------------------------------------------------------------------- /Runtime/AssemblyInfo.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: b6f7d537eb4640a49b731007a2cf14c6 3 | timeCreated: 1638279193 -------------------------------------------------------------------------------- /Runtime/Attributes.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: ea90fec5182df974aa68f65551490a77 3 | folderAsset: yes 4 | DefaultImporter: 5 | externalObjects: {} 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Runtime/Attributes/AutohookAttribute.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: d1411ab7542d45346bbf5058b51b7e5e 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Runtime/Attributes/AutohookContext.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 729833e521fe4befa04ab756a7f6295a 3 | timeCreated: 1635427923 -------------------------------------------------------------------------------- /Runtime/Attributes/AutohookExtensions.cs: -------------------------------------------------------------------------------- 1 | using UnityEngine; 2 | 3 | namespace cmdwtf.UnityTools.Attributes 4 | { 5 | public static class AutohookExtensions 6 | { 7 | public static void EnsureRuntimeAutohooks(this MonoBehaviour b) 8 | => AutohookInjection.InjectRuntimeOnDemandReferences(b); 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /Runtime/Attributes/AutohookExtensions.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 7a38340e612621d4bbef880ea8a0977e 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Runtime/Attributes/AutohookInjection.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 92837eae82874b3439fa7e42edef17f0 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Runtime/Attributes/AutohookShorthands.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: c0e89ca03dcee3e419d11bc30a254fb7 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Runtime/Attributes/AutohookTemporality.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | using UnityEngine; 4 | 5 | namespace cmdwtf.UnityTools 6 | { 7 | /// 8 | /// Timing with which should 9 | /// decide when to attempt to hook up components. 10 | /// 11 | [Flags] 12 | public enum AutohookTemporality : uint 13 | { 14 | /// 15 | /// The should be found and attached while in the editor. 16 | /// 17 | Editor = 0x1, 18 | /// 19 | /// The should be found and attached on scene load. 20 | /// 21 | RuntimeSceneLoad = 0x2, 22 | /// 23 | /// The should be found when the object is created. 24 | /// N.B.: This will occur as the attribute itself is created. 25 | /// 26 | RuntimeOnDemand = 0x04, 27 | /// 28 | /// The should be found and attached whenever possible. 29 | /// 30 | All = 0xFFFF_FFFF, 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /Runtime/Attributes/AutohookTemporality.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 888b12487814cb54caac97f73d03e451 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Runtime/Attributes/AutohookVisibility.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace cmdwtf.UnityTools.Attributes 4 | { 5 | /// 6 | /// The visibility of the ed property in the editor. 7 | /// 8 | [Flags] 9 | public enum AutohookVisibility 10 | { 11 | /// 12 | /// The Default visibility, adjustable via autohook settings. 13 | /// 14 | Default = 0x0, 15 | /// 16 | /// The field should be visible and editable. 17 | /// 18 | Visible = 0x1, 19 | /// 20 | /// The field should be visible, but disabled to be non-editable. 21 | /// 22 | Disabled = 0x2, 23 | /// 24 | /// The field should not be shown. 25 | /// 26 | Hidden = 0x4, 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /Runtime/Attributes/AutohookVisibility.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 985b31c083457c944b514671b7254b7f 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Runtime/Attributes/EnumFlagsAttribute.cs: -------------------------------------------------------------------------------- 1 | using UnityEngine; 2 | using System; 3 | 4 | namespace cmdwtf.UnityTools.Attributes 5 | { 6 | [AttributeUsage(AttributeTargets.Field, AllowMultiple = false, Inherited = true)] 7 | public class EnumFlagAttribute : PropertyAttribute { } 8 | } 9 | -------------------------------------------------------------------------------- /Runtime/Attributes/EnumFlagsAttribute.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 78ab25c0109a00f4290da5492a2b8530 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Runtime/Attributes/EnumMaskAttribute.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | using UnityEngine; 4 | 5 | namespace cmdwtf.UnityTools.Attributes 6 | { 7 | [AttributeUsage(AttributeTargets.Field, AllowMultiple = false, Inherited = true)] 8 | public class EnumMaskAttribute : PropertyAttribute { } 9 | } 10 | -------------------------------------------------------------------------------- /Runtime/Attributes/EnumMaskAttribute.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: e972ff1bcb0997943b40f6435751e3f4 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Runtime/Attributes/HexAttribute.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | using UnityEngine; 4 | 5 | namespace cmdwtf.UnityTools.Attributes 6 | { 7 | [AttributeUsage(AttributeTargets.Field, AllowMultiple = false, Inherited = true)] 8 | public class HexAttribute : PropertyAttribute 9 | { 10 | public int MinimumDisplayWidth { get; set; } 11 | 12 | public HexAttribute(int minimumDisplayWidth = -1) 13 | { 14 | MinimumDisplayWidth = minimumDisplayWidth; 15 | } 16 | 17 | public int GetDefaultWidthForType(string propertyTypeName) 18 | { 19 | return propertyTypeName switch 20 | { 21 | "byte" => 2, 22 | "sbyte" => 2, 23 | "char" => 4, 24 | "int" => 8, 25 | "uint" => 8, 26 | "nint" => IntPtr.Size * 2, 27 | "nuint" => UIntPtr.Size * 2, 28 | "long" => 16, 29 | "ulong" => 16, 30 | "short" => 4, 31 | "ushort" => 4, 32 | _ => 0, 33 | }; 34 | } 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /Runtime/Attributes/HexAttribute.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 80e92429a21cd4b41bbb8d802931a8bf 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Runtime/Attributes/LayerAttribute.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | using UnityEngine; 4 | 5 | namespace cmdwtf.UnityTools.Attributes 6 | { 7 | [AttributeUsage(AttributeTargets.Field, AllowMultiple = false, Inherited = true)] 8 | public class LayerAttribute : PropertyAttribute 9 | { 10 | // nothing to speak of. 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /Runtime/Attributes/LayerAttribute.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 0e436b49645ebb9469d0fc694b68bd1a 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Runtime/Attributes/MinMaxAttribute.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | using UnityEngine; 4 | 5 | namespace cmdwtf.UnityTools.Attributes 6 | { 7 | [AttributeUsage(AttributeTargets.Field, AllowMultiple = false, Inherited = true)] 8 | public class MinMaxAttribute : PropertyAttribute 9 | { 10 | public readonly float MinLimit; 11 | public readonly float MaxLimit; 12 | public bool ShowEditRange = false; 13 | public bool ShowDebugValues = false; 14 | 15 | public MinMaxAttribute(int min, int max) 16 | { 17 | MinLimit = min; 18 | MaxLimit = max; 19 | } 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /Runtime/Attributes/MinMaxAttribute.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 62e6dde3ea0f4139b9a36424d37e8da6 3 | timeCreated: 1631198971 -------------------------------------------------------------------------------- /Runtime/Attributes/RangedAttribute.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | using UnityEngine; 4 | 5 | namespace cmdwtf.UnityTools.Attributes 6 | { 7 | [AttributeUsage(AttributeTargets.Field, AllowMultiple = false, Inherited = true)] 8 | public class RangedAttribute : PropertyAttribute 9 | { 10 | public Rect Bounds { get; } 11 | public int GUIHeight { get; } 12 | 13 | public RangedAttribute(float xMin, float xMax, float yMin, float yMax, int height = 1) 14 | { 15 | Bounds = new Rect(xMin, yMin, xMax - xMin, yMax - yMin); 16 | GUIHeight = height; 17 | } 18 | 19 | public RangedAttribute(int height = 1) 20 | : this(0, 1, 0, 1, height) 21 | { } 22 | 23 | public RangedAttribute(float xMax, float yMax, int height = 1) 24 | : this(0, xMax, 0, yMax, height) 25 | { } 26 | 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /Runtime/Attributes/RangedAttribute.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 30ec0d1c15de4d46958db343e2f7502b 3 | timeCreated: 1670862238 -------------------------------------------------------------------------------- /Runtime/Attributes/ReadOnlyAttribute.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | using UnityEngine; 4 | 5 | namespace cmdwtf.UnityTools.Attributes 6 | { 7 | [AttributeUsage(AttributeTargets.Field, AllowMultiple = false, Inherited = true)] 8 | public class ReadOnlyAttribute : PropertyAttribute { } 9 | } 10 | -------------------------------------------------------------------------------- /Runtime/Attributes/ReadOnlyAttribute.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 4b997b0db7464b4cbe0efe9f0dbd23d6 3 | timeCreated: 1631203069 -------------------------------------------------------------------------------- /Runtime/Attributes/RequireInterfaceAttribute.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | using UnityEngine; 4 | 5 | namespace cmdwtf.UnityTools.Attributes 6 | { 7 | /// 8 | /// Attribute that require implementation of the provided interface. 9 | /// 10 | [AttributeUsage(AttributeTargets.Field, AllowMultiple = false, Inherited = true)] 11 | public class RequireInterfaceAttribute : PropertyAttribute 12 | { 13 | // Interface type. 14 | public System.Type requiredType { get; private set; } 15 | 16 | /// 17 | /// Requiring implementation of the interface. 18 | /// 19 | /// Interface type. 20 | public RequireInterfaceAttribute(System.Type type) 21 | { 22 | requiredType = type; 23 | } 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /Runtime/Attributes/RequireInterfaceAttribute.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: c8e0c1dc294aa54419118cddf63db81a 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Runtime/Attributes/TagSelectorAttribute.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | using UnityEngine; 4 | 5 | namespace cmdwtf.UnityTools.Attributes 6 | { 7 | [AttributeUsage(AttributeTargets.Field, AllowMultiple = false, Inherited = true)] 8 | public class TagSelectorAttribute : PropertyAttribute 9 | { 10 | public bool UseDefaultTagFieldDrawer = false; 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /Runtime/Attributes/TagSelectorAttribute.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 447d969b53e84a60bb30cbce0fd771f1 3 | timeCreated: 1631705109 -------------------------------------------------------------------------------- /Runtime/Axis.cs: -------------------------------------------------------------------------------- 1 | namespace cmdwtf.UnityTools 2 | { 3 | /// 4 | /// Represents the axises of vectors. 5 | /// 6 | public enum Axis 7 | { 8 | X = 0, 9 | Y, 10 | Z, 11 | W, 12 | Count, 13 | }; 14 | } 15 | -------------------------------------------------------------------------------- /Runtime/Axis.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: c48ece6a1f4841bf81bab6620d06be82 3 | timeCreated: 1634565940 -------------------------------------------------------------------------------- /Runtime/CameraProjectionBlender.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: b5a015e6f90146f468c308a685f9ff10 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Runtime/CollectionExtensions.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | 4 | namespace cmdwtf.UnityTools 5 | { 6 | public static class CollectionExtensions 7 | { 8 | public static int IndexOf(this IEnumerable collection, T value) 9 | { 10 | // using foreach to prevent full enumeration, 11 | // which might be required to count. 12 | int scan = 0; 13 | foreach (T item in collection) 14 | { 15 | if (Equals(item, value)) 16 | { 17 | return scan; 18 | } 19 | 20 | ++scan; 21 | } 22 | return -1; 23 | } 24 | 25 | public static int IndexOf(this IEnumerable collection, Func predicate) 26 | { 27 | // using foreach to prevent full enumeration, 28 | // which might be required to count. 29 | int scan = 0; 30 | foreach (T item in collection) 31 | { 32 | if (predicate(item)) 33 | { 34 | return scan; 35 | } 36 | 37 | ++scan; 38 | } 39 | return -1; 40 | } 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /Runtime/CollectionExtensions.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 0984c6245380448db9cc8ddb30245fb0 3 | timeCreated: 1638278609 -------------------------------------------------------------------------------- /Runtime/Collections.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 0fca8dda6ac045d46beb0bc3385737c6 3 | folderAsset: yes 4 | DefaultImporter: 5 | externalObjects: {} 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Runtime/Collections/CollectionHelpers.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 2838c7c16d240764e958abcf508a9173 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Runtime/Collections/Deque.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 45b6d391e3618ec419bf51c6fcdaec20 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Runtime/Collections/IndexedQueue.Collection.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: f62cc07870db66d41abe2b7ee3bd4ef5 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Runtime/Collections/IndexedQueue.Enumerable.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 4c606e82b65c9664e81a33af6881d6c2 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Runtime/Collections/IndexedQueue.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 47920398eb5d57241a67e2d038980ee3 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Runtime/ColorExtensions.cs: -------------------------------------------------------------------------------- 1 | using UnityEngine; 2 | 3 | namespace cmdwtf.UnityTools 4 | { 5 | public static class ColorExtensions 6 | { 7 | /// 8 | /// Returns a new color with the same RGB values and modified alpha. 9 | /// 10 | /// The color to use the RGB values from. 11 | /// The alpha value the result should have. 12 | /// The new color with modified alpha. 13 | public static Color WithAlpha(this Color c, float a) 14 | => new(c.r, c.g, c.b, a); 15 | 16 | /// 17 | /// Creates a with a size of 1x1 using the current color. 18 | /// 19 | /// The color to create the texture of. 20 | /// The created . 21 | public static Texture2D ToTexture2DPixel(this Color c) 22 | { 23 | Texture2D texture = new(1, 1); 24 | texture.SetPixel(0, 0, c); 25 | texture.Apply(); 26 | return texture; 27 | } 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /Runtime/ColorExtensions.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: c66a72b44597f3540a151cb9a9709e7e 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Runtime/ColorTools.cs: -------------------------------------------------------------------------------- 1 | using UnityEngine; 2 | 3 | namespace cmdwtf.UnityTools 4 | { 5 | public static class ColorTools 6 | { 7 | public static Color SmoothDamp(Color one, Color two, ref float lerpVal, ref float lerpMult, float speed, float minPerc) 8 | { 9 | lerpVal += Time.deltaTime * speed * lerpMult; 10 | if (lerpVal > 1) 11 | { 12 | lerpVal = 1; 13 | lerpMult *= -1; 14 | } 15 | else if (lerpVal < minPerc) 16 | { 17 | lerpVal = minPerc; 18 | lerpMult *= -1; 19 | } 20 | 21 | return Color.Lerp(two, one, lerpVal); 22 | } 23 | 24 | public static Color FromBytes(byte r, byte g, byte b, byte a = 255) 25 | { 26 | byte[] rgba = { r, g, b, a }; 27 | return FromBytes(rgba); 28 | } 29 | 30 | public static Color FromBytes(params byte[] rgba) 31 | { 32 | int count = rgba.Length; 33 | float r = count >= 1 ? (rgba[0] / 255f) : 0f; 34 | float g = count >= 2 ? (rgba[1] / 255f) : 0f; 35 | float b = count >= 3 ? (rgba[2] / 255f) : 0f; 36 | float a = count >= 4 ? (rgba[3] / 255f) : 1f; 37 | 38 | return new Color(r, g, b, a); 39 | } 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /Runtime/ColorTools.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 6f8ae8426e9845dcbba734fce451eead 3 | timeCreated: 1634565284 -------------------------------------------------------------------------------- /Runtime/Colors.cs: -------------------------------------------------------------------------------- 1 | using UnityEngine; 2 | 3 | namespace cmdwtf.UnityTools 4 | { 5 | public static class Colors 6 | { 7 | // Colors based on default bootstrap colors 8 | 9 | public static Color primary { get; } = ColorTools.FromBytes(0, 123, 255); 10 | public static Color secondary { get; } = ColorTools.FromBytes(108, 117, 125); 11 | public static Color success { get; } = ColorTools.FromBytes(40, 167, 69); 12 | public static Color danger { get; } = ColorTools.FromBytes(220, 53, 69); 13 | public static Color warning { get; } = ColorTools.FromBytes(255, 193, 7); 14 | public static Color info { get; } = ColorTools.FromBytes(23, 162, 184); 15 | public static Color light { get; } = ColorTools.FromBytes(248, 249, 250); 16 | public static Color dark { get; } = ColorTools.FromBytes(52, 58, 64); 17 | public static Color muted { get; } = ColorTools.FromBytes(108, 117, 125); 18 | public static Color white { get; } = Color.white; 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /Runtime/Colors.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 4d24f5ce3ca34f6aa3fefb64630f14c6 3 | timeCreated: 1638290153 -------------------------------------------------------------------------------- /Runtime/ComponentExtensions.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 3564824030e8454c88feacfe444b2beb 3 | timeCreated: 1634819684 -------------------------------------------------------------------------------- /Runtime/DateTimeExtensions.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace cmdwtf.UnityTools 4 | { 5 | public static class DateTimeExtensions 6 | { 7 | private const string NiceFileStringFormat = "yyyy-MM-dd_HH-mm-ss"; 8 | public static string ToNiceFileString(this DateTime dt) => dt.ToString(NiceFileStringFormat); 9 | public static string ToNiceFileString(this DateTimeOffset dto) => dto.ToString(NiceFileStringFormat); 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /Runtime/DateTimeExtensions.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 396a7a60bfb542059136b3109b2a37d8 3 | timeCreated: 1634567619 -------------------------------------------------------------------------------- /Runtime/DebugTools.cs: -------------------------------------------------------------------------------- 1 | using System.Linq; 2 | 3 | using UnityEngine; 4 | 5 | namespace cmdwtf.UnityTools 6 | { 7 | public static class DebugTools 8 | { 9 | public static void DrawAxis(Vector3 position = default, float scale = 1.0f) 10 | { 11 | Debug.DrawRay(position, Vector3.up * scale, Color.green); 12 | Debug.DrawRay(position, Vector3.right * scale, Color.red); 13 | Debug.DrawRay(position, Vector3.forward * scale, Color.blue); 14 | } 15 | 16 | public enum LogStackTraceLevel {Log = 0, Warning, Error}; 17 | public static void LogStackTrace(LogStackTraceLevel lvl = LogStackTraceLevel.Warning) 18 | { 19 | var stackTrace = new System.Diagnostics.StackTrace(1); 20 | System.Diagnostics.StackFrame[] stackFrames = stackTrace.GetFrames(); 21 | 22 | string msg = ""; 23 | if (stackFrames != null) 24 | { 25 | msg = stackFrames.Aggregate(msg, (current, stackFrame) => current + $"{stackFrame.GetMethod().Name}\n"); 26 | } 27 | 28 | switch (lvl) 29 | { 30 | case LogStackTraceLevel.Log: 31 | Debug.Log(msg); 32 | break; 33 | case LogStackTraceLevel.Warning: 34 | Debug.LogWarning(msg); 35 | break; 36 | case LogStackTraceLevel.Error: 37 | Debug.LogError(msg); 38 | break; 39 | default: 40 | Debug.LogError(msg); 41 | break; 42 | } 43 | } 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /Runtime/DebugTools.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 39633c02380349f097cd8e98c5154c83 3 | timeCreated: 1634565207 -------------------------------------------------------------------------------- /Runtime/DotNetTimeProvider.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace cmdwtf.UnityTools 4 | { 5 | public class DotNetTimeProvider : TimeProviderBase 6 | { 7 | protected readonly TimeSpan Epoch = new TimeSpan(new DateTime(1970, 1, 1).Ticks); 8 | 9 | public override double NowSeconds => DateTimeOffset.Now.TimeOfDay.TotalSeconds; 10 | 11 | public override long UnixTimestamp 12 | { 13 | get 14 | { 15 | TimeSpan unixTicks = new TimeSpan(DateTimeOffset.UtcNow.Ticks) - Epoch; 16 | return (long) System.Math.Round(unixTicks.TotalSeconds); 17 | } 18 | } 19 | 20 | public DotNetTimeProvider() { } 21 | 22 | public DotNetTimeProvider(double period = 0) 23 | : base(period) { } 24 | 25 | public DotNetTimeProvider(float periodF = 0) 26 | : base(periodF) { } 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /Runtime/DotNetTimeProvider.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 23669be270ed469299957efb2e19ea33 3 | timeCreated: 1637170623 -------------------------------------------------------------------------------- /Runtime/Dynamics.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 10d7569168e147b7961dfe53560d4b24 3 | timeCreated: 1657386612 -------------------------------------------------------------------------------- /Runtime/Dynamics/DeltaTimeSource.cs: -------------------------------------------------------------------------------- 1 | namespace cmdwtf.UnityTools.Dynamics 2 | { 3 | /// 4 | /// Potential sources of getting changed time for dynamics systems. 5 | /// 6 | public enum DeltaTimeSource 7 | { 8 | Zero, 9 | DeltaTime, 10 | UnscaledDeltaTime, 11 | FixedUnscaledDeltaTime, 12 | FixedDeltaTime, 13 | MaximumDeltaTime, 14 | SmoothDeltaTime, 15 | MaximumParticleDeltaTime, 16 | Custom, 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /Runtime/Dynamics/DeltaTimeSource.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: de7b9d1c70614fe3a38f32c1a6e83fd0 3 | timeCreated: 1657547199 -------------------------------------------------------------------------------- /Runtime/Dynamics/DynamicsLineColorAttribute.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Drawing; 3 | using System.Reflection; 4 | 5 | using UnityEngine; 6 | 7 | using Color = UnityEngine.Color; 8 | 9 | namespace cmdwtf.UnityTools.Attributes 10 | { 11 | // ReSharper disable once InconsistentNaming 12 | [AttributeUsage(AttributeTargets.Field, AllowMultiple = false, Inherited = true)] 13 | public class DynamicsLineColorAttribute : PropertyAttribute 14 | { 15 | public Color color { get; private set; } 16 | 17 | public DynamicsLineColorAttribute(KnownColor knownColor) 18 | { 19 | var sdColor = System.Drawing.Color.FromKnownColor(knownColor); 20 | const float byteMax = byte.MaxValue; 21 | color = new Color( 22 | sdColor.R / byteMax, 23 | sdColor.G / byteMax, 24 | sdColor.B / byteMax, 25 | sdColor.A / byteMax 26 | ); 27 | } 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /Runtime/Dynamics/DynamicsLineColorAttribute.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 24986ea4a60247218903228d5f9c7afa 3 | timeCreated: 1657221666 -------------------------------------------------------------------------------- /Runtime/Dynamics/DynamicsModifierType.cs: -------------------------------------------------------------------------------- 1 | namespace cmdwtf.UnityTools.Dynamics 2 | { 3 | /// 4 | /// The type of data for a dynamics system to act on. 5 | /// 6 | public enum DynamicsModifierType 7 | { 8 | Local, 9 | World, 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /Runtime/Dynamics/DynamicsModifierType.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: ec6f2a6d39254b89b2f075092d8856c4 3 | timeCreated: 1657547223 -------------------------------------------------------------------------------- /Runtime/Dynamics/DynamicsPosition.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | using UnityEngine; 4 | 5 | namespace cmdwtf.UnityTools.Dynamics 6 | { 7 | [Serializable] 8 | public sealed class DynamicsPosition 9 | : DynamicsTransformMutator 10 | { 11 | #region Overrides of DynamicsTransformMutator 12 | 13 | /// 14 | protected override Vector3 GetSourceValue(ref Transform source) 15 | => space switch 16 | { 17 | Space.Self => source.localPosition, 18 | _ => source.position, 19 | }; 20 | 21 | /// 22 | protected override void SetDestinationValue(ref Transform destination, Vector3 value) 23 | { 24 | if (space == Space.Self) 25 | { 26 | destination.localPosition = value; 27 | } 28 | else 29 | { 30 | destination.position = value; 31 | } 32 | } 33 | 34 | #endregion 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /Runtime/Dynamics/DynamicsPosition.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 429e12bd56f14dcf9ad8d7c969ee68ba 3 | timeCreated: 1657550216 -------------------------------------------------------------------------------- /Runtime/Dynamics/DynamicsQuaternion.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 533fceff625f47c3acab76d22a5a88ca 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {fileID: -7485488908267385562, guid: 0000000000000000d000000000000000, type: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Runtime/Dynamics/DynamicsQuaternionRotationType.cs: -------------------------------------------------------------------------------- 1 | using UnityEngine; 2 | 3 | namespace cmdwtf.UnityTools.Dynamics 4 | { 5 | /// 6 | /// Different methods of simulating dynamics on rotation quaternions. 7 | /// 8 | public enum DynamicsQuaternionRotationType 9 | { 10 | [InspectorName("Quaternion")] 11 | [Tooltip("This will simulate the dynamics of each component of the quaternion individually.")] 12 | QuaternionComponents, 13 | 14 | [InspectorName("Forward and Upwards")] 15 | [Tooltip("This simulates dynamics for two individual vectors, one representing the rotation's forward, " + 16 | "one representing the rotation's up. Each of those can be configured individually.")] 17 | ForwardAndUpward, 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /Runtime/Dynamics/DynamicsQuaternionRotationType.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: b76d0f58913746ae9cc60ae4897218a6 3 | timeCreated: 1657488653 -------------------------------------------------------------------------------- /Runtime/Dynamics/DynamicsRotation.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | using UnityEngine; 4 | 5 | namespace cmdwtf.UnityTools.Dynamics 6 | { 7 | [Serializable] 8 | public sealed class DynamicsRotation 9 | : DynamicsTransformMutator 10 | { 11 | #region Overrides of DynamicsTransformMutator 12 | 13 | /// 14 | protected override Quaternion GetSourceValue(ref Transform source) 15 | => space switch 16 | { 17 | Space.Self => source.localRotation, 18 | _ => source.rotation, 19 | }; 20 | 21 | /// 22 | protected override void SetDestinationValue(ref Transform destination, Quaternion value) 23 | { 24 | if (space == Space.Self) 25 | { 26 | destination.localRotation = value; 27 | } 28 | else 29 | { 30 | destination.rotation = value; 31 | } 32 | } 33 | 34 | #endregion 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /Runtime/Dynamics/DynamicsRotation.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: a05713519cfb48289e0f2df89dd800e4 3 | timeCreated: 1657550223 -------------------------------------------------------------------------------- /Runtime/Dynamics/DynamicsScale.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | using UnityEngine; 4 | 5 | namespace cmdwtf.UnityTools.Dynamics 6 | { 7 | [Serializable] 8 | public sealed class DynamicsScale 9 | : DynamicsTransformMutator 10 | { 11 | #region Overrides of DynamicsTransformMutator 12 | 13 | /// 14 | protected override Vector3 GetSourceValue(ref Transform source) 15 | => space switch 16 | { 17 | Space.Self => source.localScale, 18 | _ => source.lossyScale, 19 | }; 20 | 21 | /// 22 | protected override void SetDestinationValue(ref Transform destination, Vector3 value) 23 | => destination.localScale = value; 24 | 25 | #endregion 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /Runtime/Dynamics/DynamicsScale.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: dfa5b7a371704e449ef39144ac83083c 3 | timeCreated: 1657550228 -------------------------------------------------------------------------------- /Runtime/Dynamics/DynamicsTransform.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 639fe01bb2ef4335be6d2757fb204ae1 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {fileID: 148978298399363526, guid: 0000000000000000d000000000000000, type: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Runtime/Dynamics/DynamicsTransformMutator.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: e6d02f80a64f48ab967e059e7537fe41 3 | timeCreated: 1657547317 -------------------------------------------------------------------------------- /Runtime/Dynamics/DynamicsTransformSpace.cs: -------------------------------------------------------------------------------- 1 | using UnityEngine; 2 | 3 | namespace cmdwtf.UnityTools.Dynamics 4 | { 5 | public enum DynamicsTransformSpace 6 | { 7 | World = Space.World, 8 | Self = Space.Self, 9 | Child, 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /Runtime/Dynamics/DynamicsTransformSpace.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 155f89b16fc34c1f8890056100e6d2b2 3 | timeCreated: 1657829599 -------------------------------------------------------------------------------- /Runtime/Dynamics/DynamicsUpdateMode.cs: -------------------------------------------------------------------------------- 1 | using UnityEngine; 2 | 3 | namespace cmdwtf.UnityTools.Dynamics 4 | { 5 | /// 6 | /// Modes that a dynamic system may use to update objects. 7 | /// 8 | public enum DynamicsUpdateMode 9 | { 10 | [InspectorName("Do Not Modify")] 11 | [Tooltip("The selected value will not be modified.")] 12 | Ignored, 13 | 14 | [InspectorName("Copy target value on Update()")] 15 | [Tooltip("The selected value will not be modified, and instead just copied from the target on Update().")] 16 | CopyOnUpdate, 17 | 18 | [InspectorName("Modify on Update()")] 19 | [Tooltip("The target transform will be used to update the system on the Update() message.")] 20 | Update, 21 | 22 | [InspectorName("Modify on FixedUpdate()")] 23 | [Tooltip("The target transform will be used to update the system on the FixedUpdate() message.")] 24 | FixedUpdate, 25 | 26 | [InspectorName("Modify on LateUpdate()")] 27 | [Tooltip("The target transform will be used to update the system on the LateUpdate() message.")] 28 | LateUpdate, 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /Runtime/Dynamics/DynamicsUpdateMode.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: c54fa70732574b8280a1c64fd7945938 3 | timeCreated: 1657501832 -------------------------------------------------------------------------------- /Runtime/Dynamics/DynamicsVector3.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 587d728ff71f4f45af1f9f6c4f821485 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {fileID: -7343420614739014117, guid: 0000000000000000d000000000000000, type: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Runtime/Dynamics/IDynamicsPreset.cs: -------------------------------------------------------------------------------- 1 | namespace cmdwtf.UnityTools.Dynamics 2 | { 3 | public interface IDynamicsPreset 4 | { 5 | 6 | } 7 | } 8 | -------------------------------------------------------------------------------- /Runtime/Dynamics/IDynamicsPreset.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 9d9ea682e76f4be8b2bdc51af4e804bd 3 | timeCreated: 1658170216 -------------------------------------------------------------------------------- /Runtime/Dynamics/IDynamicsSystem.cs: -------------------------------------------------------------------------------- 1 | namespace cmdwtf.UnityTools.Dynamics 2 | { 3 | /// 4 | /// An interface that describes a type that implements a dynamics system. 5 | /// 6 | public interface IDynamicsSystem 7 | { 8 | /// 9 | /// Resets the system. 10 | /// 11 | void Reset(); 12 | 13 | /// 14 | /// The current value of the system. 15 | /// 16 | float Value { get; } 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /Runtime/Dynamics/IDynamicsSystem.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: c7134019c26847358df4f4cec05dd02c 3 | timeCreated: 1657559907 -------------------------------------------------------------------------------- /Runtime/Dynamics/IDynamicsTransformComponent.cs: -------------------------------------------------------------------------------- 1 | namespace cmdwtf.UnityTools.Dynamics 2 | { 3 | public interface IDynamicsTransformComponent 4 | { 5 | 6 | } 7 | 8 | public interface IDynamicsTransformComponent 9 | : IDynamicsTransformComponent where T : struct 10 | { 11 | T Value { get; } 12 | 13 | void Reset(T resetValue); 14 | 15 | T Update(float deltaTime, T current, T target); 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /Runtime/Dynamics/IDynamicsTransformComponent.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 98d8a5be9768442ca34f7f6f9394d07d 3 | timeCreated: 1657546347 -------------------------------------------------------------------------------- /Runtime/Dynamics/IMultidimensionalDynamicsProvider.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | 4 | namespace cmdwtf.UnityTools.Dynamics 5 | { 6 | /// 7 | /// An interface implemented by types that provide a number 8 | /// of dynamic system dimensions. 9 | /// 10 | public interface IMultidimensionalDynamicsProvider 11 | { 12 | int DimensionCount { get; } 13 | IDynamicsSystem GetDynamicsSystemForDimension(int dimensionIndex); 14 | IEnumerable GetDynamicsEnumerator(); 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /Runtime/Dynamics/IMultidimensionalDynamicsProvider.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 368e6a45f6c84f77b96868f7e4d4e5fe 3 | timeCreated: 1657559742 -------------------------------------------------------------------------------- /Runtime/Dynamics/ISecondOrderSolvingStrategy.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 975c3c6b837c4d6ab78f69bedb4d0e46 3 | timeCreated: 1657233893 -------------------------------------------------------------------------------- /Runtime/Dynamics/ISimulatableDynamicsSystem.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: a024439e41f04f2c805ad3fd28fbdb3a 3 | timeCreated: 1657675352 -------------------------------------------------------------------------------- /Runtime/Dynamics/SamplingMode.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 590f31fd675445e3afccf5f2627c1bef 3 | timeCreated: 1657403898 -------------------------------------------------------------------------------- /Runtime/Dynamics/SecondOrderDynamics.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: cb2818f8ab6a8fc44857345696cb1ce7 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Runtime/Dynamics/SecondOrderDynamicsPreset.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: cf2774e9ccdc4942a581fc8de346a038 3 | timeCreated: 1658170008 -------------------------------------------------------------------------------- /Runtime/Dynamics/SecondOrderSettings.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 29ac3b46b0124c4d80d5e020f83efe8d 3 | timeCreated: 1657403858 -------------------------------------------------------------------------------- /Runtime/Dynamics/SecondOrderSolvingStrategy.cs: -------------------------------------------------------------------------------- 1 | using UnityEngine; 2 | 3 | namespace cmdwtf.UnityTools.Dynamics 4 | { 5 | public enum SecondOrderSolvingStrategy 6 | { 7 | [InspectorName("")] // don't allow the user to select unknown in the editor. 8 | Unknown = -1, 9 | [Tooltip("No strategy, will always return zero.")] 10 | None = 0, 11 | [Tooltip("Linear strategy, modeling y=x.")] 12 | Linear, 13 | [Tooltip("Solve the second order system using the Semi-implicit Euler method.")] 14 | SemiImplicitEulerUnstable, 15 | [Tooltip("Solve the second order system using the Semi-implicit Euler method, with a forced minimum time step " + 16 | "to prevent instabilities.")] 17 | SemiImplicitEulerStableForcedIterations, 18 | [Tooltip("Solve the second order system using the Semi-implicit Euler method, with a constrained k2 constant " + 19 | "to prevent instabilities.")] 20 | SemiImplicitEulerStableClampedK2, 21 | [Tooltip("Solve the second order system using the Semi-implicit Euler method, with a constrained k2 constant, " + 22 | "that takes into account negative eigenvalues to prevent instabilities and jitter.")] 23 | SemiImplicitEulerStableClampedK2NoJitter, 24 | [Tooltip("Solve the second order system using the pole-zero matching (a.k.a. matched Z-transform method). " + 25 | "This will be more accurate than the Euler methods (especially for high velocities), " + 26 | "but be more computationally expensive.")] 27 | PoleZeroMatching, 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /Runtime/Dynamics/SecondOrderSolvingStrategy.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 6c197be7a13a4107aeeb4425bb430494 3 | timeCreated: 1657402777 -------------------------------------------------------------------------------- /Runtime/Dynamics/SecondOrderSolvingStrategyBase.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: daa95f3636cc4794b4690156501a8f91 3 | timeCreated: 1657403620 -------------------------------------------------------------------------------- /Runtime/Dynamics/SecondOrderSolvingStrategyEuler.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: db7322a3149c4dba9ba69a5b84cbc66b 3 | timeCreated: 1657404488 -------------------------------------------------------------------------------- /Runtime/Dynamics/SecondOrderSolvingStrategyEulerStableClampedK2.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 3037090d4f4a4152ac82e9bd67931990 3 | timeCreated: 1657404511 -------------------------------------------------------------------------------- /Runtime/Dynamics/SecondOrderSolvingStrategyEulerStableForcedIterations.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 6216fe9b3274458688060926e99f30a9 3 | timeCreated: 1657404507 -------------------------------------------------------------------------------- /Runtime/Dynamics/SecondOrderSolvingStrategyEulerStableNoJitter.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: c45c7b6e89fc4fceafc7be2ba28215ed 3 | timeCreated: 1657404517 -------------------------------------------------------------------------------- /Runtime/Dynamics/SecondOrderSolvingStrategyLinear.cs: -------------------------------------------------------------------------------- 1 | using JetBrains.Annotations; 2 | 3 | namespace cmdwtf.UnityTools.Dynamics 4 | { 5 | /// 6 | /// A simple solving strategy to test y=x. 7 | /// 8 | [UsedImplicitly] 9 | internal class SecondOrderSolvingStrategyLinear 10 | : SecondOrderSolvingStrategyBase 11 | { 12 | /// 13 | public override SecondOrderSolvingStrategy StrategyType => SecondOrderSolvingStrategy.Linear; 14 | 15 | /// 16 | public override void RecalculateConstants(ref SecondOrderState state, float initialValue) { } 17 | 18 | /// 19 | protected override void OnNewValue(ref SecondOrderState state, float deltaTime, float targetValue, float targetVelocity) 20 | => state.CurrentValue = targetValue; 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /Runtime/Dynamics/SecondOrderSolvingStrategyLinear.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 08cf481cdd7a42ef969ad90d4fdcc486 3 | timeCreated: 1657404430 -------------------------------------------------------------------------------- /Runtime/Dynamics/SecondOrderSolvingStrategyNone.cs: -------------------------------------------------------------------------------- 1 | using JetBrains.Annotations; 2 | 3 | namespace cmdwtf.UnityTools.Dynamics 4 | { 5 | /// 6 | /// A simple solving strategy to test y=0. 7 | /// 8 | [UsedImplicitly] 9 | internal class SecondOrderSolvingStrategyNone 10 | : SecondOrderSolvingStrategyBase 11 | { 12 | /// 13 | public override SecondOrderSolvingStrategy StrategyType => SecondOrderSolvingStrategy.None; 14 | 15 | /// 16 | public override void RecalculateConstants(ref SecondOrderState state, float initialValue) { } 17 | 18 | /// 19 | protected override void OnNewValue(ref SecondOrderState state, float deltaTime, float targetValue, float targetVelocity) 20 | { 21 | // intentional noop 22 | } 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /Runtime/Dynamics/SecondOrderSolvingStrategyNone.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: acc5a35f98fc4ff68aff3a74635e09f8 3 | timeCreated: 1657404415 -------------------------------------------------------------------------------- /Runtime/Dynamics/SecondOrderSolvingStrategyPoleZeroMatching.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 932b1877f1c14d22ad1d9a68cedd68f0 3 | timeCreated: 1657404523 -------------------------------------------------------------------------------- /Runtime/Dynamics/SecondOrderState.cs: -------------------------------------------------------------------------------- 1 | namespace cmdwtf.UnityTools.Dynamics 2 | { 3 | /// 4 | /// A collection of data representing the a current state of a second order system. 5 | /// 6 | internal struct SecondOrderState 7 | { 8 | // user input 9 | public float F; 10 | public float Z; 11 | public float R; 12 | public float InitialValue; 13 | public float TargetValue; 14 | public float PreviousTargetValue; 15 | 16 | // system input 17 | public float DeltaTime; 18 | public float ElapsedTime; 19 | 20 | // system output 21 | public float CurrentValue; // at t0: initial value 22 | public float CurrentVelocity; // first derivative of iv 23 | public float LastStableValue; 24 | 25 | // function constants calculated from f, ζ, and r. 26 | public float K1; 27 | public float K2; 28 | public float K3; 29 | 30 | // calculated constants for pole zero matching. 31 | public float W; 32 | public float D; 33 | 34 | // the maximum time step for any one solve iteration 35 | public float MaximumTimeStep; 36 | 37 | // meta about the current state of the system as a whole. 38 | internal bool _isDeserializing; 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /Runtime/Dynamics/SecondOrderState.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 0310fd3cc9624ce1bf75782edb8a90f5 3 | timeCreated: 1657403881 -------------------------------------------------------------------------------- /Runtime/Dynamics/SecondOrderStrategyRegistry.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: aad8c7b6cbce4c04b0b2aad09bd9343a 3 | timeCreated: 1657403456 -------------------------------------------------------------------------------- /Runtime/Dynamics/StabilityState.cs: -------------------------------------------------------------------------------- 1 | using UnityEngine; 2 | 3 | namespace cmdwtf.UnityTools.Dynamics 4 | { 5 | /// 6 | /// The current stability of a given dynamics system. 7 | /// 8 | public enum StabilityState 9 | { 10 | [Tooltip("The system is stable.")] 11 | Stable, 12 | 13 | [Tooltip("The system's current value is a denormalized number and should likely not be used.")] 14 | DenormalizedValue, 15 | 16 | [Tooltip("The system's current value exceeds it's max limit.")] 17 | BeyondMaximumLimit, 18 | 19 | [Tooltip("The system has an input value that will cause it to never approach its target.")] 20 | NeverApproachingTarget, 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /Runtime/Dynamics/StabilityState.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 0f6c7405f0094a1f84c0dae9fcb5027e 3 | timeCreated: 1657404084 -------------------------------------------------------------------------------- /Runtime/Dynamics/UnstableHandlingMode.cs: -------------------------------------------------------------------------------- 1 | using UnityEngine; 2 | 3 | namespace cmdwtf.UnityTools.Dynamics 4 | { 5 | /// 6 | /// The method a dynamics system should use to handle when it is in an unstable state. 7 | /// 8 | public enum UnstableHandlingMode 9 | { 10 | [Tooltip("When the system is unstable, update will return the given target value.")] 11 | [InspectorName("Return Target Value")] 12 | ReturnTarget, 13 | [Tooltip("When the system is unstable, update will return the value 0.")] 14 | [InspectorName("Return 0")] 15 | Return0, 16 | [Tooltip("Return Last Stable Value")] 17 | [InspectorName("When the system is unstable, update will return the last stable value the system produced.")] 18 | ReturnLastStableValue, 19 | [Tooltip("When the system is unstable, it will allow the non-finite, non-zero values to be returned as they are generated.")] 20 | [InspectorName("Allow Denormalized Values")] 21 | AllowDenormalizedValues, 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /Runtime/Dynamics/UnstableHandlingMode.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: f5f463c8179041a5b34ad78f2a0a5b16 3 | timeCreated: 1657403890 -------------------------------------------------------------------------------- /Runtime/Filters.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: f7b53af2db6a3be4b952a6f8800f0a46 3 | folderAsset: yes 4 | DefaultImporter: 5 | externalObjects: {} 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Runtime/Filters/AverageBase.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: de715926f6a4b5e4d8a1507d5e31ddae 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Runtime/Filters/Butterworth.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 48e1217872fa0d544a576f53a7a91898 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Runtime/Filters/ButterworthMultiple.cs: -------------------------------------------------------------------------------- 1 | using System.Collections.Generic; 2 | using System.Linq; 3 | 4 | namespace cmdwtf.UnityTools.Filters 5 | { 6 | public class ButterworthMultiple : Butterworth>, IFilterMultiple 7 | { 8 | public ButterworthMultiple(int count, 9 | float frequency, 10 | int sampleRate, 11 | ButterworthPassType passType = ButterworthPassType.Lowpass, 12 | float resonance = Butterworth.ResonanceMax) 13 | : base(count, frequency, sampleRate, passType, resonance) 14 | { } 15 | 16 | public IEnumerable Sample(params float[] samples) 17 | => UpdateFilters(samples); 18 | 19 | public override IEnumerable Sample(IEnumerable samples) 20 | => UpdateFilters(samples.ToArray()); 21 | 22 | public override IEnumerable Value => Filters.Select(f => f.Value); 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /Runtime/Filters/ButterworthMultiple.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: fc9ba9d1d4380dc4d8c6a2e2fbe78e9e 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Runtime/Filters/ButterworthPassType.cs: -------------------------------------------------------------------------------- 1 | namespace cmdwtf.UnityTools.Filters 2 | { 3 | public enum ButterworthPassType 4 | { 5 | Lowpass, 6 | Highpass, 7 | } 8 | } 9 | -------------------------------------------------------------------------------- /Runtime/Filters/ButterworthPassType.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: c04f228e971e1de40a5b9c08718595ec 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Runtime/Filters/ButterworthQuaternion.cs: -------------------------------------------------------------------------------- 1 | using UnityEngine; 2 | 3 | namespace cmdwtf.UnityTools.Filters 4 | { 5 | public class ButterworthQuaternion : Butterworth 6 | { 7 | public ButterworthQuaternion(float frequency, 8 | int sampleRate, 9 | ButterworthPassType passType = ButterworthPassType.Lowpass, 10 | float resonance = Butterworth.ResonanceMax) 11 | : base(4, frequency, sampleRate, passType, resonance) 12 | { } 13 | 14 | public override Quaternion Sample(Quaternion sample) 15 | { 16 | UpdateFilters(sample.x, sample.y, sample.z, sample.w); 17 | return Value; 18 | } 19 | 20 | public override Quaternion Value => new Quaternion( 21 | Filters[0].Value, 22 | Filters[1].Value, 23 | Filters[2].Value, 24 | Filters[3].Value 25 | ); 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /Runtime/Filters/ButterworthQuaternion.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 8bb99ffe00cac984aab18c9f20695bdd 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Runtime/Filters/ButterworthVector2.cs: -------------------------------------------------------------------------------- 1 | using UnityEngine; 2 | 3 | namespace cmdwtf.UnityTools.Filters 4 | { 5 | public class ButterworthVector2 : Butterworth 6 | { 7 | protected ButterworthVector2(float frequency, 8 | int sampleRate, 9 | ButterworthPassType passType = ButterworthPassType.Lowpass, 10 | float resonance = Butterworth.ResonanceMax) 11 | : base(2, frequency, sampleRate, passType, resonance) 12 | { } 13 | 14 | public override Vector2 Sample(Vector2 sample) 15 | { 16 | UpdateFilters(sample.x, sample.y); 17 | return Value; 18 | } 19 | 20 | public override Vector2 Value => new Vector2( 21 | Filters[0].Value, 22 | Filters[1].Value 23 | ); 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /Runtime/Filters/ButterworthVector2.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 56a28cbfca6763b4e8b2c49656aca87c 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Runtime/Filters/ButterworthVector3.cs: -------------------------------------------------------------------------------- 1 | using UnityEngine; 2 | 3 | namespace cmdwtf.UnityTools.Filters 4 | { 5 | public class ButterworthVector3 : Butterworth 6 | { 7 | protected ButterworthVector3(float frequency, 8 | int sampleRate, 9 | ButterworthPassType passType = ButterworthPassType.Lowpass, 10 | float resonance = Butterworth.ResonanceMax) 11 | : base(3, frequency, sampleRate, passType, resonance) 12 | { } 13 | 14 | public override Vector3 Sample(Vector3 sample) 15 | { 16 | UpdateFilters(sample.x, sample.y, sample.z); 17 | return Value; 18 | } 19 | 20 | public override Vector3 Value => new Vector3( 21 | Filters[0].Value, 22 | Filters[1].Value, 23 | Filters[2].Value 24 | ); 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /Runtime/Filters/ButterworthVector3.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 5a4f3a55f2b603345a065c3539576c42 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Runtime/Filters/ButterworthVector4.cs: -------------------------------------------------------------------------------- 1 | using UnityEngine; 2 | 3 | namespace cmdwtf.UnityTools.Filters 4 | { 5 | public class ButterworthVector4 : Butterworth 6 | { 7 | public ButterworthVector4(float frequency, 8 | int sampleRate, 9 | ButterworthPassType passType = ButterworthPassType.Lowpass, 10 | float resonance = Butterworth.ResonanceMax) 11 | : base(4, frequency, sampleRate, passType, resonance) 12 | { } 13 | 14 | public override Vector4 Sample(Vector4 sample) 15 | { 16 | UpdateFilters(sample.x, sample.y, sample.z, sample.w); 17 | return Value; 18 | } 19 | 20 | public override Vector4 Value => new Vector4( 21 | Filters[0].Value, 22 | Filters[1].Value, 23 | Filters[2].Value, 24 | Filters[3].Value 25 | ); 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /Runtime/Filters/ButterworthVector4.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 1cb0eefe35a2dd6439a6cfcaf66e5e1b 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Runtime/Filters/Butterworth`1.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections; 3 | 4 | namespace cmdwtf.UnityTools.Filters 5 | { 6 | public abstract class Butterworth : FilterBase, IBiQuadFilter 7 | { 8 | public float Resonance => First.Resonance; 9 | public float Frequency => First.Frequency; 10 | public int SampleRate => First.SampleRate; 11 | public override FilterType Type => First.Type; 12 | public override string Name => First.Name; 13 | 14 | protected Butterworth[] Filters { get; } 15 | 16 | private Butterworth First => Filters[0]; 17 | 18 | protected Butterworth(int componentCount, float frequency, int sampleRate, ButterworthPassType passType, float resonance) 19 | { 20 | Filters = new Butterworth[componentCount]; 21 | for (int scan = 0; scan < componentCount; ++scan) 22 | { 23 | Filters[scan] = new Butterworth(frequency, sampleRate, passType, resonance); 24 | } 25 | } 26 | 27 | public override void Reset() 28 | { 29 | foreach (Butterworth f in Filters) 30 | { 31 | f.Reset(); 32 | } 33 | } 34 | 35 | public T UpdateFilters(params float[] samples) 36 | { 37 | if (samples.Length != Filters.Length) 38 | { 39 | throw new ArgumentException( 40 | $"{nameof(UpdateFilters)} expects a number of parameters to match the number of filters."); 41 | } 42 | 43 | for (int scan = 0; scan < Filters.Length; ++scan) 44 | { 45 | Filters[scan].Sample(samples[scan]); 46 | } 47 | 48 | return Value; 49 | } 50 | } 51 | } 52 | -------------------------------------------------------------------------------- /Runtime/Filters/Butterworth`1.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: c2e0714b8b6865044a5547e1966eca9a 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Runtime/Filters/ExponentialMovingAverage.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Linq; 3 | 4 | namespace cmdwtf.UnityTools.Filters 5 | { 6 | public class ExponentialMovingAverage : ModifiedMovingAverage 7 | { 8 | protected override float WeightDividend => 2f; 9 | 10 | public ExponentialMovingAverage(int warmupWindow, float virtualWindow) 11 | : base(warmupWindow, virtualWindow) { } 12 | } 13 | 14 | 15 | } 16 | -------------------------------------------------------------------------------- /Runtime/Filters/ExponentialMovingAverage.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: b8b27a960ab224b40b9b461ef2f5bbcd 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Runtime/Filters/ExponentialMovingAverageTimeBased.cs: -------------------------------------------------------------------------------- 1 | 2 | namespace cmdwtf.UnityTools.Filters 3 | { 4 | public class ExponentialMovingAverageTimeBased : TimeBasedMovingAverage 5 | { 6 | public float Smoothness { get; private set; } 7 | 8 | public ExponentialMovingAverageTimeBased(int startupWindow, float smoothness, ITimeProvider timeProvider) 9 | : base(startupWindow, timeProvider) 10 | { 11 | Smoothness = smoothness; 12 | } 13 | 14 | public ExponentialMovingAverageTimeBased(int warmupWindow, float smoothness, float period, float minimumDeltaTime = 0f) 15 | : base(warmupWindow, period, minimumDeltaTime) 16 | { 17 | Smoothness = smoothness; 18 | } 19 | 20 | public override float Sample(float sample) 21 | { 22 | UpdateTime(); 23 | 24 | if (!WarmedUp) 25 | { 26 | return base.Sample(sample); 27 | } 28 | 29 | float periodPercent = DeltaTime / Time.PeriodF; 30 | 31 | float newSampleWeight = periodPercent / (periodPercent + Smoothness); 32 | float oldSampleWeight = 1 - newSampleWeight; 33 | 34 | Value = (sample * newSampleWeight) + (Value * oldSampleWeight); 35 | return Value; 36 | 37 | //float k = Period / (Smoothness + 1); 38 | //Value = (sample * k) + (Value * (1 - k)); 39 | //return Value; 40 | } 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /Runtime/Filters/ExponentialMovingAverageTimeBased.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: d75188877ddc4b04891257c109349e24 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Runtime/Filters/FilterBase.cs: -------------------------------------------------------------------------------- 1 | namespace cmdwtf.UnityTools.Filters 2 | { 3 | public abstract class FilterBase : IFilter 4 | { 5 | public virtual FilterType Type => FilterType.None; 6 | 7 | private string _name; 8 | public virtual string Name => _name ??= GetType().Name; 9 | 10 | public virtual T Value { get; protected set; } 11 | 12 | public abstract T Sample(T sample); 13 | 14 | public abstract void Reset(); 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /Runtime/Filters/FilterBase.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: b0d0d48c5cc65b64598345008b05abbb 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Runtime/Filters/FilterExtensions.cs: -------------------------------------------------------------------------------- 1 | using System.Collections.Generic; 2 | using System.Linq; 3 | 4 | namespace cmdwtf.UnityTools.Filters 5 | { 6 | public static class FilterExtensions 7 | { 8 | public static float SimpleAverage(this Queue samples) 9 | => samples.Sum(f => f) / samples.Count; 10 | 11 | public static float SimpleAverage(this IList samples) 12 | => samples.Sum(f => f) / samples.Count; 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /Runtime/Filters/FilterExtensions.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 8c01d26314477fe4aa458d89eea0f950 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Runtime/Filters/FilterSequence.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: f49a5ee9e5bd4f9aa8bf2cabfaa83ce8 3 | timeCreated: 1637346583 -------------------------------------------------------------------------------- /Runtime/Filters/FilterType.cs: -------------------------------------------------------------------------------- 1 | namespace cmdwtf.UnityTools.Filters 2 | { 3 | public enum FilterType 4 | { 5 | None, 6 | Custom, 7 | LowPass, 8 | HighPass, 9 | Average, 10 | Transformation, 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /Runtime/Filters/FilterType.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 9c6df50eb93843c2aac1c4182fc12bc8 3 | timeCreated: 1637077618 -------------------------------------------------------------------------------- /Runtime/Filters/IAverage.cs: -------------------------------------------------------------------------------- 1 | namespace cmdwtf.UnityTools.Filters 2 | { 3 | public interface IAverage : IFilter 4 | { 5 | int WindowSize { get; } 6 | } 7 | } 8 | -------------------------------------------------------------------------------- /Runtime/Filters/IAverage.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 7ef6e20dee05c3a40b94851453efd5b1 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Runtime/Filters/IBiQuadFilter.cs: -------------------------------------------------------------------------------- 1 | namespace cmdwtf.UnityTools.Filters 2 | { 3 | public interface IBiQuadFilter : IFilter 4 | { 5 | /// 6 | /// Frequency to filter at. 7 | /// 8 | float Frequency { get; } 9 | 10 | /// 11 | /// The rate the value is sampled at. 12 | /// 13 | int SampleRate { get; } 14 | 15 | /// 16 | /// Resonance amount, from sqrt(2) to ~ 0.1 17 | /// 18 | float Resonance { get; } 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /Runtime/Filters/IBiQuadFilter.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: c9e2d13b67cecba4e89548d26bef2f7b 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Runtime/Filters/IFilter.cs: -------------------------------------------------------------------------------- 1 | using System.Collections.Generic; 2 | 3 | namespace cmdwtf.UnityTools.Filters 4 | { 5 | public interface IFilter 6 | { 7 | /// 8 | /// The type of filtering applied. 9 | /// 10 | FilterType Type { get; } 11 | 12 | /// 13 | /// The name of the filter class. 14 | /// 15 | string Name { get; } 16 | 17 | /// 18 | /// The current filtered value. 19 | /// 20 | T Value { get; } 21 | 22 | /// 23 | /// Update the filter with the given sample. 24 | /// 25 | /// The sample to update with. 26 | T Sample(T sample); 27 | 28 | /// 29 | /// Resets the filter to it's initial state, clearing samples. 30 | /// 31 | void Reset(); 32 | } 33 | 34 | public interface IFilterMultiple : IFilter> 35 | { 36 | /// 37 | /// Update the filter with the given samples, with more than one. 38 | /// 39 | /// The sample to update with. 40 | IEnumerable Sample(params T[] sample); 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /Runtime/Filters/IFilter.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: cf50731d9c184e488a4c6c3822f872c4 3 | timeCreated: 1637077560 -------------------------------------------------------------------------------- /Runtime/Filters/ModifiedMovingAverage.cs: -------------------------------------------------------------------------------- 1 | 2 | 3 | using UnityEngine; 4 | 5 | namespace cmdwtf.UnityTools.Filters 6 | { 7 | public class ModifiedMovingAverage : VirtualWindowAverage 8 | { 9 | protected virtual float WeightDividend => 1f; 10 | 11 | public ModifiedMovingAverage(int warmupWindow, float windowSize) 12 | : base(warmupWindow, windowSize) { } 13 | 14 | public override float Sample(float sample) 15 | { 16 | if (!WarmedUp) 17 | { 18 | return base.Sample(sample); 19 | } 20 | 21 | //Value = (((Period - 1) * Value) + sample) / Period; 22 | float weight = WeightDividend / (VirtualWindowSize + 1); 23 | float nWeight = 1 - weight; 24 | Value = (sample * weight) + (Value * nWeight); 25 | 26 | return Value; 27 | } 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /Runtime/Filters/ModifiedMovingAverage.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: f63225a2aa4df8a41a08c97b76040a5a 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Runtime/Filters/NoiseRejection.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: e63f9cefe363491a9ad489c69fa17473 3 | timeCreated: 1637345783 -------------------------------------------------------------------------------- /Runtime/Filters/NoiseRejectionReplacementStrategy.cs: -------------------------------------------------------------------------------- 1 | namespace cmdwtf.UnityTools.Filters 2 | { 3 | public enum NoiseRejectionReplacementStrategy 4 | { 5 | Previous, 6 | SimpleAverage 7 | } 8 | } 9 | -------------------------------------------------------------------------------- /Runtime/Filters/NoiseRejectionReplacementStrategy.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: ed9ae79ccec13244a832bc261d64672c 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Runtime/Filters/NopAverage.cs: -------------------------------------------------------------------------------- 1 | namespace cmdwtf.UnityTools.Filters 2 | { 3 | public class NopAverage : AverageBase 4 | { 5 | public NopAverage() : base(0) { } 6 | 7 | public override float Sample(float sample) => Value = sample; 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /Runtime/Filters/NopAverage.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 891231dbe270c2245ab5344d76e29565 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Runtime/Filters/NopFilter.cs: -------------------------------------------------------------------------------- 1 | namespace cmdwtf.UnityTools.Filters 2 | { 3 | public class NopFilter : FilterBase 4 | { 5 | public override float Sample(float sample) => sample; 6 | 7 | public override void Reset() { } 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /Runtime/Filters/NopFilter.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 24af83f77931dfb4d9375f49153c8995 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Runtime/Filters/ScaleF.cs: -------------------------------------------------------------------------------- 1 | namespace cmdwtf.UnityTools.Filters 2 | { 3 | public class ScaleF : TransformBase 4 | { 5 | public float Scalar { get; private set; } 6 | 7 | public ScaleF(float scalar) 8 | { 9 | Scalar = scalar; 10 | } 11 | 12 | public override float Sample(float sample) => sample * Scalar; 13 | 14 | public override void Reset() => throw new System.NotImplementedException(); 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /Runtime/Filters/ScaleF.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 3b5f8ab46bd79f74bba0a498e7f74541 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Runtime/Filters/SimpleMovingAverage.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Linq; 3 | 4 | using UnityEngine; 5 | 6 | namespace cmdwtf.UnityTools.Filters 7 | { 8 | public class SimpleMovingAverage : AverageBase 9 | { 10 | protected float Accumulator { get; private set; } 11 | 12 | public SimpleMovingAverage(int windowSize) 13 | : base(windowSize) 14 | { 15 | } 16 | 17 | public override float Sample(float sample) 18 | { 19 | Accumulator += sample; 20 | Accumulator -= AppendSample(sample); 21 | Value = Accumulator / SampleCount; 22 | return Value; 23 | } 24 | 25 | public override void Reset() 26 | { 27 | base.Reset(); 28 | Accumulator = 0; 29 | } 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /Runtime/Filters/SimpleMovingAverage.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: ce4464948e37f864698051e4750dc5f7 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Runtime/Filters/SmoothDamp.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 3c759f265e9055747aa53fcdced6e462 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Runtime/Filters/StandardDeviation.cs: -------------------------------------------------------------------------------- 1 | using System.Linq; 2 | 3 | namespace cmdwtf.UnityTools.Filters 4 | { 5 | public class StandardDeviation : SimpleMovingAverage 6 | { 7 | protected float Average { get; private set; } 8 | 9 | public float Sigma { get; private set; } 10 | 11 | public StandardDeviationType StandardDeviationType { get; } 12 | 13 | public StandardDeviation(int windowSize, StandardDeviationType type = StandardDeviationType.Population) 14 | : base(windowSize) 15 | { 16 | StandardDeviationType = type; 17 | } 18 | 19 | public override float Sample(float sample) 20 | { 21 | Average = base.Sample(sample); 22 | float varianceSquaredSum = Samples.Sum(d => (float)System.Math.Pow(d - Average, 2)); 23 | float divisor = StandardDeviationType == StandardDeviationType.Population 24 | ? SampleCount 25 | : SampleCount - 1; 26 | float variance = varianceSquaredSum / divisor; 27 | Sigma = (float)System.Math.Sqrt(variance); 28 | Value = Sigma; 29 | return Value; 30 | } 31 | 32 | public float GetStandardDeviationsFromMean(float sample) 33 | { 34 | if (SampleCount <= 0 || Sigma == 0) 35 | { 36 | return 0; 37 | } 38 | 39 | float result = (sample - Average) / Sigma; 40 | return result; 41 | } 42 | 43 | public override void Reset() 44 | { 45 | base.Reset(); 46 | Sigma = default; 47 | } 48 | } 49 | } 50 | -------------------------------------------------------------------------------- /Runtime/Filters/StandardDeviation.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 82386aaa95d08874b8c6ffce78068a04 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Runtime/Filters/StandardDeviationType.cs: -------------------------------------------------------------------------------- 1 | namespace cmdwtf.UnityTools.Filters 2 | { 3 | public enum StandardDeviationType 4 | { 5 | Population, 6 | Sample, 7 | } 8 | } 9 | -------------------------------------------------------------------------------- /Runtime/Filters/StandardDeviationType.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 41433edacbf273447a09e3eca9c1b036 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Runtime/Filters/StandardDeviationsFromMean.cs: -------------------------------------------------------------------------------- 1 | namespace cmdwtf.UnityTools.Filters 2 | { 3 | public class StandardDeviationsFromMean : StandardDeviation 4 | { 5 | public StandardDeviationsFromMean(int windowSize, StandardDeviationType type = StandardDeviationType.Population) 6 | : base(windowSize, type) { } 7 | 8 | public override float Sample(float sample) => SampleCurrent(sample); 9 | 10 | public float SamplePrevious(float sample) 11 | { 12 | // get value from previous sample's stddev 13 | float stdDevs = GetStandardDeviationsFromMean(sample); 14 | 15 | // update stddev, 16 | base.Sample(sample); 17 | 18 | // return the previously calculated value, after saving it 19 | Value = stdDevs; 20 | 21 | return Value; 22 | } 23 | 24 | public float SampleCurrent(float sample) 25 | { 26 | // update stddev, 27 | base.Sample(sample); 28 | 29 | // get value from current sample's stddev 30 | float stdDevs = GetStandardDeviationsFromMean(sample); 31 | 32 | // return the previously calculated value, after saving it 33 | Value = stdDevs; 34 | return Value; 35 | } 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /Runtime/Filters/StandardDeviationsFromMean.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: e761768e2ca14f94498e388cdcb53586 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Runtime/Filters/TimeBasedMovingAverage.cs: -------------------------------------------------------------------------------- 1 | namespace cmdwtf.UnityTools.Filters 2 | { 3 | public abstract class TimeBasedMovingAverage : VirtualWindowAverage 4 | { 5 | protected ITimeProvider Time { get; set; } 6 | protected float MinimumDeltaTime { get; set; } 7 | protected float DeltaTime { get; private set; } 8 | 9 | public TimeBasedMovingAverage(int startupWindow, ITimeProvider timeProvider = null) 10 | : base(startupWindow, 1f) 11 | { 12 | Time = timeProvider ?? TimeProviders.GetDefault(1f); 13 | } 14 | 15 | public TimeBasedMovingAverage(int startupWindow, float period, float minimumDeltaTime = float.NaN) 16 | : base(startupWindow, period) 17 | { 18 | Time = TimeProviders.GetDefault(period); 19 | MinimumDeltaTime = float.IsNaN(minimumDeltaTime) ? period : minimumDeltaTime; 20 | } 21 | 22 | protected void UpdateTime() 23 | { 24 | DeltaTime = Time.UpdateF(); 25 | 26 | if (DeltaTime < MinimumDeltaTime) 27 | { 28 | DeltaTime = MinimumDeltaTime; 29 | } 30 | } 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /Runtime/Filters/TimeBasedMovingAverage.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 22702a56bc5397e46bf10b326f465c60 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Runtime/Filters/TransformBase.cs: -------------------------------------------------------------------------------- 1 | namespace cmdwtf.UnityTools.Filters 2 | { 3 | public abstract class TransformBase : FilterBase 4 | { 5 | public override FilterType Type => FilterType.Transformation; 6 | } 7 | } 8 | -------------------------------------------------------------------------------- /Runtime/Filters/TransformBase.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 6821304c621029a47b0cbba8df0c8749 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Runtime/Filters/VirtualWindowAverage.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace cmdwtf.UnityTools.Filters 4 | { 5 | public abstract class VirtualWindowAverage : AverageBase 6 | { 7 | public bool WarmedUp => Samples.Count >= WindowSize; 8 | 9 | public float VirtualWindowSize { get; private set; } 10 | 11 | public VirtualWindowAverage(int warmupWindow, float windowSize) 12 | : base(warmupWindow) 13 | { 14 | VirtualWindowSize = windowSize; 15 | } 16 | 17 | public override float Sample(float sample) 18 | { 19 | if (WarmedUp) 20 | { 21 | throw new ApplicationException( 22 | $"{nameof(VirtualWindowAverage)}.{nameof(Sample)} shouldn't be called after warmup."); 23 | } 24 | 25 | AppendSample(sample); 26 | Value = Samples.SimpleAverage(); 27 | return Value; 28 | } 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /Runtime/Filters/VirtualWindowAverage.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 6cd7abda0a0448d47adbcad1efac1af8 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Runtime/Filters/WeightedMovingAverage.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Linq; 3 | 4 | namespace cmdwtf.UnityTools.Filters 5 | { 6 | public class WeightedMovingAverage : AverageBase 7 | { 8 | public WeightedMovingAverage(int windowSize) 9 | : base(windowSize) { } 10 | 11 | public override float Sample(float sample) 12 | { 13 | AppendSample(sample); 14 | int remainingSamples = SampleCount; 15 | 16 | float dividend = Samples.Sum(s => s * remainingSamples--); 17 | float divisor = (SampleCount * (SampleCount + 1)) / 2.0f; 18 | 19 | Value = dividend / divisor; 20 | return Value; 21 | } 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /Runtime/Filters/WeightedMovingAverage.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: c5ab57b3b63e43f43a4a3858fd1a995c 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Runtime/Filters/WeightedMovingAverageStrong.cs: -------------------------------------------------------------------------------- 1 | namespace cmdwtf.UnityTools.Filters 2 | { 3 | public class WeightedMovingAverageStrong : AverageBase 4 | { 5 | public WeightedMovingAverageStrong(int windowSize) 6 | : base(windowSize) { } 7 | 8 | public override float Sample(float sample) 9 | { 10 | AppendSample(sample); 11 | float accumulator = 0; 12 | int scan = 1; 13 | float divisor = SampleCount.NthTriangular(); 14 | foreach (float s in Samples) 15 | { 16 | accumulator += s * scan / divisor; 17 | scan++; 18 | } 19 | 20 | Value = accumulator; 21 | return Value; 22 | } 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /Runtime/Filters/WeightedMovingAverageStrong.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 583e312d0c1939143acf88e844baff35 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Runtime/FrequencyCounterBase.cs: -------------------------------------------------------------------------------- 1 | namespace cmdwtf.UnityTools 2 | { 3 | public abstract class FrequencyCounterBase : IFrequencyCounter 4 | { 5 | protected readonly ITimeProvider Time; 6 | public virtual int Samples { get; protected set; } 7 | public virtual float Frequency { get; protected set; } 8 | 9 | public virtual float Period 10 | { 11 | get => Time.PeriodF; 12 | set 13 | { 14 | Time.PeriodF = value; 15 | Reset(); 16 | } 17 | } 18 | 19 | public virtual float MeasuredSeconds { get; protected set; } 20 | 21 | public FrequencyCounterBase(ITimeProvider timeProvider = null, float period = float.NaN) 22 | { 23 | if (float.IsNaN(period) || period < 0) 24 | { 25 | period = 1f; 26 | } 27 | 28 | Time = timeProvider ?? TimeProviders.GetDefault(period); 29 | } 30 | 31 | public virtual void TickAndUpdate() 32 | { 33 | Tick(); 34 | Update(); 35 | } 36 | 37 | public abstract void Reset(); 38 | 39 | public abstract void Tick(); 40 | 41 | public abstract void Update(); 42 | } 43 | } 44 | -------------------------------------------------------------------------------- /Runtime/FrequencyCounterBase.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: eb4cf1d06a104022b78e55c9799163fd 3 | timeCreated: 1637171631 -------------------------------------------------------------------------------- /Runtime/GUITools.cs: -------------------------------------------------------------------------------- 1 | using System.Collections.Generic; 2 | using System.Linq; 3 | 4 | using UnityEngine; 5 | 6 | namespace cmdwtf.UnityTools 7 | { 8 | #if UNITY_EDITOR 9 | [UnityEditor.InitializeOnLoad] 10 | #endif // UNITY_EDITOR 11 | public static class GUITools 12 | { 13 | private static readonly Stack ColorStack; 14 | private static readonly Stack EnabledStack; 15 | 16 | static GUITools() 17 | { 18 | ColorStack = new Stack(); 19 | EnabledStack = new Stack(); 20 | } 21 | 22 | [RuntimeInitializeOnLoadMethod] 23 | private static void RuntimeInitialize() 24 | { 25 | ColorStack.Clear(); 26 | EnabledStack.Clear(); 27 | } 28 | 29 | public static void PushColor(Color newColor) 30 | { 31 | ColorStack.Push(GUI.color); 32 | GUI.color = newColor; 33 | } 34 | 35 | public static void PopColor() 36 | { 37 | if (ColorStack.Any()) 38 | { 39 | GUI.color = ColorStack.Pop(); 40 | } 41 | } 42 | 43 | public static void PushEnabled(bool newEnabled) 44 | { 45 | EnabledStack.Push(GUI.enabled); 46 | GUI.enabled = newEnabled; 47 | } 48 | 49 | public static void PopEnabled() 50 | { 51 | if (EnabledStack.Any()) 52 | { 53 | GUI.enabled = EnabledStack.Pop(); 54 | } 55 | } 56 | } 57 | } 58 | -------------------------------------------------------------------------------- /Runtime/GUITools.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: a9f8771b28784f05b8d8c11e687ab57b 3 | timeCreated: 1638290000 -------------------------------------------------------------------------------- /Runtime/GameObjectExtensions.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 68d3748c857c44f5a823a1f6a235b027 3 | timeCreated: 1634561837 -------------------------------------------------------------------------------- /Runtime/GameObjectTools.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: db02128f5f8fe3f4e91acac766cc9ae9 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Runtime/Gizmos.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 5ce86928f246434fa448cbf5e6f0608d 3 | timeCreated: 1663178208 -------------------------------------------------------------------------------- /Runtime/Gizmos/BatchGizmoDrawCommand.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: eccd703522fb4446a39ef2784b32f30a 3 | timeCreated: 1662661280 -------------------------------------------------------------------------------- /Runtime/Gizmos/IBatchGizmoDrawCommand.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 19557a95018d47e696520cc0c3730c2d 3 | timeCreated: 1662661273 -------------------------------------------------------------------------------- /Runtime/Gizmos/ShowIcon.cs: -------------------------------------------------------------------------------- 1 | using UnityEngine; 2 | 3 | namespace cmdwtf.UnityTools.Gizmos 4 | { 5 | /// 6 | /// A small component that causes an gizmo icon to draw. 7 | /// 8 | public class ShowIcon : MonoBehaviour 9 | { 10 | #if UNITY_EDITOR 11 | [SerializeField] 12 | private string gizmoName = "d_Favorite@2x"; 13 | 14 | private void OnDrawGizmos() 15 | { 16 | Color originalColor = UnityEngine.Gizmos.color; 17 | var transparent = new Color(originalColor.r, originalColor.g, originalColor.b, 0.5f); 18 | UnityEngine.Gizmos.color = transparent; 19 | OnDrawGizmosSelected(); 20 | UnityEngine.Gizmos.color = originalColor; 21 | } 22 | 23 | private void OnDrawGizmosSelected() 24 | => UnityEngine.Gizmos.DrawIcon(transform.position, gizmoName); 25 | 26 | #endif // UNITY_EDITOR 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /Runtime/Gizmos/ShowIcon.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 5c08a644ef9ae6f4da23a41f2e13b9b7 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Runtime/Gizmos/Sorted.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 3540a4c859aba9742b31986ffade73c7 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Runtime/GradientExtensions.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | using UnityEngine; 4 | 5 | namespace cmdwtf.UnityTools 6 | { 7 | public static class GradientExtensions 8 | { 9 | /// 10 | /// Duplicates the prototype 's color and alpha keys, returning a new gradient with identical values. 11 | /// 12 | /// The to copy. 13 | /// The newly created duplicate. 14 | public static Gradient Clone(this Gradient prototype) 15 | { 16 | Gradient result = new(); 17 | 18 | if (prototype == null) 19 | { 20 | return result; 21 | } 22 | 23 | result.mode = prototype.mode; 24 | 25 | var colorKeys = new GradientColorKey[prototype.colorKeys.Length]; 26 | var alphaKeys = new GradientAlphaKey[prototype.alphaKeys.Length]; 27 | 28 | Array.Copy(prototype.colorKeys, colorKeys, colorKeys.Length); 29 | Array.Copy(prototype.alphaKeys, alphaKeys, alphaKeys.Length); 30 | 31 | result.SetKeys(colorKeys, alphaKeys); 32 | 33 | return result; 34 | } 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /Runtime/GradientExtensions.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 94626b41f0c343588854cbb77572b1f1 3 | timeCreated: 1671051882 -------------------------------------------------------------------------------- /Runtime/IFrequencyCounter.cs: -------------------------------------------------------------------------------- 1 | namespace cmdwtf.UnityTools 2 | { 3 | public interface IFrequencyCounter 4 | { 5 | int Samples { get; } 6 | float Frequency { get; } 7 | float Period { get; } 8 | float MeasuredSeconds { get; } 9 | void Reset(); 10 | void Tick(); 11 | void Update(); 12 | void TickAndUpdate(); 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /Runtime/IFrequencyCounter.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: c208b34d00624b6e90c11c16ba1345f8 3 | timeCreated: 1637081567 -------------------------------------------------------------------------------- /Runtime/ITimeProvider.cs: -------------------------------------------------------------------------------- 1 | namespace cmdwtf.UnityTools 2 | { 3 | public interface ITimeProvider 4 | { 5 | double Period { get; set; } 6 | float PeriodF { get; set; } 7 | double NowSeconds { get; } 8 | float NowSecondsF { get; } 9 | double DeltaSeconds { get; } 10 | float DeltaSecondsF { get; } 11 | long UnixTimestamp { get; } 12 | double Update(); 13 | float UpdateF(); 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /Runtime/ITimeProvider.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: c075891776724ebca8a9215cb8ccbeea 3 | timeCreated: 1637170260 -------------------------------------------------------------------------------- /Runtime/ITransformComponentDriver.cs: -------------------------------------------------------------------------------- 1 | namespace cmdwtf.UnityTools 2 | { 3 | /// 4 | /// Describes a type that can drive a transform component. 5 | /// 6 | public interface ITransformComponentDriver 7 | { 8 | 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /Runtime/ITransformComponentDriver.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: b63d597913de40aa8ea172b8d5dc1dc9 3 | timeCreated: 1657491684 -------------------------------------------------------------------------------- /Runtime/ITransformDriver.cs: -------------------------------------------------------------------------------- 1 | namespace cmdwtf.UnityTools 2 | { 3 | /// 4 | /// Describes a type that can drive one or more transform components. 5 | /// 6 | public interface ITransformDriver 7 | : ITransformPositionDriver, ITransformRotationDriver, ITransformScaleDriver 8 | { 9 | /// 10 | /// Returns true if the object is driving any component of a transform's. 11 | /// 12 | bool IsDrivingAnyTransformComponent { get; } 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /Runtime/ITransformDriver.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 8f7af05d314047868d24b126d03a285e 3 | timeCreated: 1657472131 -------------------------------------------------------------------------------- /Runtime/ITransformPositionDriver.cs: -------------------------------------------------------------------------------- 1 | namespace cmdwtf.UnityTools 2 | { 3 | /// 4 | /// Describes a type that can drive a transform position. 5 | /// 6 | public interface ITransformPositionDriver : ITransformComponentDriver 7 | { 8 | /// 9 | /// Returns true if the object can drive a transform's position. 10 | /// 11 | bool CanDrivePosition { get; } 12 | 13 | /// 14 | /// Returns true if the object is driving a transform's position. 15 | /// 16 | bool IsDrivingPosition { get; set; } 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /Runtime/ITransformPositionDriver.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 42c318f1831a425fa463dc1793884613 3 | timeCreated: 1657491712 -------------------------------------------------------------------------------- /Runtime/ITransformRotationDriver.cs: -------------------------------------------------------------------------------- 1 | namespace cmdwtf.UnityTools 2 | { 3 | /// 4 | /// Describes a type that can drive a transform rotation. 5 | /// 6 | public interface ITransformRotationDriver : ITransformComponentDriver 7 | { 8 | /// 9 | /// Returns true if the object can drive a transform's rotation. 10 | /// 11 | bool CanDriveRotation { get; } 12 | 13 | /// 14 | /// Returns true if the object is driving a transform's rotation. 15 | /// 16 | bool IsDrivingRotation { get; set; } 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /Runtime/ITransformRotationDriver.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 137ce446fd2f49a0a99f903da361f3fe 3 | timeCreated: 1657491726 -------------------------------------------------------------------------------- /Runtime/ITransformScaleDriver.cs: -------------------------------------------------------------------------------- 1 | namespace cmdwtf.UnityTools 2 | { 3 | /// 4 | /// Describes a type that can drive a transform scale. 5 | /// 6 | public interface ITransformScaleDriver : ITransformComponentDriver 7 | { 8 | /// 9 | /// Returns true if the object can drive a transform's scale. 10 | /// 11 | bool CanDriveScale { get; } 12 | 13 | /// 14 | /// Returns true if the object is driving a transform's scale. 15 | /// 16 | bool IsDrivingScale { get; set; } 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /Runtime/ITransformScaleDriver.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 385baef04b5a42d293ac049b687a6773 3 | timeCreated: 1657491740 -------------------------------------------------------------------------------- /Runtime/Input.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 367b0fab28594a3f964d991edc456d07 3 | timeCreated: 1638303985 -------------------------------------------------------------------------------- /Runtime/Input/DebugOnlyProcessor.cs: -------------------------------------------------------------------------------- 1 | using UnityEngine; 2 | using UnityEngine.InputSystem; 3 | 4 | namespace cmdwtf.UnityTools.Input 5 | { 6 | #if UNITY_EDITOR 7 | [UnityEditor.InitializeOnLoad] 8 | #endif 9 | public class DebugOnlyProcessor : InputProcessor 10 | { 11 | internal bool _allowInDebugBuild = true; 12 | internal bool _allowInReleaseBuild = false; 13 | internal bool _allowInEditor = true; 14 | 15 | private bool AlwaysAllow => _allowInEditor && _allowInDebugBuild && _allowInDebugBuild; 16 | 17 | #if UNITY_EDITOR 18 | static DebugOnlyProcessor() 19 | { 20 | Initialize(); 21 | } 22 | #endif 23 | 24 | [RuntimeInitializeOnLoadMethod] 25 | private static void Initialize() 26 | { 27 | InputSystem.RegisterProcessor(); 28 | } 29 | 30 | public override float Process(float value, InputControl control) 31 | { 32 | if (AlwaysAllow) 33 | { 34 | return value; 35 | } 36 | 37 | if (Application.isEditor) 38 | { 39 | if (!_allowInEditor) 40 | { 41 | value = 0; 42 | } 43 | } 44 | else 45 | { 46 | if (Debug.isDebugBuild) 47 | { 48 | if (!_allowInDebugBuild) 49 | { 50 | value = 0; 51 | } 52 | } 53 | else 54 | { 55 | if (!_allowInReleaseBuild) 56 | { 57 | value = 0; 58 | } 59 | } 60 | } 61 | 62 | return value; 63 | } 64 | } 65 | } 66 | -------------------------------------------------------------------------------- /Runtime/Input/DebugOnlyProcessor.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 8b1d39e409c6d8d46a8d8b6ace157c87 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Runtime/Input/InputActionEvent.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | using UnityEngine; 4 | using UnityEngine.Events; 5 | using UnityEngine.InputSystem; 6 | 7 | namespace cmdwtf.UnityTools.Input 8 | { 9 | [Serializable] 10 | internal class InputActionEvent 11 | { 12 | [HideInInspector] 13 | public string name; 14 | 15 | [HideInInspector] 16 | public SerializableGuid inputActionGuid; 17 | 18 | public UnityEvent started; 19 | public UnityEvent performed; 20 | public UnityEvent cancelled; 21 | 22 | internal InputActionEvent(InputAction baseAction) 23 | { 24 | name = baseAction.name.SpaceCamelCase(); 25 | inputActionGuid = baseAction.id; 26 | } 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /Runtime/Input/InputActionEvent.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 72c8476dd1f14bae8cc5d1aed40dc0fd 3 | timeCreated: 1638300874 -------------------------------------------------------------------------------- /Runtime/Input/InputActionEvents.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: eda36bb0ef2a85a44b3b9b0d2c24f227 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {fileID: 4621777727084837110, guid: 0000000000000000d000000000000000, type: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Runtime/InstantaneousFrequencyCounter.cs: -------------------------------------------------------------------------------- 1 | namespace cmdwtf.UnityTools 2 | { 3 | public class InstantaneousFrequencyCounter : FrequencyCounterBase 4 | { 5 | private float _elapsed; 6 | private float _nextUpdate; 7 | private float _lastUpdate; 8 | 9 | public InstantaneousFrequencyCounter(ITimeProvider timeProvider) 10 | : base(timeProvider) { } 11 | 12 | public void AddTicks(int sampleCount) => Samples += sampleCount; 13 | 14 | public override void Reset() 15 | { 16 | Samples = 0; 17 | Frequency = 0; 18 | _elapsed = 0; 19 | _nextUpdate = Period; 20 | _lastUpdate = 0; 21 | } 22 | 23 | public override void Tick() => AddTicks(1); 24 | 25 | public override void Update() => Update(Time.UpdateF()); 26 | 27 | public void Update(float deltaSeconds) 28 | { 29 | _elapsed += deltaSeconds; 30 | 31 | if (_elapsed < _nextUpdate) 32 | { 33 | return; 34 | } 35 | 36 | MeasuredSeconds = _elapsed - _lastUpdate; 37 | Frequency = Samples / MeasuredSeconds; 38 | _nextUpdate = _elapsed + Period; 39 | _lastUpdate = _elapsed; 40 | Samples = 0; 41 | } 42 | 43 | public override string ToString() => $"{Frequency.ToString2Points()} Hz"; 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /Runtime/InstantaneousFrequencyCounter.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 7c859d3d97d540a89f0666c904f14b49 3 | timeCreated: 1637080779 -------------------------------------------------------------------------------- /Runtime/LayerExtensions.cs: -------------------------------------------------------------------------------- 1 | using UnityEngine; 2 | 3 | namespace cmdwtf.UnityTools 4 | { 5 | public static class LayerExtensions 6 | { 7 | // via http://answers.unity.com/answers/1712186/view.html 8 | public static int ToLayerIndex(this LayerMask mask) 9 | => (int) Mathf.Log(mask.value, 2); 10 | 11 | public static void SetLayerRecursively(this GameObject obj, int newLayer) 12 | { 13 | obj.layer = newLayer; 14 | 15 | foreach (Transform child in obj.transform) 16 | { 17 | child.gameObject.SetLayerRecursively(newLayer); 18 | } 19 | } 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /Runtime/LayerExtensions.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: f9349026cf834033be49609b8fe70f83 3 | timeCreated: 1634561944 -------------------------------------------------------------------------------- /Runtime/MarshalExtensions.cs: -------------------------------------------------------------------------------- 1 | namespace cmdwtf.UnityTools 2 | { 3 | public static class MarshalExtensions 4 | { 5 | public static string GetAnsiString(this System.IntPtr ptr) 6 | => System.Runtime.InteropServices.Marshal.PtrToStringAnsi(ptr); 7 | 8 | public static string GetAutoString(this System.IntPtr ptr) 9 | => System.Runtime.InteropServices.Marshal.PtrToStringAuto(ptr); 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /Runtime/MarshalExtensions.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: b3d53722f0994cf1aa805176ac0711f9 3 | timeCreated: 1634567294 -------------------------------------------------------------------------------- /Runtime/Math.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: f3d742671f3643d19bc5907f78ed521b 3 | timeCreated: 1634564898 -------------------------------------------------------------------------------- /Runtime/MathExtensions.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 46e16740f20b4a1d8b2e1ba3005f5d6b 3 | timeCreated: 1634564856 -------------------------------------------------------------------------------- /Runtime/NetLegacy.cs: -------------------------------------------------------------------------------- 1 | namespace cmdwtf.UnityTools 2 | { 3 | public static class NetLegacy 4 | { 5 | #if NET_LEGACY 6 | public static class Path 7 | { 8 | public static string Combine(params string [] paths) 9 | { 10 | if (paths == null || paths.Length == 0) 11 | { 12 | return string.Empty; 13 | } 14 | 15 | if (paths.Length == 1) 16 | { 17 | return paths[0]; 18 | } 19 | 20 | string ret = paths[0]; 21 | for (int pathsScan = 1; pathsScan < paths.Length; pathsScan++) 22 | { 23 | ret = Path.Combine(ret, paths[pathsScan]); 24 | } 25 | 26 | return ret; 27 | } 28 | } 29 | #endif // NET_LEGACY 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /Runtime/NetLegacy.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 24e991b841884e3d9d86eb13a5c956f0 3 | timeCreated: 1634565103 -------------------------------------------------------------------------------- /Runtime/NumberExtensions.cs: -------------------------------------------------------------------------------- 1 | namespace cmdwtf.UnityTools 2 | { 3 | public static class NumberExtensions 4 | { 5 | public static string ToStringPercent(this float f) 6 | => $"{f * 100.0f:0.00}%"; 7 | 8 | public static string ToString2Points(this float f) 9 | => $"{f:0.00}"; 10 | 11 | public static string ToString0Points(this float f) 12 | => $"{System.Math.Truncate(f):0.}"; 13 | 14 | public static bool IsFiniteOrZero(this float f) 15 | => float.IsFinite(f) || f == 0; 16 | 17 | public static string ToStringPercent(this double d) 18 | => $"{d * 100.0:0.00}%"; 19 | 20 | public static string ToString2Points(this double d) 21 | => $"{d:0.00}"; 22 | 23 | public static string ToString0Points(this double d) 24 | => $"{System.Math.Truncate(d):0.}"; 25 | 26 | public static bool IsFiniteOrZero(this double d) 27 | => double.IsFinite(d) || d == 0; 28 | 29 | public static string ToStringPercent(this decimal d) 30 | => $"{d * 100.0m:0.00}%"; 31 | 32 | public static string ToString2Points(this decimal d) 33 | => $"{d:0.00}"; 34 | 35 | public static string ToString0Points(this decimal d) 36 | => $"{System.Math.Truncate(d):0.}"; 37 | 38 | public static bool IsFiniteOrZero(this decimal f) 39 | => true; 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /Runtime/NumberExtensions.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: cefd43ff9ac243f3a38a372f084a69f9 3 | timeCreated: 1634565183 -------------------------------------------------------------------------------- /Runtime/ObjectExtensions.cs: -------------------------------------------------------------------------------- 1 | using System.IO; 2 | 3 | #if UNITY_EDITOR 4 | using UnityEditor; 5 | #endif // UNITY_EDITOR 6 | 7 | using UnityEngine; 8 | 9 | namespace cmdwtf.UnityTools 10 | { 11 | public static class ObjectExtensions 12 | { 13 | public static string GetAssetName(this Object obj) 14 | { 15 | #if !UNITY_EDITOR 16 | throw new System.NotSupportedException($"{nameof(GetAssetName)} is only supported in the editor."); 17 | #else // UNITY_EDITOR 18 | string assetPath = AssetDatabase.GetAssetPath(obj.GetInstanceID()); 19 | 20 | return !string.IsNullOrEmpty(assetPath) 21 | ? Path.GetFileNameWithoutExtension(assetPath) 22 | : null; 23 | #endif // !UNITY_EDITOR 24 | } 25 | 26 | public static bool TryGetAssetName(this Object obj, out string assetName) 27 | { 28 | try 29 | { 30 | assetName = obj.GetAssetName(); 31 | return assetName != null; 32 | } 33 | catch (System.Exception /*e*/) 34 | { 35 | assetName = null; 36 | } 37 | 38 | return false; 39 | } 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /Runtime/ObjectExtensions.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: b8657be5e16d48348f180c9a89221f3b 3 | timeCreated: 1637681912 -------------------------------------------------------------------------------- /Runtime/ObjectPool.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Concurrent; 3 | 4 | namespace cmdwtf.UnityTools 5 | { 6 | #if UNITY_2021_1_OR_NEWER 7 | [Obsolete("Unity provides UnityEngine.Pool.ObjectPool, use that instead!")] 8 | #endif 9 | public class ObjectPool 10 | { 11 | private readonly ConcurrentBag _objects; 12 | private readonly Func _objectGenerator; 13 | 14 | public ObjectPool(Func objectGenerator) 15 | { 16 | _objectGenerator = objectGenerator ?? throw new ArgumentNullException(nameof(objectGenerator)); 17 | _objects = new ConcurrentBag(); 18 | } 19 | 20 | public T Get() => _objects.TryTake(out T item) ? item : _objectGenerator(); 21 | 22 | public void Return(T item) => _objects.Add(item); 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /Runtime/ObjectPool.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: ebbbc69ffd8a4c878475780bf1932497 3 | timeCreated: 1637087606 -------------------------------------------------------------------------------- /Runtime/Optional.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using UnityEngine; 3 | // ReSharper disable FieldCanBeMadeReadOnly.Local 4 | 5 | namespace cmdwtf.UnityTools 6 | { 7 | #if UNITY_2020_1_OR_NEWER 8 | [Serializable] 9 | public struct Optional 10 | { 11 | [SerializeField] 12 | internal bool enabled; 13 | [SerializeField] 14 | internal T value; 15 | 16 | public bool Enabled => enabled; 17 | public T Value => value; 18 | 19 | public Optional(T initialValue) 20 | { 21 | enabled = true; 22 | value = initialValue; 23 | } 24 | 25 | public static implicit operator Optional(T initialValue) => new(initialValue); 26 | public static explicit operator T(Optional value) => value.Enabled ? value.Value : default; 27 | 28 | public override string ToString() => Value.ToString(); 29 | } 30 | #endif // UNITY_2020_1_OR_NEWER 31 | } 32 | -------------------------------------------------------------------------------- /Runtime/Optional.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: c9e483e09fe4c5c49bc26d049cc70f90 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Runtime/PersistantData.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.IO; 3 | 4 | using UnityEngine; 5 | 6 | namespace cmdwtf.UnityTools 7 | { 8 | public static class PersistantData 9 | { 10 | public static StreamingAssets.SettingsCollection Settings => StreamingAssets.Settings; 11 | private static string Tag => StreamingAssets.Settings.LogTag; 12 | 13 | public static DateTime GetFileModifiedTime(string path) => File.GetLastWriteTime(path); 14 | 15 | /// 16 | /// Deletes all files matching the search pattern from the persistent data path. 17 | /// 18 | /// The pattern to match 19 | /// A subdirectory (if any) to search in 20 | /// Search option to recurse through directories or search top level only 21 | public static void RemoveFiles(string searchPattern, string subdir = null, SearchOption option = SearchOption.TopDirectoryOnly) 22 | { 23 | string directory = Path.Combine(Application.persistentDataPath, (subdir ?? "")); 24 | string[] files = Directory.GetFiles(directory, searchPattern, option); 25 | 26 | foreach (string file in files) 27 | { 28 | try 29 | { 30 | File.Delete(file); 31 | } 32 | catch (Exception ex) 33 | { 34 | Debug.LogError($"{Tag}Error deleting {file}: {ex.Message}"); 35 | } 36 | } 37 | } 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /Runtime/PersistantData.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: d065be4ee6964bf8ac8eebdf5c20695f 3 | timeCreated: 1634568503 -------------------------------------------------------------------------------- /Runtime/RuntimePlatformExtensions.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 356cf038438f43b5b546d58b26b83cd8 3 | timeCreated: 1637766644 -------------------------------------------------------------------------------- /Runtime/ScriptableObjectBase.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | using UnityEngine; 4 | 5 | namespace cmdwtf.UnityTools 6 | { 7 | public abstract class ScriptableObjectBase : ScriptableObject 8 | { 9 | public string Name => displayName; 10 | public string displayName; 11 | 12 | public event Action Validated; 13 | 14 | protected virtual void OnValidate() 15 | { 16 | #if UNITY_EDITOR 17 | displayName ??= this.GetAssetName() ?? GetType().Name; 18 | #endif // UNITY_EDITOR 19 | 20 | if (string.IsNullOrEmpty(name)) 21 | { 22 | name = displayName; 23 | } 24 | 25 | Validated?.Invoke(); 26 | } 27 | 28 | protected virtual void Reset() 29 | { 30 | #if UNITY_EDITOR 31 | displayName = null; 32 | OnValidate(); 33 | #endif // UNITY_EDITOR 34 | } 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /Runtime/ScriptableObjectBase.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 6ed5566281714b02aca9e06a0b7be354 3 | timeCreated: 1637681690 -------------------------------------------------------------------------------- /Runtime/SerializableGuid.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 424e9d26181a4e91880bf81a33900acf 3 | timeCreated: 1638290368 -------------------------------------------------------------------------------- /Runtime/StreamingAssets.SettingsCollection.cs: -------------------------------------------------------------------------------- 1 | namespace cmdwtf.UnityTools 2 | { 3 | public static partial class StreamingAssets 4 | { 5 | public class SettingsCollection 6 | { 7 | public bool OverwriteOnCopyFromStreaming { get; set; } 8 | public bool OverwriteOnCopyFromStreamingIfNewer { get; set; } 9 | public string AndroidJarPrefix { get; private set; } 10 | public string LogTag { get; set; } 11 | 12 | internal SettingsCollection() 13 | { 14 | Revert(); 15 | } 16 | 17 | public void Revert() 18 | { 19 | OverwriteOnCopyFromStreaming = false; 20 | OverwriteOnCopyFromStreamingIfNewer = true; 21 | LogTag = "[CMD] "; 22 | AndroidJarPrefix = "jar:file://"; 23 | } 24 | } 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /Runtime/StreamingAssets.SettingsCollection.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 2674f5b1aa1e4681ada8d3ecd52d7733 3 | timeCreated: 1634567517 -------------------------------------------------------------------------------- /Runtime/StreamingAssets.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 71060d27d8f6402b9375b08bce17b33a 3 | timeCreated: 1634567343 -------------------------------------------------------------------------------- /Runtime/StringExtensions.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 7a9223c2b19ca9b4680adf8f7c0b293c 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Runtime/Tasks.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 34e69669fab2f7f4d94127160a0ef946 3 | folderAsset: yes 4 | DefaultImporter: 5 | externalObjects: {} 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Runtime/Tasks/UnityTask.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: edbcae90420e5474db3f98dcd6551c99 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Runtime/Tasks/UnityTaskComponent.cs: -------------------------------------------------------------------------------- 1 | using UnityEngine; 2 | 3 | namespace cmdwtf.UnityTools.Tasks 4 | { 5 | public class UnityTaskComponent : MonoBehaviour 6 | { 7 | private static UnityTaskComponent _instance; 8 | 9 | public static UnityTaskComponent Instance 10 | { 11 | get 12 | { 13 | if (_instance) 14 | { 15 | return _instance; 16 | } 17 | 18 | var unityTaskObject = new GameObject("routine"); 19 | var unityTaskComponent = unityTaskObject.AddComponent(); 20 | 21 | DontDestroyOnLoad(unityTaskObject); 22 | _instance = unityTaskComponent; 23 | 24 | return _instance; 25 | } 26 | } 27 | 28 | private void Awake() 29 | { 30 | if (_instance != null) 31 | { 32 | Debug.LogError($"More than one {nameof(UnityTaskComponent)} was attempted to be created.\n" + 33 | $"Please use {nameof(UnityTaskComponent)}.{nameof(Instance)} instead."); 34 | } 35 | } 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /Runtime/Tasks/UnityTaskComponent.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 20672eb9b9f52a44bafd64fe6fba4105 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Runtime/Tasks/UnityTaskEventArgs.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace cmdwtf.UnityTools.Tasks 4 | { 5 | public class UnityTaskEventArgs : EventArgs 6 | { 7 | public bool IsForced { get; } 8 | 9 | public UnityTaskEventArgs(bool isForced) 10 | { 11 | IsForced = isForced; 12 | } 13 | } 14 | 15 | public class UnityTaskEventArgs : UnityTaskEventArgs 16 | { 17 | public TReturnType ReturnValue { get; } 18 | 19 | public UnityTaskEventArgs(bool isForced, TReturnType returnValue) 20 | : base(isForced) 21 | { 22 | ReturnValue = returnValue; 23 | } 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /Runtime/Tasks/UnityTaskEventArgs.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: e82858f5d3e17724ca4e747eaa394f79 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Runtime/Tasks/WaitForCompletion.cs: -------------------------------------------------------------------------------- 1 | using UnityEngine; 2 | 3 | namespace cmdwtf.UnityTools.Tasks 4 | { 5 | public class WaitForCompletion : CustomYieldInstruction 6 | { 7 | private UnityTask Task { get; } 8 | 9 | public override bool keepWaiting => Task.IsRunning; 10 | 11 | public WaitForCompletion(UnityTask task) 12 | { 13 | Task = task; 14 | } 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /Runtime/Tasks/WaitForCompletion.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 3cc824f29c3f9cb49959f527a7cabde0 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Runtime/TerrainExtensions.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 83a414096cca420f9dd9bd11d7d78374 3 | timeCreated: 1636566914 -------------------------------------------------------------------------------- /Runtime/Texture2DExtensions.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 249e2a2d2c0b4ab4b5aaffbaf22c2d97 3 | timeCreated: 1658169349 -------------------------------------------------------------------------------- /Runtime/TimeProviderBase.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace cmdwtf.UnityTools 4 | { 5 | public abstract class TimeProviderBase : ITimeProvider 6 | { 7 | public double Period { get; set; } 8 | 9 | public float PeriodF 10 | { 11 | get => (float)Period; 12 | set => Period = value; 13 | } 14 | 15 | public abstract double NowSeconds { get; } 16 | public virtual float NowSecondsF => (float)NowSeconds; 17 | 18 | public virtual double DeltaSeconds { get; protected set; } 19 | public virtual float DeltaSecondsF => (float)DeltaSeconds; 20 | public abstract long UnixTimestamp { get; } 21 | 22 | protected double LastUpdate { get; set; } = double.NaN; 23 | 24 | public TimeProviderBase() 25 | : this(0d) 26 | { } 27 | 28 | public TimeProviderBase(double period = 0) 29 | { 30 | Period = period; 31 | } 32 | 33 | public TimeProviderBase(float periodF = 0) 34 | { 35 | PeriodF = periodF; 36 | } 37 | 38 | public virtual double Update() 39 | { 40 | double now = NowSeconds; 41 | 42 | if (double.IsNaN(LastUpdate)) 43 | { 44 | LastUpdate = now; 45 | return 0; 46 | } 47 | 48 | DeltaSeconds = now - LastUpdate; 49 | LastUpdate = now; 50 | return DeltaSeconds; 51 | } 52 | 53 | public virtual float UpdateF() => (float)Update(); 54 | } 55 | } 56 | -------------------------------------------------------------------------------- /Runtime/TimeProviderBase.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: d16e6da8215d49ddbb13f71d062cdad0 3 | timeCreated: 1637170641 -------------------------------------------------------------------------------- /Runtime/TimeProviders.cs: -------------------------------------------------------------------------------- 1 | namespace cmdwtf.UnityTools 2 | { 3 | public static class TimeProviders 4 | { 5 | #if UNITY 6 | public static ITimeProvider GetDefault(double period = 1d) => GetUnityTimeProvider(period); 7 | public static ITimeProvider GetDefault(float period) => GetUnityTimeProvider(period); 8 | public static UnityTimeProvider GetUnityTimeProvider(double period = 0d) => new UnityTimeProvider(period); 9 | public static UnityTimeProvider GetUnityTimeProvider(float period) => new UnityTimeProvider(period); 10 | #else 11 | public static ITimeProvider GetDefault(double period = 1d) => GetDotNetTimeProvider(period); 12 | public static ITimeProvider GetDefault(float period) => GetDotNetTimeProvider(period); 13 | public static DotNetTimeProvider GetDotNetTimeProvider(double period = 0d) => new DotNetTimeProvider(period); 14 | public static DotNetTimeProvider GetDotNetTimeProvider(float period) => new DotNetTimeProvider(period); 15 | #endif // UNITY 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /Runtime/TimeProviders.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: ae4e941652de42b1b79fdcb39c999109 3 | timeCreated: 1637173066 -------------------------------------------------------------------------------- /Runtime/TransformExtensions.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: c969695f386343698735d1830bd14678 3 | timeCreated: 1634561909 -------------------------------------------------------------------------------- /Runtime/UI.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 07025acd4efe49a386075b4a045b8a29 3 | timeCreated: 1638214803 -------------------------------------------------------------------------------- /Runtime/UI/DefaultPageManager.cs: -------------------------------------------------------------------------------- 1 | namespace cmdwtf.UnityTools.UI 2 | { 3 | public class DefaultPageManager : PageManager 4 | { 5 | 6 | } 7 | } 8 | -------------------------------------------------------------------------------- /Runtime/UI/DefaultPageManager.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 1c0df6cd95dc6f545a86c853d9ff220c 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Runtime/UI/HeldButton.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: a0fc8a45a25144979e1000088f48b55b 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {fileID: -2246836292574321313, guid: 0000000000000000d000000000000000, type: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Runtime/UI/IPageContainer.cs: -------------------------------------------------------------------------------- 1 | using System.Collections.Generic; 2 | 3 | namespace cmdwtf.UnityTools.UI 4 | { 5 | public interface IPageContainer 6 | { 7 | IPageDescription CurrentPage { get; } 8 | IReadOnlyCollection Pages { get; } 9 | void OpenFirstPage(); 10 | void OpenPage(string pageName); 11 | void NextPage(); 12 | void PreviousPage(); 13 | void ShowCurrentPage(); 14 | void HideCurrentPage(); 15 | void ShowCurrentButton(); 16 | void HideCurrentButton(); 17 | IPageDescription AddNewPageDescription(); 18 | void AddPage(IPageDescription page); 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /Runtime/UI/IPageContainer.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: f86e97e7a659a574a89982326b1e37f0 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Runtime/UI/IPageDescription.cs: -------------------------------------------------------------------------------- 1 | using UnityEngine; 2 | 3 | namespace cmdwtf.UnityTools.UI 4 | { 5 | public interface IPageDescription 6 | { 7 | string Name { get; set; } 8 | Page Page { get; set; } 9 | GameObject Button { get; set; } 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /Runtime/UI/IPageDescription.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 901bb025f95a5cb4f998d3e4b1ae86a3 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Runtime/UI/Page.cs: -------------------------------------------------------------------------------- 1 | using cmdwtf.UnityTools.Attributes; 2 | 3 | using UnityEngine; 4 | 5 | namespace cmdwtf.UnityTools.UI 6 | { 7 | [RequireComponent(typeof(CanvasGroup))] 8 | public class Page : MonoBehaviour 9 | { 10 | public bool IsShown { get; internal set; } = false; 11 | public bool IsHidden => !IsShown; 12 | public bool IsHiding { get; internal set; } 13 | 14 | public float Alpha => canvasGroup.alpha; 15 | 16 | [SerializeField, Autohook] 17 | private CanvasGroup canvasGroup; 18 | 19 | public virtual bool PageDisabled 20 | => gameObject.activeInHierarchy == false || 21 | enabled == false; 22 | 23 | protected virtual void Awake() 24 | { 25 | canvasGroup = GetComponent(); 26 | canvasGroup.alpha = 0; 27 | } 28 | 29 | protected virtual void Start() { } 30 | protected virtual void Update() { } 31 | 32 | public virtual void OnPageShowing() { } 33 | public virtual void OnPageShown() { } 34 | public virtual void OnPageHiding() { } 35 | public virtual void OnPageHidden() { } 36 | 37 | public IPageDescription GetDescription() 38 | => new PageDescription() 39 | { 40 | Name = name, 41 | Page = this, 42 | Button = null, 43 | }; 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /Runtime/UI/Page.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: b13e564a7564686428cd17a60054098f 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Runtime/UI/PageContainer.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: d76a2bb1f7f19c343a34d13fbe88af7f 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Runtime/UI/PageDescription.cs: -------------------------------------------------------------------------------- 1 | using UnityEngine; 2 | 3 | namespace cmdwtf.UnityTools.UI 4 | { 5 | public class PageDescription : IPageDescription 6 | { 7 | public string Name { get; set; } 8 | public Page Page { get; set; } 9 | public GameObject Button { get; set; } 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /Runtime/UI/PageDescription.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 2e569f1d12454a640bc9df3946c20593 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Runtime/UI/PageManager.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 643b5d52ce557b84fa41d50d784cda7e 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Runtime/UniqueNamespaceAttribute.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace cmdwtf.UnityTools 4 | { 5 | /// 6 | /// An attribute that can be applied to a to adjust the sub-Resources 7 | /// name of the folder the asset is saved in. 8 | /// 9 | [AttributeUsage(AttributeTargets.Class, AllowMultiple = false, Inherited = true)] 10 | public class UniqueNamespaceAttribute : Attribute 11 | { 12 | public string Namespace { get; } 13 | 14 | public UniqueNamespaceAttribute(string @namespace) 15 | { 16 | Namespace = @namespace; 17 | } 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /Runtime/UniqueNamespaceAttribute.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 09bdb7b770a8413d8f91a0f8e92e0408 3 | timeCreated: 1677252220 -------------------------------------------------------------------------------- /Runtime/UniqueScriptableObject.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 0debbeef6d35cd849b32227da73e25cf 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Runtime/UnityTaskManager.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 11f74ed62bb4ddb42b94eecbff8ce0a2 3 | folderAsset: yes 4 | DefaultImporter: 5 | externalObjects: {} 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Runtime/UnityTaskManager/InterpolationType.cs: -------------------------------------------------------------------------------- 1 | namespace UnityCoroutineManager 2 | { 3 | public enum InterpolationType 4 | { 5 | /// Standard linear interpolation 6 | Linear = 0, 7 | 8 | /// Smooth fade interpolation 9 | SmoothStep = 1, 10 | 11 | /// Smoother fade interpolation than SmoothStep 12 | SmootherStep = 2, 13 | 14 | /// Sine interpolation, smoothing at the end 15 | Sinerp = 3, 16 | 17 | /// Cosine interpolation, smoothing at the start 18 | Coserp = 4, 19 | 20 | /// Extreme bend towards end, low speed at end 21 | Square = 5, 22 | 23 | /// Extreme bend toward start, high speed at end 24 | Quadratic = 6, 25 | 26 | /// Stronger bending than Quadratic 27 | Cubic = 7, 28 | 29 | /// Spherical interpolation, vertical speed at start 30 | CircularStart = 8, 31 | 32 | /// Spherical interpolation, vertical speed at end 33 | CircularEnd = 9, 34 | 35 | /// Pure Random interpolation 36 | Random = 10, 37 | 38 | /// Random interpolation with linear constraining at 0..1 39 | RandomConstrained = 11 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /Runtime/UnityTaskManager/InterpolationType.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 58caee4ae46b4d6e9d1992bf78a95d98 3 | timeCreated: 1670945349 -------------------------------------------------------------------------------- /Runtime/UnityTaskManager/LICENSE: -------------------------------------------------------------------------------- 1 | Copyright © 2021 Chris Marc Dailey (nitz) 2 | 3 | 5 years later, the derivation from this code, done by Wildan Mubarok 4 | Everyone is still granted non-exclusive license to do anything at all with this code. 5 | 6 | Copyright (c) 2011, Ken Rockot . All rights reserved. 7 | Everyone is granted non-exclusive license to do anything at all with this code. 8 | -------------------------------------------------------------------------------- /Runtime/UnityTaskManager/LICENSE.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: a45d3a30f968d4c43819b6c3bb2d6163 3 | DefaultImporter: 4 | externalObjects: {} 5 | userData: 6 | assetBundleName: 7 | assetBundleVariant: 8 | -------------------------------------------------------------------------------- /Runtime/UnityTaskManager/ListPool.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 6762963ebff22c543bc8f6d4bbaab49f 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Runtime/UnityTaskManager/ObjectPool.cs: -------------------------------------------------------------------------------- 1 | using System.Collections.Generic; 2 | using UnityEngine.Events; 3 | using UnityEngine; 4 | 5 | namespace UnityCoroutineManager 6 | { 7 | public class ObjectPool where T : new () 8 | { 9 | private readonly Stack m_Stack = new Stack(); 10 | 11 | #if UNITY_EDITOR 12 | public int countAll { get; private set; } 13 | public int countActive { get { return countAll - countInactive; } } 14 | public int countInactive { get { return m_Stack.Count; } } 15 | #endif 16 | 17 | public T Get() 18 | { 19 | T element; 20 | if (m_Stack.Count == 0) 21 | { 22 | element = new T(); 23 | #if UNITY_EDITOR 24 | countAll++; 25 | // Debug.LogFormat( "Pop New {0}, Total {1}", typeof(T).Name, countAll); 26 | #endif 27 | } 28 | else 29 | { 30 | element = m_Stack.Pop(); 31 | } 32 | return element; 33 | } 34 | 35 | public void Release(T element) 36 | { 37 | #if UNITY_EDITOR 38 | if (m_Stack.Count > 0 && ReferenceEquals(m_Stack.Peek(), element)) 39 | Debug.LogError("Internal error. Trying to destroy object that is already released to pool."); 40 | #endif 41 | m_Stack.Push(element); 42 | } 43 | } 44 | } -------------------------------------------------------------------------------- /Runtime/UnityTaskManager/ObjectPool.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: be8eb4b7c9576664e987fcedcdf7bfc5 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Runtime/UnityTaskManager/OriginalSource.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: bd42338e4bce7694fbb9d60433e46960 3 | folderAsset: yes 4 | DefaultImporter: 5 | externalObjects: {} 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Runtime/UnityTaskManager/OriginalSource/UnityTaskManager.zip: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cmdwtf/UnityTools/948844e2efacff389f027fa925ec634671581486/Runtime/UnityTaskManager/OriginalSource/UnityTaskManager.zip -------------------------------------------------------------------------------- /Runtime/UnityTaskManager/OriginalSource/UnityTaskManager.zip.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: fc90af2085a67a4448a89a41bf1bab39 3 | DefaultImporter: 4 | externalObjects: {} 5 | userData: 6 | assetBundleName: 7 | assetBundleVariant: 8 | -------------------------------------------------------------------------------- /Runtime/UnityTaskManager/README.md.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 72ab23e1b83e4404a865212bef45698a 3 | TextScriptImporter: 4 | externalObjects: {} 5 | userData: 6 | assetBundleName: 7 | assetBundleVariant: 8 | -------------------------------------------------------------------------------- /Runtime/UnityTaskManager/Task.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: da29c7c180374405b1ca63aa2699571c 3 | timeCreated: 1670944903 -------------------------------------------------------------------------------- /Runtime/UnityTaskManager/TaskManager.cs: -------------------------------------------------------------------------------- 1 | // Copyright © 2021-2022 Chris Marc Dailey (nitz) 2 | // 3 | // 5 years later, the derivation from this code, done by Wildan Mubarok 4 | // Everyone is still granted non-exclusive license to do anything at all with this code. 5 | // 6 | // Copyright (c) 2011, Ken Rockot . All rights reserved. 7 | // Everyone is granted non-exclusive license to do anything at all with this code. 8 | 9 | using UnityEngine; 10 | using System.Collections; 11 | 12 | namespace UnityCoroutineManager 13 | { 14 | internal class TaskManager : MonoBehaviour 15 | { 16 | internal static TaskManager Instance { get; private set; } 17 | 18 | public static TaskState CreateTask(IEnumerator coroutine) 19 | { 20 | if (Instance == null) 21 | { 22 | var go = new GameObject("TaskManager"); 23 | Instance = go.AddComponent(); 24 | } 25 | 26 | return new TaskState(coroutine); 27 | } 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /Runtime/UnityTaskManager/TaskManager.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 4f4dcdb290ebedc46a672355b18541f4 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Runtime/UnityTaskManager/TaskState.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: c35f19431a454dabb3c7077d2ca59fed 3 | timeCreated: 1670944933 -------------------------------------------------------------------------------- /Runtime/UnityThreadingHelper.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 9520682d97d837741adc46dd5b5883e9 3 | folderAsset: yes 4 | DefaultImporter: 5 | externalObjects: {} 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Runtime/UnityThreadingHelper/ActionExtension.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: f34981d87d3f11241b200652e2d68592 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Runtime/UnityThreadingHelper/Channel.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 68df9cd380d86a844a056074102c0b7d 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Runtime/UnityThreadingHelper/Dispatcher.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: e915ccd411bda3e49a705779d84d0d97 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Runtime/UnityThreadingHelper/EnumerableExtension.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 09fe9b9c9d715bf41b6410ed2e7b0834 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Runtime/UnityThreadingHelper/EnumeratorExtension.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using System.Collections; 6 | 7 | namespace UnityThreading 8 | { 9 | public static class EnumeratorExtension 10 | { 11 | /// 12 | /// Starts the Enumerator as async Task on the given TaskDistributor. 13 | /// 14 | /// The task. 15 | public static Task RunAsync(this IEnumerator that) 16 | { 17 | return that.RunAsync(UnityThreadHelper.TaskDistributor); 18 | } 19 | 20 | /// 21 | /// Starts the Enumerator as async Task on the given TaskDistributor. 22 | /// 23 | /// The TaskDistributor instance on which the operation should perform. 24 | /// The task. 25 | public static Task RunAsync(this IEnumerator that, TaskDistributor target) 26 | { 27 | return target.Dispatch(Task.Create(that)); 28 | } 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /Runtime/UnityThreadingHelper/EnumeratorExtension.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: cb5cfc81aae2090459c5e1576e15181b 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Runtime/UnityThreadingHelper/ObjectExtension.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 68ff9e0efd9052e4ea7bf96106ab8390 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Runtime/UnityThreadingHelper/OriginalSource.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: f78a3361ed9553b4bb124621156c157d 3 | folderAsset: yes 4 | DefaultImporter: 5 | externalObjects: {} 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Runtime/UnityThreadingHelper/OriginalSource/$UnityThreading.zip: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cmdwtf/UnityTools/948844e2efacff389f027fa925ec634671581486/Runtime/UnityThreadingHelper/OriginalSource/$UnityThreading.zip -------------------------------------------------------------------------------- /Runtime/UnityThreadingHelper/OriginalSource/$UnityThreading.zip.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 2bba3a4e3c0daf841aeaa129c3bc3b68 3 | DefaultImporter: 4 | externalObjects: {} 5 | userData: 6 | assetBundleName: 7 | assetBundleVariant: 8 | -------------------------------------------------------------------------------- /Runtime/UnityThreadingHelper/SwitchTo.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | 6 | namespace UnityThreading 7 | { 8 | public class SwitchTo 9 | { 10 | public enum TargetType 11 | { 12 | Main, 13 | Thread 14 | } 15 | 16 | public TargetType Target { get; private set; } 17 | 18 | private SwitchTo(TargetType target) 19 | { 20 | Target = target; 21 | } 22 | 23 | /// 24 | /// Changes the context of the following commands to the MainThread when yielded. 25 | /// 26 | public static readonly SwitchTo MainThread = new SwitchTo(TargetType.Main); 27 | 28 | /// 29 | /// Changes the context of the following commands to the WorkerThread when yielded. 30 | /// 31 | public static readonly SwitchTo Thread = new SwitchTo(TargetType.Thread); 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /Runtime/UnityThreadingHelper/SwitchTo.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 9f263b1b0f078a0488e745a2291c189b 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Runtime/UnityThreadingHelper/Task.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 99412057fbaa20b4cb87993bc82cbce8 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Runtime/UnityThreadingHelper/TaskDistributer.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 4cc0ddfad6c42314080e55db93a5883e 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Runtime/UnityThreadingHelper/TaskExtension.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 672ce693009b41d49918d34796c2d42c 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Runtime/UnityThreadingHelper/Thread.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 6a955b2599d5f5f44b50d74c24b16d00 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Runtime/UnityThreadingHelper/UnityThreadHelper.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 0aff9cdf4fe7d1d40b361dab6c23580c 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Runtime/UnityThreadingHelper/WaitOneExtension.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | 6 | #if !NO_UNITY 7 | using UnityEngine; 8 | #endif 9 | 10 | namespace UnityThreading 11 | { 12 | public static class WaitOneExtension 13 | { 14 | #if UNITY_WEBPLAYER 15 | private static System.Reflection.MethodInfo WaitOneMilliseconds; 16 | private static System.Reflection.MethodInfo WaitOneTimeSpan; 17 | 18 | static WaitOneExtension() 19 | { 20 | var type = typeof(System.Threading.ManualResetEvent); 21 | WaitOneMilliseconds = type.GetMethod("WaitOne", new System.Type[1] { typeof(int) }); 22 | WaitOneTimeSpan = type.GetMethod("WaitOne", new System.Type[1] { typeof(TimeSpan) }); 23 | } 24 | 25 | 26 | public static bool InterWaitOne(this System.Threading.ManualResetEvent that, int ms) 27 | { 28 | return (bool)WaitOneMilliseconds.Invoke(that, new object[1] { ms }); 29 | } 30 | 31 | public static bool InterWaitOne(this System.Threading.ManualResetEvent that, TimeSpan duration) 32 | { 33 | return (bool)WaitOneTimeSpan.Invoke(that, new object[1] { duration }); 34 | } 35 | #else 36 | public static bool InterWaitOne(this System.Threading.ManualResetEvent that, int ms) 37 | { 38 | return that.WaitOne(ms, false); 39 | } 40 | 41 | public static bool InterWaitOne(this System.Threading.ManualResetEvent that, TimeSpan duration) 42 | { 43 | return that.WaitOne(duration, false); 44 | } 45 | #endif 46 | } 47 | } -------------------------------------------------------------------------------- /Runtime/UnityThreadingHelper/WaitOneExtension.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: cd63e68a38b254947bf5c1faf7eec40d 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Runtime/UnityTimeProvider.cs: -------------------------------------------------------------------------------- 1 | using UnityEngine; 2 | 3 | #if UNITY 4 | namespace cmdwtf.UnityTools 5 | { 6 | public class UnityTimeProvider : TimeProviderBase 7 | { 8 | protected readonly DotNetTimeProvider DotNetTime = new DotNetTimeProvider(); 9 | public override double NowSeconds => Time.realtimeSinceStartupAsDouble; 10 | public override float NowSecondsF => Time.realtimeSinceStartup; 11 | public override long UnixTimestamp => DotNetTime.UnixTimestamp; 12 | 13 | public UnityTimeProvider() { } 14 | 15 | public UnityTimeProvider(double period = 0) 16 | : base(period) { } 17 | 18 | public UnityTimeProvider(float periodF = 0) 19 | : base(periodF) { } 20 | } 21 | } 22 | #endif // UNITY 23 | -------------------------------------------------------------------------------- /Runtime/UnityTimeProvider.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 7b213f2df1964a65a82f8abc62471588 3 | timeCreated: 1637171001 -------------------------------------------------------------------------------- /Runtime/ValueRange.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 0ba2e4de5bcf18b4683eae95b5526f11 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Runtime/ValueRangeSampleMode.cs: -------------------------------------------------------------------------------- 1 | namespace cmdwtf.UnityTools 2 | { 3 | public enum ValueRangeSampleMode 4 | { 5 | Random, 6 | DeltaTime, 7 | MinimumOnly, 8 | MaximumOnly, 9 | MidpointOnly, 10 | Default = Random, 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /Runtime/ValueRangeSampleMode.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 82e7d3ae868d421ba3667bfd7d1e1d73 3 | timeCreated: 1657204397 -------------------------------------------------------------------------------- /Runtime/VectorExtensions.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: b8d75aaa69104e68af401740c7cc8460 3 | timeCreated: 1634565000 -------------------------------------------------------------------------------- /Runtime/WWWExtensions.cs: -------------------------------------------------------------------------------- 1 | using UnityEngine; 2 | 3 | namespace cmdwtf.UnityTools 4 | { 5 | public static class WWWExtensions 6 | { 7 | #pragma warning disable 0618 8 | public static bool HasError(this WWW w, string errorStringPrefix = "ERROR") 9 | => string.IsNullOrEmpty(w.error) == false || 10 | w.text.StartsWith(errorStringPrefix); 11 | #pragma warning restore 0618 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /Runtime/WWWExtensions.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: c3bc350e4d034dd18fadc36160297727 3 | timeCreated: 1634562013 -------------------------------------------------------------------------------- /Runtime/Wildcard.cs: -------------------------------------------------------------------------------- 1 | using System.Text.RegularExpressions; 2 | 3 | namespace cmdwtf.UnityTools 4 | { 5 | /// 6 | /// Represents a wildcard running on the 7 | /// engine. 8 | /// 9 | public class Wildcard : Regex 10 | { 11 | /// 12 | /// Initializes a wildcard with the given search pattern. 13 | /// 14 | /// The wildcard pattern to match. 15 | public Wildcard(string pattern) 16 | : base(WildcardToRegex(pattern)) 17 | { 18 | } 19 | 20 | /// 21 | /// Initializes a wildcard with the given search pattern and options. 22 | /// 23 | /// The wildcard pattern to match. 24 | /// A combination of one or errors 25 | /// . 26 | public Wildcard(string pattern, RegexOptions options) 27 | : base(WildcardToRegex(pattern), options) 28 | { 29 | } 30 | 31 | /// 32 | /// Converts a wildcard to a regex. 33 | /// 34 | /// The wildcard pattern to convert. 35 | /// A regex equivalent of the given wildcard. 36 | public static string WildcardToRegex(string pattern) 37 | => $"^{Escape(pattern).Replace("\\*", ".*").Replace("\\?", ".")}$"; 38 | } 39 | } -------------------------------------------------------------------------------- /Runtime/Wildcard.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 43ae4ded751b4cb43886c90c36a0c4d6 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Runtime/WindowedFrequencyCounter.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | 5 | using UnityEngine; 6 | 7 | namespace cmdwtf.UnityTools 8 | { 9 | public class WindowedFrequencyCounter : FrequencyCounterBase 10 | { 11 | private readonly Queue _samples = new Queue(); 12 | private float _startTime; 13 | 14 | public override int Samples => _samples.Count; 15 | 16 | public WindowedFrequencyCounter(float period) 17 | : base(null, period) 18 | { 19 | 20 | } 21 | 22 | public WindowedFrequencyCounter(ITimeProvider timeProvider = null) 23 | : base(timeProvider) 24 | { 25 | _startTime = Time.NowSecondsF; 26 | } 27 | 28 | public override void Reset() 29 | { 30 | _samples.Clear(); 31 | Frequency = 0; 32 | _startTime = Time.NowSecondsF; 33 | } 34 | 35 | public override void Tick() 36 | { 37 | float timestamp = Time.NowSecondsF; 38 | _samples.Enqueue(timestamp); 39 | } 40 | 41 | public override void Update() 42 | { 43 | float now = Time.NowSecondsF; 44 | 45 | // clear out samples older than the measure duration 46 | while (_samples.Any() && now - _samples.Peek() > Period) 47 | { 48 | _samples.Dequeue(); 49 | } 50 | 51 | // calculate how long we've been holding samples 52 | MeasuredSeconds = System.Math.Min(now - _startTime, Period); 53 | 54 | // update the frequency value 55 | Frequency = Samples / MeasuredSeconds; 56 | } 57 | 58 | public override string ToString() => $"{Frequency.ToString2Points()} Hz"; 59 | } 60 | } 61 | -------------------------------------------------------------------------------- /Runtime/WindowedFrequencyCounter.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: a219087003fd43ad8f14600cbdf1d679 3 | timeCreated: 1637081531 -------------------------------------------------------------------------------- /Runtime/cmdwtf.UnityTools.asmdef: -------------------------------------------------------------------------------- 1 | { 2 | "name": "cmdwtf.UnityTools", 3 | "rootNamespace": "cmdwtf.UnityTools", 4 | "references": [ 5 | "GUID:75469ad4d38634e559750d17036d5f7c" 6 | ], 7 | "includePlatforms": [], 8 | "excludePlatforms": [], 9 | "allowUnsafeCode": false, 10 | "overrideReferences": false, 11 | "precompiledReferences": [], 12 | "autoReferenced": true, 13 | "defineConstraints": [], 14 | "versionDefines": [], 15 | "noEngineReferences": false 16 | } -------------------------------------------------------------------------------- /Runtime/cmdwtf.UnityTools.asmdef.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: c5269df1601f2694ea7cc39324c42246 3 | AssemblyDefinitionImporter: 4 | externalObjects: {} 5 | userData: 6 | assetBundleName: 7 | assetBundleVariant: 8 | -------------------------------------------------------------------------------- /Runtime/iGUITools.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 66703f7922b0a004caa109405d000951 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Runtime/iOSTools.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | 4 | namespace cmdwtf.UnityTools 5 | { 6 | public static class iOSTools 7 | { 8 | public static int iOSCompareToSafe(this Guid lhs, Guid rhs) 9 | { 10 | #if UNITY_IOS || UNITY_IPHONE 11 | return lhs.ToString().CompareTo(rhs.ToString()); 12 | #else 13 | return lhs.CompareTo(rhs); 14 | #endif // IOS/IPHONE 15 | } 16 | 17 | public class iOSGuidComparer : IEqualityComparer 18 | { 19 | #region IEqualityComparer implementation 20 | 21 | public bool Equals(Guid x, Guid y) 22 | => x.iOSCompareToSafe(y) == 0; 23 | 24 | public int GetHashCode(Guid obj) 25 | => obj.GetHashCode(); 26 | 27 | #endregion 28 | } 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /Runtime/iOSTools.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: bc30bd34f3d1447e86cfad0d2ecf1ceb 3 | timeCreated: 1634569178 -------------------------------------------------------------------------------- /copyright.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 3e55b4d813f78a9479905e1c82222fbf 3 | DefaultImporter: 4 | externalObjects: {} 5 | userData: 6 | assetBundleName: 7 | assetBundleVariant: 8 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "wtf.cmd.tools", 3 | "version": "0.0.6", 4 | "displayName": "cmd.wtf Unity Tools", 5 | "description": "A small collection of tools that multiple projects make use of.", 6 | "category": "Libraries", 7 | "dependencies": { 8 | "com.unity.inputsystem": "1.3.0" 9 | }, 10 | "unity": "2018.1", 11 | "keywords": [ 12 | "tools", 13 | "editor", 14 | "attributes", 15 | "wildcard", 16 | "gizmo", 17 | "gizmos", 18 | "icons", 19 | "threading", 20 | "tasks", 21 | "coroutines", 22 | "autohook", 23 | "getcomponent", 24 | "findcomponent", 25 | "dynamics", 26 | "math", 27 | "interpolation" 28 | ], 29 | "author": { 30 | "name": "Chris Marc Dailey (nitz)", 31 | "url": "https://cmd.wtf/" 32 | }, 33 | "license": "None", 34 | "hideInEditor": false, 35 | "type": "library" 36 | } 37 | -------------------------------------------------------------------------------- /package.json.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: dbe544aa151140a4fb83945fc7e95f6e 3 | PackageManifestImporter: 4 | externalObjects: {} 5 | userData: 6 | assetBundleName: 7 | assetBundleVariant: 8 | --------------------------------------------------------------------------------