├── .gitignore ├── CHANGELOG.md ├── CHANGELOG.md.meta ├── Editor.meta ├── Editor ├── RateManagerInspector.cs ├── RateManagerInspector.cs.meta ├── RateRequestAnimationComponentInspector.cs ├── RateRequestAnimationComponentInspector.cs.meta ├── RateRequestAnimatorComponentInspector.cs ├── RateRequestAnimatorComponentInspector.cs.meta ├── RateRequestComponentInspector.cs ├── RateRequestComponentInspector.cs.meta ├── RateRequestTrackerTreeView.cs ├── RateRequestTrackerTreeView.cs.meta ├── RateRequestTrackerWindow.cs ├── RateRequestTrackerWindow.cs.meta ├── UniRate.Editor.asmdef └── UniRate.Editor.asmdef.meta ├── Examples.meta ├── Examples ├── AnimClipLoop_H_Three.anim ├── AnimClipLoop_H_Three.anim.meta ├── AnimClipLoop_V_Three.anim ├── AnimClipLoop_V_Three.anim.meta ├── AnimClip_State_1_Three.anim ├── AnimClip_State_1_Three.anim.meta ├── AnimClip_State_2_Three.anim ├── AnimClip_State_2_Three.anim.meta ├── AnimController_Three.controller ├── AnimController_Three.controller.meta ├── ExampleScene_One.unity ├── ExampleScene_One.unity.meta ├── ExampleScene_Three.unity ├── ExampleScene_Three.unity.meta ├── ExampleScene_Two.unity ├── ExampleScene_Two.unity.meta ├── ExampleScript_One.cs ├── ExampleScript_One.cs.meta ├── UniRate.Examples.asmdef └── UniRate.Examples.asmdef.meta ├── LICENSE.md ├── LICENSE.md.meta ├── Legacy.meta ├── Legacy ├── CustomUnityEvents.cs ├── CustomUnityEvents.cs.meta ├── Frame Rate.meta ├── Frame Rate │ ├── FrameRateLooper.cs │ ├── FrameRateLooper.cs.meta │ ├── FrameRateManager.cs │ ├── FrameRateManager.cs.meta │ ├── FrameRateRequest.cs │ ├── FrameRateRequest.cs.meta │ ├── FrameRateRequestComponent.cs │ ├── FrameRateRequestComponent.cs.meta │ ├── FrameRateRequester.cs │ ├── FrameRateRequester.cs.meta │ ├── FrameRateTrigger.cs │ ├── FrameRateTrigger.cs.meta │ ├── FrameRateType.cs │ └── FrameRateType.cs.meta ├── Memory.meta ├── Memory │ ├── LowMemoryTrigger.cs │ ├── LowMemoryTrigger.cs.meta │ ├── MemoryManager.cs │ └── MemoryManager.cs.meta ├── Power Profiles.meta ├── Power Profiles │ ├── Components.meta │ ├── Components │ │ ├── PowerProfileComponent.cs │ │ ├── PowerProfileComponent.cs.meta │ │ ├── PowerProfileComponentDelayedRelease.cs │ │ ├── PowerProfileComponentDelayedRelease.cs.meta │ │ ├── PowerProfileInputField.cs │ │ ├── PowerProfileInputField.cs.meta │ │ ├── PowerProfileScrollRect.cs │ │ ├── PowerProfileScrollRect.cs.meta │ │ ├── PowerProfileTMPInputField.cs │ │ ├── PowerProfileTMPInputField.cs.meta │ │ ├── PowerProfileTouches.cs │ │ └── PowerProfileTouches.cs.meta │ ├── PowerProfile.cs │ ├── PowerProfile.cs.meta │ ├── PowerProfileCombo.cs │ ├── PowerProfileCombo.cs.meta │ ├── PowerProfileFrameRate.cs │ ├── PowerProfileFrameRate.cs.meta │ ├── PowerProfileRenderInterval.cs │ └── PowerProfileRenderInterval.cs.meta ├── Render Interval.meta ├── Render Interval │ ├── RenderIntervalManager.cs │ ├── RenderIntervalManager.cs.meta │ ├── RenderIntervalManagerPointer.cs │ ├── RenderIntervalManagerPointer.cs.meta │ ├── RenderIntervalRequest.cs │ ├── RenderIntervalRequest.cs.meta │ ├── RenderIntervalRequestComponent.cs │ ├── RenderIntervalRequestComponent.cs.meta │ ├── RenderIntervalRequester.cs │ ├── RenderIntervalRequester.cs.meta │ ├── RenderIntervalTrigger.cs │ └── RenderIntervalTrigger.cs.meta ├── UniRate.Legacy.asmdef └── UniRate.Legacy.asmdef.meta ├── README.md ├── README.md.meta ├── Runtime.meta ├── Runtime ├── Components.meta ├── Components │ ├── RateRequestAnimationComponent.cs │ ├── RateRequestAnimationComponent.cs.meta │ ├── RateRequestAnimatorComponent.cs │ ├── RateRequestAnimatorComponent.cs.meta │ ├── RateRequestComponent.cs │ ├── RateRequestComponent.cs.meta │ ├── RateRequestInputFieldComponent.cs │ ├── RateRequestInputFieldComponent.cs.meta │ ├── RateRequestScrollRectComponent.cs │ ├── RateRequestScrollRectComponent.cs.meta │ ├── RateRequestTMPInputFieldComponent.cs │ ├── RateRequestTMPInputFieldComponent.cs.meta │ ├── RateRequestTouchComponent.cs │ ├── RateRequestTouchComponent.cs.meta │ ├── RateRequestWhileEnabledComponent.cs │ └── RateRequestWhileEnabledComponent.cs.meta ├── Controllers.meta ├── Controllers │ ├── RateManagerFixedUpdateRateController.cs │ ├── RateManagerFixedUpdateRateController.cs.meta │ ├── RateManagerRenderIntervalController.cs │ ├── RateManagerRenderIntervalController.cs.meta │ ├── RateManagerUpdateRateController.cs │ ├── RateManagerUpdateRateController.cs.meta │ ├── RateManagerValueController.cs │ └── RateManagerValueController.cs.meta ├── Debug.meta ├── Debug │ ├── RateDebug.cs │ ├── RateDebug.cs.meta │ ├── RateLogLevel.cs │ ├── RateLogLevel.cs.meta │ ├── RateRequestTrackInfo.cs │ ├── RateRequestTrackInfo.cs.meta │ ├── RateRequestTracker.cs │ └── RateRequestTracker.cs.meta ├── RateManager.cs ├── RateManager.cs.meta ├── RatePreset.cs ├── RatePreset.cs.meta ├── Requests.meta ├── Requests │ ├── FixedUpdateRateRequest.cs │ ├── FixedUpdateRateRequest.cs.meta │ ├── RateRequest.cs │ ├── RateRequest.cs.meta │ ├── RateRequestType.cs │ ├── RateRequestType.cs.meta │ ├── RenderIntervalRequest.cs │ ├── RenderIntervalRequest.cs.meta │ ├── UpdateRateRequest.cs │ └── UpdateRateRequest.cs.meta ├── UniRate.asmdef ├── UniRate.asmdef.meta ├── UpdateRateMode.cs └── UpdateRateMode.cs.meta ├── TestsEditMode.meta ├── TestsEditMode ├── RateManagerValueController_TargetTests_EditMode.cs ├── RateManagerValueController_TargetTests_EditMode.cs.meta ├── UniRate.TestsEditMode.asmdef └── UniRate.TestsEditMode.asmdef.meta ├── TestsPlayMode.meta ├── TestsPlayMode ├── RateManager_CheckRuntimeUpdateRate_PlayMode.cs ├── RateManager_CheckRuntimeUpdateRate_PlayMode.cs.meta ├── UniRate.TestsPlayMode.asmdef └── UniRate.TestsPlayMode.asmdef.meta ├── UniRate_v3.0.1.unitypackage ├── UniRate_v3.0.1.unitypackage.meta ├── package.json └── package.json.meta /.gitignore: -------------------------------------------------------------------------------- 1 | 2 | # Created by https://www.gitignore.io/api/unity 3 | 4 | ### Unity ### 5 | /[Ll]ibrary/ 6 | /[Tt]emp/ 7 | /[Oo]bj/ 8 | /[Bb]uild/ 9 | /[Bb]uilds/ 10 | /Assets/AssetStoreTools* 11 | 12 | # Autogenerated VS/MD/Consulo solution and project files 13 | ExportedObj/ 14 | .consulo/ 15 | *.csproj 16 | *.unityproj 17 | *.sln 18 | *.suo 19 | *.tmp 20 | *.user 21 | *.userprefs 22 | *.pidb 23 | *.booproj 24 | *.svd 25 | *.pdb 26 | 27 | 28 | # Unity3D generated meta files 29 | *.pidb.meta 30 | 31 | # Unity3D Generated File On Crash Reports 32 | sysinfo.txt 33 | 34 | # Builds 35 | *.apk 36 | #*.unitypackage 37 | 38 | # End of https://www.gitignore.io/api/unity 39 | 40 | #Ignore VSCode.cs and its settings editor 41 | *VSCode.cs 42 | *.vscode 43 | *VSCode.cs.meta 44 | /omnisharp.json 45 | 46 | #Sytem OS 47 | .DS_Store 48 | *.DS_Store -------------------------------------------------------------------------------- /CHANGELOG.md: -------------------------------------------------------------------------------- 1 | # Changelog 2 | 3 | ## [3.0.1] - 2023-10-30 4 | ### Changed 5 | - Using new `UnityEngine.Device.Application` api. 6 | - Using new `UnityEngine.Device.Screen` api. 7 | - Changed `RateManager` default update rate mode to `ApplicationTargetFrameRate`, default minimum update rate to 20 and default maximum render interval to 10. 8 | - Changed rate request components default delay seconds to stop requests to 1. 9 | 10 | ## [3.0.0] - 2022-09-26 11 | ### Added 12 | - New editor tracker window to make it easy to debug requests lifecycle. It's accessible through `Window > UniRate Tracker`. 13 | ### Changed 14 | - Refactored rates/interval management to allow easy testability. 15 | - **Breaking:** `RateManager.Instance.UpdateRate` now returns the update rate controller instance instead of the current update rate per seconds value, which is now accessible through `RateManager.Instance.UpdateRate.Current`. 16 | - **Breaking:** `RateManager.Instance.FixedUpdateRate` now returns the fixed update rate controller instance instead of the current fixed update rate per seconds value, which is now accessible through `RateManager.Instance.FixedUpdateRate.Current`. 17 | - **Breaking:** `RateManager.Instance.RenderInterval` now returns the render interval controller instance instead of the current render interval value, which is now accessible through `RateManager.Instance.RenderInterval.Current`. 18 | ### Deprecated 19 | - `RateManager.Instance.UpdateRateMode` is now deprecated, use `RateManager.Instance.UpdateRate.Mode` instead. 20 | - `RateManager.Instance.MinimumUpdateRate` is now deprecated, use `RateManager.Instance.UpdateRate.Minimum` instead. 21 | - `RateManager.Instance.TargetUpdateRate` is now deprecated, use `RateManager.Instance.UpdateRate.Target` instead. 22 | - `RateManager.Instance.UpdateRateModeChanged` is now deprecated, use `RateManager.Instance.UpdateRate.ModeChanged` instead. 23 | - `RateManager.Instance.UpdateRateChanged` is now deprecated, use `RateManager.Instance.UpdateRate.CurrentChanged` instead. 24 | - `RateManager.Instance.MinimumFixedUpdateRate` is now deprecated, use `RateManager.Instance.FixedUpdateRate.Minimum` instead. 25 | - `RateManager.Instance.TargetFixedUpdateRate` is now deprecated, use `RateManager.Instance.FixedUpdateRate.Target` instead. 26 | - `RateManager.Instance.FixedUpdateRateChanged` is now deprecated, use `RateManager.Instance.FixedUpdateRate.CurrentChanged` instead. 27 | - `RateManager.Instance.TargetFixedUpdateRateChanged` is now deprecated, use `RateManager.Instance.FixedUpdateRate.TargetChanged` instead. 28 | - `RateManager.Instance.MaximumRenderInterval` is now deprecated, use `RateManager.Instance.RenderInterval.Maximum` instead. 29 | - `RateManager.Instance.TargetRenderInterval` is now deprecated, use `RateManager.Instance.RenderInterval.Target` instead. 30 | - `RateManager.Instance.RenderIntervalChanged` is now deprecated, use `RateManager.Instance.RenderInterval.CurrentChanged` instead. 31 | - `RateManager.Instance.TargetRenderIntervalChanged` is now deprecated, use `RateManager.Instance.RenderInterval.TargetChanged` instead. 32 | - `RateManager.Instance.RenderRate` is now deprecated, use `RateManager.Instance.RenderInterval.CurrentRenderRate` instead. 33 | - `RateManager.Instance.WillRender` is now deprecated, use `RateManager.Instance.RenderInterval.WillRender` instead. 34 | - `RateManager.Instance.IsRenderIntervalSupported` is now deprecated, use `RateManager.Instance.RenderInterval.IsSupported` instead. 35 | - `RateManager.Instance.RequestUpdateRate(int)` is now deprecated, use `RateManager.Instance.UpdateRate.Request(int)` instead. 36 | - `RateManager.Instance.RequestFixedUpdateRate(int)` is now deprecated, use `RateManager.Instance.FixedUpdateRate.Request(int)` instead. 37 | - `RateManager.Instance.RequestRenderInterval(int)` is now deprecated, use `RateManager.Instance.RenderInterval.Request(int)` instead. 38 | ### Fixed 39 | - Fixed `ArgumentNullException` when application is quitting ([#2](https://github.com/renanwolf/UniRate/issues/2)). 40 | 41 | ## [2.2.2] - 2021-07-28 42 | ### Fixed 43 | - Fixed compilation error on `RateManager` for Unity versions below 2019.3 ([#1](https://github.com/renanwolf/UniRate/pull/1)), by [@Chrisdbhr](https://github.com/Chrisdbhr). 44 | 45 | ## [2.2.1] - 2021-05-18 46 | ### Fixed 47 | - `RateRequestAnimatorComponent` was not evaluating correctly if `Animator` states are playing. 48 | 49 | ## [2.2.0] - 2021-01-20 50 | ### Added 51 | - `RateRequestAnimationComponent` to activate requests while an `Animation` component is playing. 52 | - `RateRequestAnimatorComponent` to activate requests while an `Animator` component is playing. 53 | ### Fixed 54 | - `DelaySecondsToStopRequests` on requests components was not calculating delay since 'should stop requests' time. 55 | - Wrong release years on changelog.md file. 56 | 57 | ## [2.1.2] - 2020-10-01 58 | ### Fixed 59 | - Changes to `RateDebug.ScreenDataBackgroundColor` sometimes had no effect when application was running on device. 60 | - Legacy code not being imported correctly by Unity because assembly definition file was missing. 61 | 62 | ## [2.1.1] - 2020-08-28 63 | ### Fixed 64 | - `package.json` wrong version. 65 | 66 | ## [2.1.0] - 2020-08-28 67 | ### Added 68 | - Customize background color, text color and font size on `RateDebug` screen data. 69 | - Enable/disable verbose screen data on `RateDebug`. 70 | - `RateManager.HasInstance` to check if the instance exists without creating it. 71 | ### Changed 72 | - Renamed `Debugger` to `RateDebug`. 73 | - Renamed `LogLevel` to `RateLogLevel`. 74 | - Increased `RateDebug.LogLevel` default value. 75 | 76 | [Unreleased]: https://github.com/renanwolf/UniRate/compare/v3.0.1...HEAD 77 | [3.0.1]: https://github.com/renanwolf/UniRate/releases/tag/v3.0.1 78 | [3.0.0]: https://github.com/renanwolf/UniRate/releases/tag/v3.0.0 79 | [2.2.2]: https://github.com/renanwolf/UniRate/releases/tag/v2.2.2 80 | [2.2.1]: https://github.com/renanwolf/UniRate/releases/tag/v2.2.1 81 | [2.2.0]: https://github.com/renanwolf/UniRate/releases/tag/v2.2.0 82 | [2.1.2]: https://github.com/renanwolf/UniRate/releases/tag/v2.1.2 83 | [2.1.1]: https://github.com/renanwolf/UniRate/releases/tag/v2.1.1 84 | [2.1.0]: https://github.com/renanwolf/UniRate/releases/tag/v2.1.0 -------------------------------------------------------------------------------- /CHANGELOG.md.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: db0fbb24e9a194e05ba186cc08b1f8cb 3 | TextScriptImporter: 4 | externalObjects: {} 5 | userData: 6 | assetBundleName: 7 | assetBundleVariant: 8 | -------------------------------------------------------------------------------- /Editor.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 6dc32018cf6054ba8b81fc71dd52b721 3 | folderAsset: yes 4 | DefaultImporter: 5 | externalObjects: {} 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Editor/RateManagerInspector.cs: -------------------------------------------------------------------------------- 1 | #if !UNITY_2019_3_OR_NEWER 2 | using UnityEditor; 3 | 4 | namespace UniRate.Editor { 5 | 6 | [CustomEditor(typeof(RateManager))] 7 | public class RateManagerInspector : UnityEditor.Editor { 8 | 9 | public override void OnInspectorGUI() { 10 | this.serializedObject.Update(); 11 | this.DrawDefaultInspector(); 12 | EditorGUILayout.HelpBox("render interval is only supported on Unity 2019.3 or newer", MessageType.Warning); 13 | } 14 | } 15 | } 16 | #endif -------------------------------------------------------------------------------- /Editor/RateManagerInspector.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 14df3ba12d69c4c10958575e45734ac1 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Editor/RateRequestAnimationComponentInspector.cs: -------------------------------------------------------------------------------- 1 | using UnityEditor; 2 | 3 | namespace UniRate.Editor { 4 | 5 | [CustomEditor(typeof(RateRequestAnimationComponent), true)] 6 | [CanEditMultipleObjects] 7 | public class RateRequestAnimationComponentInspector : RateRequestComponentInspector { 8 | 9 | #region <<---------- Properties and Fields ---------->> 10 | 11 | private SerializedProperty _propClipName; 12 | 13 | #endregion <<---------- Properties and Fields ---------->> 14 | 15 | 16 | 17 | 18 | #region <<---------- Editor ---------->> 19 | 20 | protected override void OnEnable() { 21 | base.OnEnable(); 22 | this._propClipName = this.serializedObject.FindProperty("_clipName"); 23 | } 24 | 25 | public override void OnInspectorGUI() { 26 | base.OnInspectorGUI(); 27 | 28 | EditorGUILayout.Space(); 29 | 30 | EditorGUI.BeginChangeCheck(); 31 | EditorGUILayout.PropertyField(this._propClipName); 32 | if (EditorGUI.EndChangeCheck()) { 33 | this.serializedObject.ApplyModifiedProperties(); 34 | } 35 | 36 | if (this._propClipName.hasMultipleDifferentValues) return; 37 | 38 | var clipName = this._propClipName.stringValue; 39 | if (string.IsNullOrEmpty(clipName)) { 40 | EditorGUILayout.HelpBox("requests will be active if any AnimationClip is playing", MessageType.Info); 41 | return; 42 | } 43 | EditorGUILayout.HelpBox($"requests will be active only if AnimationClip named '{clipName}' is playing", MessageType.Info); 44 | } 45 | 46 | #endregion <<---------- Editor ---------->> 47 | } 48 | } -------------------------------------------------------------------------------- /Editor/RateRequestAnimationComponentInspector.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: dee601861b68e406ab0de9a100afd664 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Editor/RateRequestAnimatorComponentInspector.cs: -------------------------------------------------------------------------------- 1 | using UnityEditor; 2 | 3 | namespace UniRate.Editor { 4 | 5 | [CustomEditor(typeof(RateRequestAnimatorComponent), true)] 6 | [CanEditMultipleObjects] 7 | public class RateRequestAnimatorComponentInspector : RateRequestComponentInspector { 8 | 9 | #region <<---------- Properties and Fields ---------->> 10 | 11 | private SerializedProperty _propActivateRequestsInTransitions; 12 | private SerializedProperty _propLayerName; 13 | private SerializedProperty _propStateName; 14 | 15 | #endregion <<---------- Properties and Fields ---------->> 16 | 17 | 18 | 19 | 20 | #region <<---------- Editor ---------->> 21 | 22 | protected override void OnEnable() { 23 | base.OnEnable(); 24 | this._propActivateRequestsInTransitions = this.serializedObject.FindProperty("_activateRequestsInTransitions"); 25 | this._propLayerName = this.serializedObject.FindProperty("_layerName"); 26 | this._propStateName = this.serializedObject.FindProperty("_stateName"); 27 | } 28 | 29 | public override void OnInspectorGUI() { 30 | base.OnInspectorGUI(); 31 | 32 | EditorGUILayout.Space(); 33 | 34 | EditorGUI.BeginChangeCheck(); 35 | EditorGUILayout.PropertyField(this._propActivateRequestsInTransitions); 36 | if (EditorGUI.EndChangeCheck()) { 37 | this.serializedObject.ApplyModifiedProperties(); 38 | } 39 | 40 | EditorGUI.BeginChangeCheck(); 41 | EditorGUILayout.PropertyField(this._propLayerName); 42 | if (EditorGUI.EndChangeCheck()) { 43 | this.serializedObject.ApplyModifiedProperties(); 44 | } 45 | 46 | EditorGUI.BeginChangeCheck(); 47 | EditorGUILayout.PropertyField(this._propStateName); 48 | if (EditorGUI.EndChangeCheck()) { 49 | this.serializedObject.ApplyModifiedProperties(); 50 | } 51 | 52 | var hasAnyMultipleDifferentValues = ( 53 | this._propActivateRequestsInTransitions.hasMultipleDifferentValues 54 | || this._propLayerName.hasMultipleDifferentValues 55 | || this._propStateName.hasMultipleDifferentValues 56 | ); 57 | if (hasAnyMultipleDifferentValues) return; 58 | 59 | var helpMessage = this.GenerateHelpMessage( 60 | this._propActivateRequestsInTransitions.boolValue, 61 | this._propLayerName.stringValue, 62 | this._propStateName.stringValue 63 | ); 64 | EditorGUILayout.HelpBox(helpMessage, MessageType.Info); 65 | } 66 | 67 | #endregion <<---------- Editor ---------->> 68 | 69 | 70 | 71 | 72 | #region <<---------- General ---------->> 73 | 74 | private string GenerateHelpMessage(bool activeRequestsInTransitions, string layerName, string stateName) { 75 | var hasLayer = !string.IsNullOrEmpty(layerName); 76 | var hasState = !string.IsNullOrEmpty(stateName); 77 | 78 | var helpMessage = "requests will be active if"; 79 | 80 | if (activeRequestsInTransitions) { 81 | helpMessage += " any transition is ocurring on"; 82 | if (hasLayer) helpMessage += $" layer '{layerName}'"; 83 | else helpMessage += " any layer"; 84 | helpMessage += "\nor"; 85 | } 86 | 87 | if (hasState) helpMessage += $" state '{stateName}'"; 88 | else helpMessage += " any state"; 89 | 90 | helpMessage += " is playing on"; 91 | 92 | if (hasLayer) helpMessage += $" layer '{layerName}'"; 93 | else helpMessage += " any layer"; 94 | 95 | return helpMessage; 96 | } 97 | 98 | #endregion <<---------- General ---------->> 99 | } 100 | } -------------------------------------------------------------------------------- /Editor/RateRequestAnimatorComponentInspector.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: f3d9189d2a35b4bb19bcd6b9e4e90e79 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Editor/RateRequestComponentInspector.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: cd7da6577fb9741f98a1dd15d80422bb 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Editor/RateRequestTrackerTreeView.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 9e662b68ce41545eab4c0d415ca7b9c7 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Editor/RateRequestTrackerWindow.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 03e7e2a80e51044b9b727aad8aba66dc 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Editor/UniRate.Editor.asmdef: -------------------------------------------------------------------------------- 1 | { 2 | "name": "UniRate.Editor", 3 | "references": [ 4 | "UniRate" 5 | ], 6 | "optionalUnityReferences": [], 7 | "includePlatforms": [ 8 | "Editor" 9 | ], 10 | "excludePlatforms": [], 11 | "allowUnsafeCode": false, 12 | "overrideReferences": false, 13 | "precompiledReferences": [], 14 | "autoReferenced": true, 15 | "defineConstraints": [] 16 | } -------------------------------------------------------------------------------- /Editor/UniRate.Editor.asmdef.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 53e219f30f3b241e88483740d7d5b777 3 | AssemblyDefinitionImporter: 4 | externalObjects: {} 5 | userData: 6 | assetBundleName: 7 | assetBundleVariant: 8 | -------------------------------------------------------------------------------- /Examples.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: ddce18636d06d476a8750f895b24fc89 3 | folderAsset: yes 4 | timeCreated: 1535309564 5 | licenseType: Pro 6 | DefaultImporter: 7 | externalObjects: {} 8 | userData: 9 | assetBundleName: 10 | assetBundleVariant: 11 | -------------------------------------------------------------------------------- /Examples/AnimClipLoop_H_Three.anim: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | %TAG !u! tag:unity3d.com,2011: 3 | --- !u!74 &7400000 4 | AnimationClip: 5 | m_ObjectHideFlags: 0 6 | m_CorrespondingSourceObject: {fileID: 0} 7 | m_PrefabInstance: {fileID: 0} 8 | m_PrefabAsset: {fileID: 0} 9 | m_Name: AnimClipLoop_H_Three 10 | serializedVersion: 6 11 | m_Legacy: 1 12 | m_Compressed: 0 13 | m_UseHighQualityCurve: 1 14 | m_RotationCurves: [] 15 | m_CompressedRotationCurves: [] 16 | m_EulerCurves: [] 17 | m_PositionCurves: [] 18 | m_ScaleCurves: 19 | - curve: 20 | serializedVersion: 2 21 | m_Curve: 22 | - serializedVersion: 3 23 | time: 0 24 | value: {x: 1, y: 1, z: 1} 25 | inSlope: {x: 0, y: 0, z: 0} 26 | outSlope: {x: 0, y: 0, z: 0} 27 | tangentMode: 0 28 | weightedMode: 0 29 | inWeight: {x: 0.33333334, y: 0.33333334, z: 0.33333334} 30 | outWeight: {x: 0.33333334, y: 0.33333334, z: 0.33333334} 31 | - serializedVersion: 3 32 | time: 0.33333334 33 | value: {x: 1.3, y: 1, z: 1} 34 | inSlope: {x: 0, y: 0, z: 0} 35 | outSlope: {x: 0, y: 0, z: 0} 36 | tangentMode: 0 37 | weightedMode: 0 38 | inWeight: {x: 0.33333334, y: 0.33333334, z: 0.33333334} 39 | outWeight: {x: 0.33333334, y: 0.33333334, z: 0.33333334} 40 | - serializedVersion: 3 41 | time: 0.6666667 42 | value: {x: 1, y: 1, z: 1} 43 | inSlope: {x: 0, y: 0, z: 0} 44 | outSlope: {x: 0, y: 0, z: 0} 45 | tangentMode: 0 46 | weightedMode: 0 47 | inWeight: {x: 0.33333334, y: 0.33333334, z: 0.33333334} 48 | outWeight: {x: 0.33333334, y: 0.33333334, z: 0.33333334} 49 | m_PreInfinity: 2 50 | m_PostInfinity: 2 51 | m_RotationOrder: 4 52 | path: 53 | m_FloatCurves: [] 54 | m_PPtrCurves: [] 55 | m_SampleRate: 60 56 | m_WrapMode: 2 57 | m_Bounds: 58 | m_Center: {x: 0, y: 0, z: 0} 59 | m_Extent: {x: 0, y: 0, z: 0} 60 | m_ClipBindingConstant: 61 | genericBindings: [] 62 | pptrCurveMapping: [] 63 | m_AnimationClipSettings: 64 | serializedVersion: 2 65 | m_AdditiveReferencePoseClip: {fileID: 0} 66 | m_AdditiveReferencePoseTime: 0 67 | m_StartTime: 0 68 | m_StopTime: 0.6666667 69 | m_OrientationOffsetY: 0 70 | m_Level: 0 71 | m_CycleOffset: 0 72 | m_HasAdditiveReferencePose: 0 73 | m_LoopTime: 1 74 | m_LoopBlend: 0 75 | m_LoopBlendOrientation: 0 76 | m_LoopBlendPositionY: 0 77 | m_LoopBlendPositionXZ: 0 78 | m_KeepOriginalOrientation: 0 79 | m_KeepOriginalPositionY: 1 80 | m_KeepOriginalPositionXZ: 0 81 | m_HeightFromFeet: 0 82 | m_Mirror: 0 83 | m_EditorCurves: 84 | - curve: 85 | serializedVersion: 2 86 | m_Curve: 87 | - serializedVersion: 3 88 | time: 0 89 | value: 1 90 | inSlope: 0 91 | outSlope: 0 92 | tangentMode: 136 93 | weightedMode: 0 94 | inWeight: 0.33333334 95 | outWeight: 0.33333334 96 | - serializedVersion: 3 97 | time: 0.33333334 98 | value: 1.3 99 | inSlope: 0 100 | outSlope: 0 101 | tangentMode: 136 102 | weightedMode: 0 103 | inWeight: 0.33333334 104 | outWeight: 0.33333334 105 | - serializedVersion: 3 106 | time: 0.6666667 107 | value: 1 108 | inSlope: 0 109 | outSlope: 0 110 | tangentMode: 136 111 | weightedMode: 0 112 | inWeight: 0.33333334 113 | outWeight: 0.33333334 114 | m_PreInfinity: 2 115 | m_PostInfinity: 2 116 | m_RotationOrder: 4 117 | attribute: m_LocalScale.x 118 | path: 119 | classID: 224 120 | script: {fileID: 0} 121 | - curve: 122 | serializedVersion: 2 123 | m_Curve: 124 | - serializedVersion: 3 125 | time: 0 126 | value: 1 127 | inSlope: 0 128 | outSlope: 0 129 | tangentMode: 136 130 | weightedMode: 0 131 | inWeight: 0.33333334 132 | outWeight: 0.33333334 133 | - serializedVersion: 3 134 | time: 0.33333334 135 | value: 1 136 | inSlope: 0 137 | outSlope: 0 138 | tangentMode: 136 139 | weightedMode: 0 140 | inWeight: 0.33333334 141 | outWeight: 0.33333334 142 | - serializedVersion: 3 143 | time: 0.6666667 144 | value: 1 145 | inSlope: 0 146 | outSlope: 0 147 | tangentMode: 136 148 | weightedMode: 0 149 | inWeight: 0.33333334 150 | outWeight: 0.33333334 151 | m_PreInfinity: 2 152 | m_PostInfinity: 2 153 | m_RotationOrder: 4 154 | attribute: m_LocalScale.y 155 | path: 156 | classID: 224 157 | script: {fileID: 0} 158 | - curve: 159 | serializedVersion: 2 160 | m_Curve: 161 | - serializedVersion: 3 162 | time: 0 163 | value: 1 164 | inSlope: 0 165 | outSlope: 0 166 | tangentMode: 136 167 | weightedMode: 0 168 | inWeight: 0.33333334 169 | outWeight: 0.33333334 170 | - serializedVersion: 3 171 | time: 0.33333334 172 | value: 1 173 | inSlope: 0 174 | outSlope: 0 175 | tangentMode: 136 176 | weightedMode: 0 177 | inWeight: 0.33333334 178 | outWeight: 0.33333334 179 | - serializedVersion: 3 180 | time: 0.6666667 181 | value: 1 182 | inSlope: 0 183 | outSlope: 0 184 | tangentMode: 136 185 | weightedMode: 0 186 | inWeight: 0.33333334 187 | outWeight: 0.33333334 188 | m_PreInfinity: 2 189 | m_PostInfinity: 2 190 | m_RotationOrder: 4 191 | attribute: m_LocalScale.z 192 | path: 193 | classID: 224 194 | script: {fileID: 0} 195 | m_EulerEditorCurves: [] 196 | m_HasGenericRootTransform: 0 197 | m_HasMotionFloatCurves: 0 198 | m_Events: [] 199 | -------------------------------------------------------------------------------- /Examples/AnimClipLoop_H_Three.anim.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: af56f33aadc9e46e7865ec6a3adf3ec9 3 | NativeFormatImporter: 4 | externalObjects: {} 5 | mainObjectFileID: 0 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Examples/AnimClipLoop_V_Three.anim: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | %TAG !u! tag:unity3d.com,2011: 3 | --- !u!74 &7400000 4 | AnimationClip: 5 | m_ObjectHideFlags: 0 6 | m_CorrespondingSourceObject: {fileID: 0} 7 | m_PrefabInstance: {fileID: 0} 8 | m_PrefabAsset: {fileID: 0} 9 | m_Name: AnimClipLoop_V_Three 10 | serializedVersion: 6 11 | m_Legacy: 1 12 | m_Compressed: 0 13 | m_UseHighQualityCurve: 1 14 | m_RotationCurves: [] 15 | m_CompressedRotationCurves: [] 16 | m_EulerCurves: [] 17 | m_PositionCurves: [] 18 | m_ScaleCurves: 19 | - curve: 20 | serializedVersion: 2 21 | m_Curve: 22 | - serializedVersion: 3 23 | time: 0 24 | value: {x: 1, y: 1, z: 1} 25 | inSlope: {x: 0, y: 0, z: 0} 26 | outSlope: {x: 0, y: 0, z: 0} 27 | tangentMode: 0 28 | weightedMode: 0 29 | inWeight: {x: 0.33333334, y: 0.33333334, z: 0.33333334} 30 | outWeight: {x: 0.33333334, y: 0.33333334, z: 0.33333334} 31 | - serializedVersion: 3 32 | time: 0.33333334 33 | value: {x: 1, y: 1.3, z: 1} 34 | inSlope: {x: 0, y: 0, z: 0} 35 | outSlope: {x: 0, y: 0, z: 0} 36 | tangentMode: 0 37 | weightedMode: 0 38 | inWeight: {x: 0.33333334, y: 0.33333334, z: 0.33333334} 39 | outWeight: {x: 0.33333334, y: 0.33333334, z: 0.33333334} 40 | - serializedVersion: 3 41 | time: 0.6666667 42 | value: {x: 1, y: 1, z: 1} 43 | inSlope: {x: 0, y: 0, z: 0} 44 | outSlope: {x: 0, y: 0, z: 0} 45 | tangentMode: 0 46 | weightedMode: 0 47 | inWeight: {x: 0.33333334, y: 0.33333334, z: 0.33333334} 48 | outWeight: {x: 0.33333334, y: 0.33333334, z: 0.33333334} 49 | m_PreInfinity: 2 50 | m_PostInfinity: 2 51 | m_RotationOrder: 4 52 | path: 53 | m_FloatCurves: [] 54 | m_PPtrCurves: [] 55 | m_SampleRate: 60 56 | m_WrapMode: 2 57 | m_Bounds: 58 | m_Center: {x: 0, y: 0, z: 0} 59 | m_Extent: {x: 0, y: 0, z: 0} 60 | m_ClipBindingConstant: 61 | genericBindings: [] 62 | pptrCurveMapping: [] 63 | m_AnimationClipSettings: 64 | serializedVersion: 2 65 | m_AdditiveReferencePoseClip: {fileID: 0} 66 | m_AdditiveReferencePoseTime: 0 67 | m_StartTime: 0 68 | m_StopTime: 0.6666667 69 | m_OrientationOffsetY: 0 70 | m_Level: 0 71 | m_CycleOffset: 0 72 | m_HasAdditiveReferencePose: 0 73 | m_LoopTime: 1 74 | m_LoopBlend: 0 75 | m_LoopBlendOrientation: 0 76 | m_LoopBlendPositionY: 0 77 | m_LoopBlendPositionXZ: 0 78 | m_KeepOriginalOrientation: 0 79 | m_KeepOriginalPositionY: 1 80 | m_KeepOriginalPositionXZ: 0 81 | m_HeightFromFeet: 0 82 | m_Mirror: 0 83 | m_EditorCurves: 84 | - curve: 85 | serializedVersion: 2 86 | m_Curve: 87 | - serializedVersion: 3 88 | time: 0 89 | value: 1 90 | inSlope: 0 91 | outSlope: 0 92 | tangentMode: 136 93 | weightedMode: 0 94 | inWeight: 0.33333334 95 | outWeight: 0.33333334 96 | - serializedVersion: 3 97 | time: 0.33333334 98 | value: 1 99 | inSlope: 0 100 | outSlope: 0 101 | tangentMode: 136 102 | weightedMode: 0 103 | inWeight: 0.33333334 104 | outWeight: 0.33333334 105 | - serializedVersion: 3 106 | time: 0.6666667 107 | value: 1 108 | inSlope: 0 109 | outSlope: 0 110 | tangentMode: 136 111 | weightedMode: 0 112 | inWeight: 0.33333334 113 | outWeight: 0.33333334 114 | m_PreInfinity: 2 115 | m_PostInfinity: 2 116 | m_RotationOrder: 4 117 | attribute: m_LocalScale.x 118 | path: 119 | classID: 224 120 | script: {fileID: 0} 121 | - curve: 122 | serializedVersion: 2 123 | m_Curve: 124 | - serializedVersion: 3 125 | time: 0 126 | value: 1 127 | inSlope: 0 128 | outSlope: 0 129 | tangentMode: 136 130 | weightedMode: 0 131 | inWeight: 0.33333334 132 | outWeight: 0.33333334 133 | - serializedVersion: 3 134 | time: 0.33333334 135 | value: 1.3 136 | inSlope: 0 137 | outSlope: 0 138 | tangentMode: 136 139 | weightedMode: 0 140 | inWeight: 0.33333334 141 | outWeight: 0.33333334 142 | - serializedVersion: 3 143 | time: 0.6666667 144 | value: 1 145 | inSlope: 0 146 | outSlope: 0 147 | tangentMode: 136 148 | weightedMode: 0 149 | inWeight: 0.33333334 150 | outWeight: 0.33333334 151 | m_PreInfinity: 2 152 | m_PostInfinity: 2 153 | m_RotationOrder: 4 154 | attribute: m_LocalScale.y 155 | path: 156 | classID: 224 157 | script: {fileID: 0} 158 | - curve: 159 | serializedVersion: 2 160 | m_Curve: 161 | - serializedVersion: 3 162 | time: 0 163 | value: 1 164 | inSlope: 0 165 | outSlope: 0 166 | tangentMode: 136 167 | weightedMode: 0 168 | inWeight: 0.33333334 169 | outWeight: 0.33333334 170 | - serializedVersion: 3 171 | time: 0.33333334 172 | value: 1 173 | inSlope: 0 174 | outSlope: 0 175 | tangentMode: 136 176 | weightedMode: 0 177 | inWeight: 0.33333334 178 | outWeight: 0.33333334 179 | - serializedVersion: 3 180 | time: 0.6666667 181 | value: 1 182 | inSlope: 0 183 | outSlope: 0 184 | tangentMode: 136 185 | weightedMode: 0 186 | inWeight: 0.33333334 187 | outWeight: 0.33333334 188 | m_PreInfinity: 2 189 | m_PostInfinity: 2 190 | m_RotationOrder: 4 191 | attribute: m_LocalScale.z 192 | path: 193 | classID: 224 194 | script: {fileID: 0} 195 | m_EulerEditorCurves: [] 196 | m_HasGenericRootTransform: 0 197 | m_HasMotionFloatCurves: 0 198 | m_Events: [] 199 | -------------------------------------------------------------------------------- /Examples/AnimClipLoop_V_Three.anim.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: f219b1cf267464774b03b96b884833ae 3 | NativeFormatImporter: 4 | externalObjects: {} 5 | mainObjectFileID: 0 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Examples/AnimClip_State_1_Three.anim: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | %TAG !u! tag:unity3d.com,2011: 3 | --- !u!74 &7400000 4 | AnimationClip: 5 | m_ObjectHideFlags: 0 6 | m_CorrespondingSourceObject: {fileID: 0} 7 | m_PrefabInstance: {fileID: 0} 8 | m_PrefabAsset: {fileID: 0} 9 | m_Name: AnimClip_State_1_Three 10 | serializedVersion: 6 11 | m_Legacy: 0 12 | m_Compressed: 0 13 | m_UseHighQualityCurve: 1 14 | m_RotationCurves: [] 15 | m_CompressedRotationCurves: [] 16 | m_EulerCurves: [] 17 | m_PositionCurves: [] 18 | m_ScaleCurves: 19 | - curve: 20 | serializedVersion: 2 21 | m_Curve: 22 | - serializedVersion: 3 23 | time: 0 24 | value: {x: 1, y: 1, z: 1} 25 | inSlope: {x: 0, y: 0, z: 0} 26 | outSlope: {x: 0, y: 0, z: 0} 27 | tangentMode: 0 28 | weightedMode: 0 29 | inWeight: {x: 0.33333334, y: 0.33333334, z: 0.33333334} 30 | outWeight: {x: 0.33333334, y: 0.33333334, z: 0.33333334} 31 | - serializedVersion: 3 32 | time: 0.5 33 | value: {x: 1.3, y: 1, z: 1} 34 | inSlope: {x: 0, y: 0, z: 0} 35 | outSlope: {x: 0, y: 0, z: 0} 36 | tangentMode: 0 37 | weightedMode: 0 38 | inWeight: {x: 0.33333334, y: 0.33333334, z: 0.33333334} 39 | outWeight: {x: 0.33333334, y: 0.33333334, z: 0.33333334} 40 | - serializedVersion: 3 41 | time: 1 42 | value: {x: 1, y: 1, z: 1} 43 | inSlope: {x: 0, y: 0, z: 0} 44 | outSlope: {x: 0, y: 0, z: 0} 45 | tangentMode: 0 46 | weightedMode: 0 47 | inWeight: {x: 0.33333334, y: 0.33333334, z: 0.33333334} 48 | outWeight: {x: 0.33333334, y: 0.33333334, z: 0.33333334} 49 | m_PreInfinity: 2 50 | m_PostInfinity: 2 51 | m_RotationOrder: 4 52 | path: 53 | m_FloatCurves: [] 54 | m_PPtrCurves: [] 55 | m_SampleRate: 60 56 | m_WrapMode: 0 57 | m_Bounds: 58 | m_Center: {x: 0, y: 0, z: 0} 59 | m_Extent: {x: 0, y: 0, z: 0} 60 | m_ClipBindingConstant: 61 | genericBindings: 62 | - serializedVersion: 2 63 | path: 0 64 | attribute: 3 65 | script: {fileID: 0} 66 | typeID: 4 67 | customType: 0 68 | isPPtrCurve: 0 69 | pptrCurveMapping: [] 70 | m_AnimationClipSettings: 71 | serializedVersion: 2 72 | m_AdditiveReferencePoseClip: {fileID: 0} 73 | m_AdditiveReferencePoseTime: 0 74 | m_StartTime: 0 75 | m_StopTime: 1 76 | m_OrientationOffsetY: 0 77 | m_Level: 0 78 | m_CycleOffset: 0 79 | m_HasAdditiveReferencePose: 0 80 | m_LoopTime: 0 81 | m_LoopBlend: 0 82 | m_LoopBlendOrientation: 0 83 | m_LoopBlendPositionY: 0 84 | m_LoopBlendPositionXZ: 0 85 | m_KeepOriginalOrientation: 0 86 | m_KeepOriginalPositionY: 1 87 | m_KeepOriginalPositionXZ: 0 88 | m_HeightFromFeet: 0 89 | m_Mirror: 0 90 | m_EditorCurves: 91 | - curve: 92 | serializedVersion: 2 93 | m_Curve: 94 | - serializedVersion: 3 95 | time: 0 96 | value: 1 97 | inSlope: 0 98 | outSlope: 0 99 | tangentMode: 136 100 | weightedMode: 0 101 | inWeight: 0.33333334 102 | outWeight: 0.33333334 103 | - serializedVersion: 3 104 | time: 0.5 105 | value: 1.3 106 | inSlope: 0 107 | outSlope: 0 108 | tangentMode: 136 109 | weightedMode: 0 110 | inWeight: 0.33333334 111 | outWeight: 0.33333334 112 | - serializedVersion: 3 113 | time: 1 114 | value: 1 115 | inSlope: 0 116 | outSlope: 0 117 | tangentMode: 136 118 | weightedMode: 0 119 | inWeight: 0.33333334 120 | outWeight: 0.33333334 121 | m_PreInfinity: 2 122 | m_PostInfinity: 2 123 | m_RotationOrder: 4 124 | attribute: m_LocalScale.x 125 | path: 126 | classID: 224 127 | script: {fileID: 0} 128 | - curve: 129 | serializedVersion: 2 130 | m_Curve: 131 | - serializedVersion: 3 132 | time: 0 133 | value: 1 134 | inSlope: 0 135 | outSlope: 0 136 | tangentMode: 136 137 | weightedMode: 0 138 | inWeight: 0.33333334 139 | outWeight: 0.33333334 140 | - serializedVersion: 3 141 | time: 0.5 142 | value: 1 143 | inSlope: 0 144 | outSlope: 0 145 | tangentMode: 136 146 | weightedMode: 0 147 | inWeight: 0.33333334 148 | outWeight: 0.33333334 149 | - serializedVersion: 3 150 | time: 1 151 | value: 1 152 | inSlope: 0 153 | outSlope: 0 154 | tangentMode: 136 155 | weightedMode: 0 156 | inWeight: 0.33333334 157 | outWeight: 0.33333334 158 | m_PreInfinity: 2 159 | m_PostInfinity: 2 160 | m_RotationOrder: 4 161 | attribute: m_LocalScale.y 162 | path: 163 | classID: 224 164 | script: {fileID: 0} 165 | - curve: 166 | serializedVersion: 2 167 | m_Curve: 168 | - serializedVersion: 3 169 | time: 0 170 | value: 1 171 | inSlope: 0 172 | outSlope: 0 173 | tangentMode: 136 174 | weightedMode: 0 175 | inWeight: 0.33333334 176 | outWeight: 0.33333334 177 | - serializedVersion: 3 178 | time: 0.5 179 | value: 1 180 | inSlope: 0 181 | outSlope: 0 182 | tangentMode: 136 183 | weightedMode: 0 184 | inWeight: 0.33333334 185 | outWeight: 0.33333334 186 | - serializedVersion: 3 187 | time: 1 188 | value: 1 189 | inSlope: 0 190 | outSlope: 0 191 | tangentMode: 136 192 | weightedMode: 0 193 | inWeight: 0.33333334 194 | outWeight: 0.33333334 195 | m_PreInfinity: 2 196 | m_PostInfinity: 2 197 | m_RotationOrder: 4 198 | attribute: m_LocalScale.z 199 | path: 200 | classID: 224 201 | script: {fileID: 0} 202 | m_EulerEditorCurves: [] 203 | m_HasGenericRootTransform: 0 204 | m_HasMotionFloatCurves: 0 205 | m_Events: [] 206 | -------------------------------------------------------------------------------- /Examples/AnimClip_State_1_Three.anim.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 5b326cb030d2e4af8afc1fe47055bfb0 3 | NativeFormatImporter: 4 | externalObjects: {} 5 | mainObjectFileID: 0 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Examples/AnimClip_State_2_Three.anim: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | %TAG !u! tag:unity3d.com,2011: 3 | --- !u!74 &7400000 4 | AnimationClip: 5 | m_ObjectHideFlags: 0 6 | m_CorrespondingSourceObject: {fileID: 0} 7 | m_PrefabInstance: {fileID: 0} 8 | m_PrefabAsset: {fileID: 0} 9 | m_Name: AnimClip_State_2_Three 10 | serializedVersion: 6 11 | m_Legacy: 0 12 | m_Compressed: 0 13 | m_UseHighQualityCurve: 1 14 | m_RotationCurves: [] 15 | m_CompressedRotationCurves: [] 16 | m_EulerCurves: [] 17 | m_PositionCurves: [] 18 | m_ScaleCurves: 19 | - curve: 20 | serializedVersion: 2 21 | m_Curve: 22 | - serializedVersion: 3 23 | time: 0 24 | value: {x: 1, y: 1, z: 1} 25 | inSlope: {x: 0, y: 0, z: 0} 26 | outSlope: {x: 0, y: 0, z: 0} 27 | tangentMode: 0 28 | weightedMode: 0 29 | inWeight: {x: 0.33333334, y: 0.33333334, z: 0.33333334} 30 | outWeight: {x: 0.33333334, y: 0.33333334, z: 0.33333334} 31 | - serializedVersion: 3 32 | time: 0.5 33 | value: {x: 1, y: 1.3, z: 1} 34 | inSlope: {x: 0, y: 0, z: 0} 35 | outSlope: {x: 0, y: 0, z: 0} 36 | tangentMode: 0 37 | weightedMode: 0 38 | inWeight: {x: 0.33333334, y: 0.33333334, z: 0.33333334} 39 | outWeight: {x: 0.33333334, y: 0.33333334, z: 0.33333334} 40 | - serializedVersion: 3 41 | time: 1 42 | value: {x: 1, y: 1, z: 1} 43 | inSlope: {x: 0, y: 0, z: 0} 44 | outSlope: {x: 0, y: 0, z: 0} 45 | tangentMode: 0 46 | weightedMode: 0 47 | inWeight: {x: 0.33333334, y: 0.33333334, z: 0.33333334} 48 | outWeight: {x: 0.33333334, y: 0.33333334, z: 0.33333334} 49 | m_PreInfinity: 2 50 | m_PostInfinity: 2 51 | m_RotationOrder: 4 52 | path: 53 | m_FloatCurves: [] 54 | m_PPtrCurves: [] 55 | m_SampleRate: 60 56 | m_WrapMode: 0 57 | m_Bounds: 58 | m_Center: {x: 0, y: 0, z: 0} 59 | m_Extent: {x: 0, y: 0, z: 0} 60 | m_ClipBindingConstant: 61 | genericBindings: 62 | - serializedVersion: 2 63 | path: 0 64 | attribute: 3 65 | script: {fileID: 0} 66 | typeID: 4 67 | customType: 0 68 | isPPtrCurve: 0 69 | pptrCurveMapping: [] 70 | m_AnimationClipSettings: 71 | serializedVersion: 2 72 | m_AdditiveReferencePoseClip: {fileID: 0} 73 | m_AdditiveReferencePoseTime: 0 74 | m_StartTime: 0 75 | m_StopTime: 1 76 | m_OrientationOffsetY: 0 77 | m_Level: 0 78 | m_CycleOffset: 0 79 | m_HasAdditiveReferencePose: 0 80 | m_LoopTime: 0 81 | m_LoopBlend: 0 82 | m_LoopBlendOrientation: 0 83 | m_LoopBlendPositionY: 0 84 | m_LoopBlendPositionXZ: 0 85 | m_KeepOriginalOrientation: 0 86 | m_KeepOriginalPositionY: 1 87 | m_KeepOriginalPositionXZ: 0 88 | m_HeightFromFeet: 0 89 | m_Mirror: 0 90 | m_EditorCurves: 91 | - curve: 92 | serializedVersion: 2 93 | m_Curve: 94 | - serializedVersion: 3 95 | time: 0 96 | value: 1 97 | inSlope: 0 98 | outSlope: 0 99 | tangentMode: 136 100 | weightedMode: 0 101 | inWeight: 0.33333334 102 | outWeight: 0.33333334 103 | - serializedVersion: 3 104 | time: 0.5 105 | value: 1 106 | inSlope: 0 107 | outSlope: 0 108 | tangentMode: 136 109 | weightedMode: 0 110 | inWeight: 0.33333334 111 | outWeight: 0.33333334 112 | - serializedVersion: 3 113 | time: 1 114 | value: 1 115 | inSlope: 0 116 | outSlope: 0 117 | tangentMode: 136 118 | weightedMode: 0 119 | inWeight: 0.33333334 120 | outWeight: 0.33333334 121 | m_PreInfinity: 2 122 | m_PostInfinity: 2 123 | m_RotationOrder: 4 124 | attribute: m_LocalScale.x 125 | path: 126 | classID: 224 127 | script: {fileID: 0} 128 | - curve: 129 | serializedVersion: 2 130 | m_Curve: 131 | - serializedVersion: 3 132 | time: 0 133 | value: 1 134 | inSlope: 0 135 | outSlope: 0 136 | tangentMode: 136 137 | weightedMode: 0 138 | inWeight: 0.33333334 139 | outWeight: 0.33333334 140 | - serializedVersion: 3 141 | time: 0.5 142 | value: 1.3 143 | inSlope: 0 144 | outSlope: 0 145 | tangentMode: 136 146 | weightedMode: 0 147 | inWeight: 0.33333334 148 | outWeight: 0.33333334 149 | - serializedVersion: 3 150 | time: 1 151 | value: 1 152 | inSlope: 0 153 | outSlope: 0 154 | tangentMode: 136 155 | weightedMode: 0 156 | inWeight: 0.33333334 157 | outWeight: 0.33333334 158 | m_PreInfinity: 2 159 | m_PostInfinity: 2 160 | m_RotationOrder: 4 161 | attribute: m_LocalScale.y 162 | path: 163 | classID: 224 164 | script: {fileID: 0} 165 | - curve: 166 | serializedVersion: 2 167 | m_Curve: 168 | - serializedVersion: 3 169 | time: 0 170 | value: 1 171 | inSlope: 0 172 | outSlope: 0 173 | tangentMode: 136 174 | weightedMode: 0 175 | inWeight: 0.33333334 176 | outWeight: 0.33333334 177 | - serializedVersion: 3 178 | time: 0.5 179 | value: 1 180 | inSlope: 0 181 | outSlope: 0 182 | tangentMode: 136 183 | weightedMode: 0 184 | inWeight: 0.33333334 185 | outWeight: 0.33333334 186 | - serializedVersion: 3 187 | time: 1 188 | value: 1 189 | inSlope: 0 190 | outSlope: 0 191 | tangentMode: 136 192 | weightedMode: 0 193 | inWeight: 0.33333334 194 | outWeight: 0.33333334 195 | m_PreInfinity: 2 196 | m_PostInfinity: 2 197 | m_RotationOrder: 4 198 | attribute: m_LocalScale.z 199 | path: 200 | classID: 224 201 | script: {fileID: 0} 202 | m_EulerEditorCurves: [] 203 | m_HasGenericRootTransform: 0 204 | m_HasMotionFloatCurves: 0 205 | m_Events: [] 206 | -------------------------------------------------------------------------------- /Examples/AnimClip_State_2_Three.anim.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: e2c47f0e8c12549ba951e91711eda0c5 3 | NativeFormatImporter: 4 | externalObjects: {} 5 | mainObjectFileID: 0 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Examples/AnimController_Three.controller: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | %TAG !u! tag:unity3d.com,2011: 3 | --- !u!1102 &-8157273741378959870 4 | AnimatorState: 5 | serializedVersion: 5 6 | m_ObjectHideFlags: 1 7 | m_CorrespondingSourceObject: {fileID: 0} 8 | m_PrefabInstance: {fileID: 0} 9 | m_PrefabAsset: {fileID: 0} 10 | m_Name: State2 11 | m_Speed: 1 12 | m_CycleOffset: 0 13 | m_Transitions: 14 | - {fileID: -1191753622588735709} 15 | m_StateMachineBehaviours: [] 16 | m_Position: {x: 50, y: 50, z: 0} 17 | m_IKOnFeet: 0 18 | m_WriteDefaultValues: 1 19 | m_Mirror: 0 20 | m_SpeedParameterActive: 0 21 | m_MirrorParameterActive: 0 22 | m_CycleOffsetParameterActive: 0 23 | m_TimeParameterActive: 0 24 | m_Motion: {fileID: 7400000, guid: e2c47f0e8c12549ba951e91711eda0c5, type: 2} 25 | m_Tag: 26 | m_SpeedParameter: 27 | m_MirrorParameter: 28 | m_CycleOffsetParameter: 29 | m_TimeParameter: 30 | --- !u!1107 &-7295123783391113353 31 | AnimatorStateMachine: 32 | serializedVersion: 5 33 | m_ObjectHideFlags: 1 34 | m_CorrespondingSourceObject: {fileID: 0} 35 | m_PrefabInstance: {fileID: 0} 36 | m_PrefabAsset: {fileID: 0} 37 | m_Name: Base Layer 38 | m_ChildStates: 39 | - serializedVersion: 1 40 | m_State: {fileID: 3185103783705212087} 41 | m_Position: {x: -10, y: 100, z: 0} 42 | - serializedVersion: 1 43 | m_State: {fileID: -8157273741378959870} 44 | m_Position: {x: 280, y: 100, z: 0} 45 | m_ChildStateMachines: [] 46 | m_AnyStateTransitions: [] 47 | m_EntryTransitions: [] 48 | m_StateMachineTransitions: {} 49 | m_StateMachineBehaviours: [] 50 | m_AnyStatePosition: {x: 310, y: -30, z: 0} 51 | m_EntryPosition: {x: 20, y: -40, z: 0} 52 | m_ExitPosition: {x: 400, y: 260, z: 0} 53 | m_ParentStateMachinePosition: {x: 800, y: 20, z: 0} 54 | m_DefaultState: {fileID: 3185103783705212087} 55 | --- !u!1101 &-1191753622588735709 56 | AnimatorStateTransition: 57 | m_ObjectHideFlags: 1 58 | m_CorrespondingSourceObject: {fileID: 0} 59 | m_PrefabInstance: {fileID: 0} 60 | m_PrefabAsset: {fileID: 0} 61 | m_Name: 62 | m_Conditions: [] 63 | m_DstStateMachine: {fileID: 0} 64 | m_DstState: {fileID: 3185103783705212087} 65 | m_Solo: 0 66 | m_Mute: 0 67 | m_IsExit: 0 68 | serializedVersion: 3 69 | m_TransitionDuration: 0.36697698 70 | m_TransitionOffset: 0.0035139357 71 | m_ExitTime: 0.6285144 72 | m_HasExitTime: 1 73 | m_HasFixedDuration: 1 74 | m_InterruptionSource: 0 75 | m_OrderedInterruption: 1 76 | m_CanTransitionToSelf: 1 77 | --- !u!91 &9100000 78 | AnimatorController: 79 | m_ObjectHideFlags: 0 80 | m_CorrespondingSourceObject: {fileID: 0} 81 | m_PrefabInstance: {fileID: 0} 82 | m_PrefabAsset: {fileID: 0} 83 | m_Name: AnimController_Three 84 | serializedVersion: 5 85 | m_AnimatorParameters: [] 86 | m_AnimatorLayers: 87 | - serializedVersion: 5 88 | m_Name: Base Layer 89 | m_StateMachine: {fileID: -7295123783391113353} 90 | m_Mask: {fileID: 0} 91 | m_Motions: [] 92 | m_Behaviours: [] 93 | m_BlendingMode: 0 94 | m_SyncedLayerIndex: -1 95 | m_DefaultWeight: 0 96 | m_IKPass: 0 97 | m_SyncedLayerAffectsTiming: 0 98 | m_Controller: {fileID: 9100000} 99 | --- !u!1101 &1103962442273764562 100 | AnimatorStateTransition: 101 | m_ObjectHideFlags: 1 102 | m_CorrespondingSourceObject: {fileID: 0} 103 | m_PrefabInstance: {fileID: 0} 104 | m_PrefabAsset: {fileID: 0} 105 | m_Name: 106 | m_Conditions: [] 107 | m_DstStateMachine: {fileID: 0} 108 | m_DstState: {fileID: -8157273741378959870} 109 | m_Solo: 0 110 | m_Mute: 0 111 | m_IsExit: 0 112 | serializedVersion: 3 113 | m_TransitionDuration: 0.36976743 114 | m_TransitionOffset: 0.003514112 115 | m_ExitTime: 0.6285143 116 | m_HasExitTime: 1 117 | m_HasFixedDuration: 1 118 | m_InterruptionSource: 0 119 | m_OrderedInterruption: 1 120 | m_CanTransitionToSelf: 1 121 | --- !u!1102 &3185103783705212087 122 | AnimatorState: 123 | serializedVersion: 5 124 | m_ObjectHideFlags: 1 125 | m_CorrespondingSourceObject: {fileID: 0} 126 | m_PrefabInstance: {fileID: 0} 127 | m_PrefabAsset: {fileID: 0} 128 | m_Name: State1 129 | m_Speed: 1 130 | m_CycleOffset: 0 131 | m_Transitions: 132 | - {fileID: 1103962442273764562} 133 | m_StateMachineBehaviours: [] 134 | m_Position: {x: 50, y: 50, z: 0} 135 | m_IKOnFeet: 0 136 | m_WriteDefaultValues: 1 137 | m_Mirror: 0 138 | m_SpeedParameterActive: 0 139 | m_MirrorParameterActive: 0 140 | m_CycleOffsetParameterActive: 0 141 | m_TimeParameterActive: 0 142 | m_Motion: {fileID: 7400000, guid: 5b326cb030d2e4af8afc1fe47055bfb0, type: 2} 143 | m_Tag: 144 | m_SpeedParameter: 145 | m_MirrorParameter: 146 | m_CycleOffsetParameter: 147 | m_TimeParameter: 148 | -------------------------------------------------------------------------------- /Examples/AnimController_Three.controller.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 2cc81d404bc52422b8978b9a14b104bb 3 | NativeFormatImporter: 4 | externalObjects: {} 5 | mainObjectFileID: 0 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Examples/ExampleScene_One.unity.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: fdcba9a80e087474bad143b38cea3f27 3 | timeCreated: 1535309653 4 | licenseType: Pro 5 | DefaultImporter: 6 | externalObjects: {} 7 | userData: 8 | assetBundleName: 9 | assetBundleVariant: 10 | -------------------------------------------------------------------------------- /Examples/ExampleScene_Three.unity.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 5c13db25e31f242438affa5809090862 3 | timeCreated: 1535309653 4 | licenseType: Pro 5 | DefaultImporter: 6 | externalObjects: {} 7 | userData: 8 | assetBundleName: 9 | assetBundleVariant: 10 | -------------------------------------------------------------------------------- /Examples/ExampleScene_Two.unity.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 235d6cf7ca2694e3ba94d0ec291c000a 3 | timeCreated: 1535309653 4 | licenseType: Pro 5 | DefaultImporter: 6 | externalObjects: {} 7 | userData: 8 | assetBundleName: 9 | assetBundleVariant: 10 | -------------------------------------------------------------------------------- /Examples/ExampleScript_One.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: c43293fea9aba4589bb51af22262c04d 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Examples/UniRate.Examples.asmdef: -------------------------------------------------------------------------------- 1 | { 2 | "name": "UniRate.Examples", 3 | "references": [ 4 | "UniRate" 5 | ], 6 | "optionalUnityReferences": [], 7 | "includePlatforms": [], 8 | "excludePlatforms": [], 9 | "allowUnsafeCode": false, 10 | "overrideReferences": false, 11 | "precompiledReferences": [], 12 | "autoReferenced": true, 13 | "defineConstraints": [] 14 | } -------------------------------------------------------------------------------- /Examples/UniRate.Examples.asmdef.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 53427a8c9c7e34218a2c45262a285739 3 | AssemblyDefinitionImporter: 4 | externalObjects: {} 5 | userData: 6 | assetBundleName: 7 | assetBundleVariant: 8 | -------------------------------------------------------------------------------- /LICENSE.md: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2018 Renan Wolf Pace 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. -------------------------------------------------------------------------------- /LICENSE.md.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 5b2a63550a2004caf8f867ee096a4a05 3 | timeCreated: 1534017037 4 | licenseType: Free 5 | DefaultImporter: 6 | externalObjects: {} 7 | userData: 8 | assetBundleName: 9 | assetBundleVariant: 10 | -------------------------------------------------------------------------------- /Legacy.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 6cec9effc57e046e9b499427cc3788f2 3 | folderAsset: yes 4 | timeCreated: 1535309558 5 | licenseType: Pro 6 | DefaultImporter: 7 | externalObjects: {} 8 | userData: 9 | assetBundleName: 10 | assetBundleVariant: 11 | -------------------------------------------------------------------------------- /Legacy/CustomUnityEvents.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using UnityEngine.Events; 3 | 4 | namespace PWR.LowPowerMemoryConsumption { 5 | 6 | [Serializable] 7 | [Obsolete] 8 | public class UnityEventInt : UnityEvent { } 9 | 10 | [Serializable] 11 | [Obsolete] 12 | public class UnityEventBool : UnityEvent { } 13 | } -------------------------------------------------------------------------------- /Legacy/CustomUnityEvents.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 2bb465da36e7a4798886770bbe382d65 3 | timeCreated: 1535565365 4 | licenseType: Pro 5 | MonoImporter: 6 | externalObjects: {} 7 | serializedVersion: 2 8 | defaultReferences: [] 9 | executionOrder: 0 10 | icon: {instanceID: 0} 11 | userData: 12 | assetBundleName: 13 | assetBundleVariant: 14 | -------------------------------------------------------------------------------- /Legacy/Frame Rate.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 62128971d45254511b68cad1fe3e5ca8 3 | folderAsset: yes 4 | timeCreated: 1534017484 5 | licenseType: Free 6 | DefaultImporter: 7 | externalObjects: {} 8 | userData: 9 | assetBundleName: 10 | assetBundleVariant: 11 | -------------------------------------------------------------------------------- /Legacy/Frame Rate/FrameRateLooper.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 4274ea13ecb56462ab020a311c8be7d9 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Legacy/Frame Rate/FrameRateManager.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 50b09e51b7bd74cc294faa61d3c939d6 3 | timeCreated: 1534017636 4 | licenseType: Free 5 | MonoImporter: 6 | externalObjects: {} 7 | serializedVersion: 2 8 | defaultReferences: [] 9 | executionOrder: 0 10 | icon: {instanceID: 0} 11 | userData: 12 | assetBundleName: 13 | assetBundleVariant: 14 | -------------------------------------------------------------------------------- /Legacy/Frame Rate/FrameRateRequest.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using UniRate; 3 | 4 | namespace PWR.LowPowerMemoryConsumption { 5 | 6 | [Obsolete] 7 | public struct FrameRateRequest { 8 | 9 | #region <<---------- Initializers ---------->> 10 | 11 | public FrameRateRequest(RateRequest request) { 12 | this._request = request; 13 | this._type = default(FrameRateType); 14 | this._rate = 0; 15 | if (request == null) return; 16 | if (request is FixedUpdateRateRequest fixedRequest) { 17 | this._type = FrameRateType.FixedFPS; 18 | this._rate = fixedRequest.FixedUpdateRate; 19 | } 20 | else if (request is UpdateRateRequest updateRequest) { 21 | this._type = FrameRateType.FPS; 22 | this._rate = updateRequest.UpdateRate; 23 | } 24 | } 25 | 26 | #endregion <<---------- Initializers ---------->> 27 | 28 | 29 | 30 | 31 | #region <<---------- Properties and Fields ---------->> 32 | 33 | public RateRequest UniRateRequest => this._request; 34 | private readonly RateRequest _request; 35 | 36 | public int Rate => this._rate; 37 | private readonly int _rate; 38 | 39 | public FrameRateType Type => this._type; 40 | private readonly FrameRateType _type; 41 | 42 | public bool IsValid => (this._rate >= MinRate && this._request != null); 43 | 44 | public const int MinRate = 1; 45 | 46 | public static readonly FrameRateRequest Invalid = new FrameRateRequest(null); 47 | 48 | #endregion <<---------- Properties and Fields ---------->> 49 | 50 | 51 | 52 | 53 | #region <<---------- Legacy Support ---------->> 54 | 55 | 56 | 57 | #endregion <<---------- Legacy Support ---------->> 58 | } 59 | } -------------------------------------------------------------------------------- /Legacy/Frame Rate/FrameRateRequest.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: c52e3d36192354c5693b746089f59fa0 3 | timeCreated: 1534025905 4 | licenseType: Free 5 | MonoImporter: 6 | externalObjects: {} 7 | serializedVersion: 2 8 | defaultReferences: [] 9 | executionOrder: 0 10 | icon: {instanceID: 0} 11 | userData: 12 | assetBundleName: 13 | assetBundleVariant: 14 | -------------------------------------------------------------------------------- /Legacy/Frame Rate/FrameRateRequestComponent.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using UnityEngine; 3 | 4 | namespace PWR.LowPowerMemoryConsumption { 5 | 6 | [Obsolete("OBSOLETE, use RateRequestWhileEnabledComponent instead")] 7 | public class FrameRateRequestComponent : MonoBehaviour { 8 | 9 | #region <<---------- Initializers ---------->> 10 | 11 | protected FrameRateRequestComponent() { } 12 | 13 | #endregion <<---------- Initializers ---------->> 14 | 15 | 16 | 17 | 18 | #region <<---------- Properties and Fields ---------->> 19 | 20 | [SerializeField] private FrameRateType _type = FrameRateType.FPS; 21 | 22 | [SerializeField][Range(FrameRateRequest.MinRate, 120)] private int _rate = 30; 23 | 24 | /// 25 | /// Frame rate type. 26 | /// 27 | public FrameRateType Type { 28 | get { return this._type; } 29 | set { 30 | this._type = value; 31 | if (!Application.isPlaying || !this.IsRequestValuesDifferentFromFields()) return; 32 | this.AssertCurrentRequestRunning(this.isActiveAndEnabled); 33 | } 34 | } 35 | 36 | /// 37 | /// Frame rate value. 38 | /// 39 | public int Rate { 40 | get { return this._rate; } 41 | set { 42 | this._rate = value; 43 | if (!Application.isPlaying || !this.IsRequestValuesDifferentFromFields()) return; 44 | this.AssertCurrentRequestRunning(this.isActiveAndEnabled); 45 | } 46 | } 47 | 48 | private FrameRateRequest _request; 49 | 50 | private bool _isApplicationQuitting = false; 51 | 52 | #endregion <<---------- Properties and Fields ---------->> 53 | 54 | 55 | 56 | 57 | #region <<---------- MonoBehaviour ---------->> 58 | 59 | protected virtual void OnEnable() { 60 | this.AssertCurrentRequestRunning(true); 61 | } 62 | 63 | protected virtual void OnDisable() { 64 | if (this._isApplicationQuitting) return; 65 | this.AssertCurrentRequestRunning(false); 66 | } 67 | 68 | protected virtual void OnApplicationQuit() { 69 | this._isApplicationQuitting = true; 70 | } 71 | 72 | #if UNITY_EDITOR 73 | protected virtual void OnValidate() { 74 | if (!Application.isPlaying) return; 75 | this.AssertCurrentRequestRunning(this.isActiveAndEnabled); 76 | } 77 | protected virtual void OnReset() { 78 | if (!Application.isPlaying) return; 79 | this.AssertCurrentRequestRunning(this.isActiveAndEnabled); 80 | } 81 | #endif 82 | 83 | #endregion <<---------- MonoBehaviour ---------->> 84 | 85 | 86 | 87 | 88 | #region <<---------- General ---------->> 89 | 90 | private void AssertCurrentRequestRunning(bool running) { 91 | FrameRateManager.Instance.StopRequest(this._request); 92 | if (!running) { 93 | this._request = FrameRateRequest.Invalid; 94 | return; 95 | } 96 | this._request = FrameRateManager.Instance.StartRequest(this._type, this._rate); 97 | } 98 | 99 | private bool IsRequestValuesDifferentFromFields() { 100 | return this._request.Type != this._type || this._request.Rate != this._rate; 101 | } 102 | 103 | #endregion <<---------- General ---------->> 104 | } 105 | } -------------------------------------------------------------------------------- /Legacy/Frame Rate/FrameRateRequestComponent.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 9d2d72ad0c6ce4382ac8628f6af45526 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Legacy/Frame Rate/FrameRateRequester.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace PWR.LowPowerMemoryConsumption { 4 | 5 | [Obsolete("OBSOLETE, use RateRequestWhileEnabledComponent instead")] 6 | public class FrameRateRequester : FrameRateRequestComponent { 7 | 8 | #region <<---------- Initializers ---------->> 9 | 10 | protected FrameRateRequester() { } 11 | 12 | #endregion <<---------- Initializers ---------->> 13 | } 14 | } -------------------------------------------------------------------------------- /Legacy/Frame Rate/FrameRateRequester.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: f4e03d04cd3ac4bb9baf2a6c5861f3cd 3 | timeCreated: 1534100437 4 | licenseType: Free 5 | MonoImporter: 6 | externalObjects: {} 7 | serializedVersion: 2 8 | defaultReferences: [] 9 | executionOrder: 0 10 | icon: {instanceID: 0} 11 | userData: 12 | assetBundleName: 13 | assetBundleVariant: 14 | -------------------------------------------------------------------------------- /Legacy/Frame Rate/FrameRateTrigger.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using UnityEngine; 3 | 4 | namespace PWR.LowPowerMemoryConsumption { 5 | 6 | [Obsolete] 7 | public class FrameRateTrigger : MonoBehaviour { 8 | 9 | #region <<---------- Properties and Fields ---------->> 10 | 11 | [SerializeField] private FrameRateType _type = FrameRateType.FPS; 12 | 13 | [SerializeField] private UnityEventInt _currentRateChanged; 14 | 15 | [SerializeField] private UnityEventInt _targetRateChanged; 16 | 17 | /// 18 | /// Rate type. 19 | /// 20 | public FrameRateType Type { 21 | get { return this._type; } 22 | set { 23 | if (this._type == value) return; 24 | this._type = value; 25 | this.OnTypeChanged(); 26 | } 27 | } 28 | 29 | /// 30 | /// Event raised when current rate of changes. 31 | /// 32 | public UnityEventInt CurrentRateChanged { 33 | get { 34 | if (this._currentRateChanged == null) { 35 | this._currentRateChanged = new UnityEventInt(); 36 | } 37 | return this._currentRateChanged; 38 | } 39 | } 40 | 41 | /// 42 | /// Event raised when target rate of changes. 43 | /// 44 | public UnityEventInt TargetRateChanged { 45 | get { 46 | if (this._targetRateChanged == null) { 47 | this._targetRateChanged = new UnityEventInt(); 48 | } 49 | return this._targetRateChanged; 50 | } 51 | } 52 | 53 | private bool _isApplicationQuitting = false; 54 | 55 | #endregion <<---------- Properties and Fields ---------->> 56 | 57 | 58 | 59 | 60 | #region <<---------- MonoBehaviour ---------->> 61 | 62 | protected virtual void OnEnable() { 63 | this.NotifyAllRatesChanged(); 64 | this.StartListening(); 65 | } 66 | 67 | protected virtual void OnDisable() { 68 | if (this._isApplicationQuitting) return; 69 | this.StopListening(); 70 | } 71 | 72 | protected virtual void OnApplicationQuit() { 73 | this._isApplicationQuitting = true; 74 | } 75 | 76 | #if UNITY_EDITOR 77 | protected virtual void OnValidate() { 78 | this.OnTypeChanged(); 79 | } 80 | #endif 81 | 82 | #endregion <<---------- MonoBehaviour ---------->> 83 | 84 | 85 | 86 | 87 | #region <<---------- General ---------->> 88 | 89 | private void NotifyAllRatesChanged() { 90 | this.NotifyTargetFrameRateChanged(); 91 | this.NotifyTargetFixedFrameRateChanged(); 92 | this.NotifyCurrentFrameRateChanged(); 93 | this.NotifyCurrentFixedFrameRateChanged(); 94 | } 95 | 96 | protected virtual void OnTypeChanged() { 97 | if (!this.isActiveAndEnabled) return; 98 | this.NotifyAllRatesChanged(); 99 | } 100 | 101 | protected void StartListening() { 102 | FrameRateManager.Instance.TargetFrameRateChanged += this.NotifyTargetFrameRateChanged; 103 | FrameRateManager.Instance.FrameRateChanged += this.NotifyCurrentFrameRateChanged; 104 | 105 | FrameRateManager.Instance.TargetFixedFrameRateChanged += this.NotifyTargetFixedFrameRateChanged; 106 | FrameRateManager.Instance.FixedFrameRateChanged += this.NotifyCurrentFixedFrameRateChanged; 107 | } 108 | 109 | protected void StopListening() { 110 | FrameRateManager.Instance.TargetFrameRateChanged -= this.NotifyTargetFrameRateChanged; 111 | FrameRateManager.Instance.FrameRateChanged -= this.NotifyCurrentFrameRateChanged; 112 | 113 | FrameRateManager.Instance.TargetFixedFrameRateChanged -= this.NotifyTargetFixedFrameRateChanged; 114 | FrameRateManager.Instance.FixedFrameRateChanged -= this.NotifyCurrentFixedFrameRateChanged; 115 | } 116 | 117 | protected void NotifyCurrentFrameRateChanged() { 118 | this.NotifyCurrentFrameRateChanged(FrameRateManager.Instance.FrameRate); 119 | } 120 | protected virtual void NotifyCurrentFrameRateChanged(int rate) { 121 | if (this._type != FrameRateType.FPS) return; 122 | if (this._currentRateChanged != null) this._currentRateChanged.Invoke(rate); 123 | } 124 | 125 | protected void NotifyTargetFrameRateChanged() { 126 | this.NotifyTargetFrameRateChanged(FrameRateManager.Instance.TargetFrameRate); 127 | } 128 | protected virtual void NotifyTargetFrameRateChanged(int rate) { 129 | if (this._type != FrameRateType.FPS) return; 130 | if (this._targetRateChanged != null) this._targetRateChanged.Invoke(rate); 131 | } 132 | 133 | protected void NotifyCurrentFixedFrameRateChanged() { 134 | this.NotifyCurrentFixedFrameRateChanged(FrameRateManager.Instance.FixedFrameRate); 135 | } 136 | protected virtual void NotifyCurrentFixedFrameRateChanged(int rate) { 137 | if (this._type != FrameRateType.FixedFPS) return; 138 | if (this._currentRateChanged != null) this._currentRateChanged.Invoke(rate); 139 | } 140 | 141 | protected void NotifyTargetFixedFrameRateChanged() { 142 | this.NotifyTargetFixedFrameRateChanged(FrameRateManager.Instance.TargetFixedFrameRate); 143 | } 144 | protected virtual void NotifyTargetFixedFrameRateChanged(int rate) { 145 | if (this._type != FrameRateType.FixedFPS) return; 146 | if (this._targetRateChanged != null) this._targetRateChanged.Invoke(rate); 147 | } 148 | 149 | #endregion <<---------- General ---------->> 150 | } 151 | } -------------------------------------------------------------------------------- /Legacy/Frame Rate/FrameRateTrigger.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 918950bc085434e4591581be1d545f25 3 | timeCreated: 1534962991 4 | licenseType: Pro 5 | MonoImporter: 6 | externalObjects: {} 7 | serializedVersion: 2 8 | defaultReferences: [] 9 | executionOrder: 0 10 | icon: {instanceID: 0} 11 | userData: 12 | assetBundleName: 13 | assetBundleVariant: 14 | -------------------------------------------------------------------------------- /Legacy/Frame Rate/FrameRateType.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace PWR.LowPowerMemoryConsumption { 4 | 5 | [Obsolete] 6 | public enum FrameRateType { 7 | FPS, 8 | FixedFPS 9 | } 10 | } -------------------------------------------------------------------------------- /Legacy/Frame Rate/FrameRateType.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: c6c159ec2d58147ea9bc0efe4876cdbc 3 | timeCreated: 1534099335 4 | licenseType: Free 5 | MonoImporter: 6 | externalObjects: {} 7 | serializedVersion: 2 8 | defaultReferences: [] 9 | executionOrder: 0 10 | icon: {instanceID: 0} 11 | userData: 12 | assetBundleName: 13 | assetBundleVariant: 14 | -------------------------------------------------------------------------------- /Legacy/Memory.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 92033221ebdda49d7a06e40a61c2a044 3 | folderAsset: yes 4 | timeCreated: 1533873284 5 | licenseType: Free 6 | DefaultImporter: 7 | externalObjects: {} 8 | userData: 9 | assetBundleName: 10 | assetBundleVariant: 11 | -------------------------------------------------------------------------------- /Legacy/Memory/LowMemoryTrigger.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using UnityEngine; 3 | using UnityEngine.Events; 4 | 5 | #if UNITY_EDITOR 6 | using UnityEditor; 7 | #endif 8 | 9 | namespace PWR.LowPowerMemoryConsumption { 10 | 11 | [Obsolete("OBSOLETE, this package will no longer provide the MemoryManager system on next versions")] 12 | public class LowMemoryTrigger : MonoBehaviour { 13 | 14 | #region <<---------- Properties and Fields ---------->> 15 | 16 | [SerializeField] private UnityEvent _lowMemory; 17 | 18 | /// 19 | /// Event raised when is raised. 20 | /// 21 | public UnityEvent LowMemory { 22 | get { 23 | if (this._lowMemory == null) { 24 | this._lowMemory = new UnityEvent(); 25 | } 26 | return this._lowMemory; 27 | } 28 | } 29 | 30 | private bool _isApplicationQuitting = false; 31 | 32 | #endregion <<---------- Properties and Fields ---------->> 33 | 34 | 35 | 36 | 37 | #region <<---------- MonoBehaviour ---------->> 38 | 39 | protected virtual void OnEnable() { 40 | MemoryManager.Instance.LowMemory += this.OnLowMemory; 41 | } 42 | 43 | protected virtual void OnDisable() { 44 | if (this._isApplicationQuitting) return; 45 | MemoryManager.Instance.LowMemory -= this.OnLowMemory; 46 | } 47 | 48 | protected virtual void OnApplicationQuit() { 49 | this._isApplicationQuitting = true; 50 | } 51 | 52 | #endregion <<---------- MonoBehaviour ---------->> 53 | 54 | 55 | 56 | 57 | #region <<---------- General ---------->> 58 | 59 | protected virtual void OnLowMemory() { 60 | if (this._lowMemory == null) return; 61 | this._lowMemory.Invoke(); 62 | } 63 | 64 | #endregion <<---------- General ---------->> 65 | 66 | 67 | 68 | 69 | #region <<---------- Custom Inspector ---------->> 70 | #if UNITY_EDITOR 71 | [CustomEditor(typeof(LowMemoryTrigger), true)] 72 | [CanEditMultipleObjects] 73 | protected class CustomInspectorBase : Editor { 74 | 75 | public override void OnInspectorGUI() { 76 | this.serializedObject.Update(); 77 | this.DrawDefaultInspector(); 78 | 79 | if (!MemoryManager.IsSupported) { 80 | EditorGUILayout.HelpBox(MemoryManager.NotSupportedMessage, MessageType.Warning); 81 | EditorGUILayout.Space(); 82 | } 83 | } 84 | } 85 | #endif 86 | #endregion <<---------- Custom Inspector ---------->> 87 | } 88 | } -------------------------------------------------------------------------------- /Legacy/Memory/LowMemoryTrigger.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 9331ba75fd28d4ab2b15236deec2c0d6 3 | timeCreated: 1533877125 4 | licenseType: Free 5 | MonoImporter: 6 | externalObjects: {} 7 | serializedVersion: 2 8 | defaultReferences: [] 9 | executionOrder: 0 10 | icon: {instanceID: 0} 11 | userData: 12 | assetBundleName: 13 | assetBundleVariant: 14 | -------------------------------------------------------------------------------- /Legacy/Memory/MemoryManager.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 7bcd4bd55a26a41d082833b5c07b49a1 3 | timeCreated: 1533873471 4 | licenseType: Free 5 | MonoImporter: 6 | externalObjects: {} 7 | serializedVersion: 2 8 | defaultReferences: [] 9 | executionOrder: 0 10 | icon: {instanceID: 0} 11 | userData: 12 | assetBundleName: 13 | assetBundleVariant: 14 | -------------------------------------------------------------------------------- /Legacy/Power Profiles.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 1fcb78aa671a446fe9e822f81902c7f3 3 | folderAsset: yes 4 | DefaultImporter: 5 | externalObjects: {} 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Legacy/Power Profiles/Components.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 29dbe62d404ba48378bc01c6e8fe0510 3 | folderAsset: yes 4 | DefaultImporter: 5 | externalObjects: {} 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Legacy/Power Profiles/Components/PowerProfileComponent.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using UnityEngine; 3 | 4 | namespace PWR.LowPowerMemoryConsumption { 5 | 6 | [Obsolete("OBSOLETE, use RateRequestWhileEnabledComponent instead")] 7 | public class PowerProfileComponent : MonoBehaviour { 8 | 9 | #region <<---------- Properties and Fields ---------->> 10 | 11 | [SerializeField] private PowerProfile _profile; 12 | 13 | protected bool isRetainedByMe; 14 | 15 | #endregion <<---------- Properties and Fields ---------->> 16 | 17 | 18 | 19 | 20 | #region <<---------- MonoBehaviour ---------->> 21 | 22 | protected virtual void OnEnable() { 23 | this.RetainNow(); 24 | } 25 | 26 | protected virtual void OnDisable() { 27 | this.ReleaseNow(); 28 | } 29 | 30 | #endregion <<---------- MonoBehaviour ---------->> 31 | 32 | 33 | 34 | 35 | #region <<---------- General ---------->> 36 | 37 | protected virtual void RetainNow() { 38 | if (this.isRetainedByMe || this._profile == null) return; 39 | this.isRetainedByMe = true; 40 | this._profile.Retain(); 41 | } 42 | 43 | protected virtual void ReleaseNow() { 44 | if (!this.isRetainedByMe || this._profile == null) return; 45 | this.isRetainedByMe = false; 46 | this._profile.Release(); 47 | } 48 | 49 | #endregion <<---------- General ---------->> 50 | } 51 | } -------------------------------------------------------------------------------- /Legacy/Power Profiles/Components/PowerProfileComponent.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 4a77208e449a94bfc9a67689924da08d 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Legacy/Power Profiles/Components/PowerProfileComponentDelayedRelease.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using UnityEngine; 3 | 4 | namespace PWR.LowPowerMemoryConsumption { 5 | 6 | [Obsolete] 7 | public abstract class PowerProfileComponentDelayedRelease : PowerProfileComponent { 8 | 9 | #region <<---------- Properties and Fields ---------->> 10 | 11 | [SerializeField] protected float delayedReleaseSeconds = 2f; 12 | 13 | private float _timeReleaseRequested; 14 | 15 | #endregion <<---------- Properties and Fields ---------->> 16 | 17 | 18 | 19 | 20 | #region <<---------- MonoBehaviour ---------->> 21 | 22 | protected virtual void Awake() { 23 | this.SetReleaseRequestedNever(); 24 | } 25 | 26 | protected virtual void Update() { 27 | if (!this.IsDelayedReleaseEnabled()) return; 28 | if (this.ElapsedTimeReleaseRequested() < this.delayedReleaseSeconds) return; 29 | this.ReleaseNow(); 30 | } 31 | 32 | protected virtual void FixedUpdate() { 33 | if (!this.IsDelayedReleaseEnabled()) return; 34 | if (this.ElapsedTimeReleaseRequested() < this.delayedReleaseSeconds) return; 35 | this.ReleaseNow(); 36 | } 37 | 38 | #endregion <<---------- MonoBehaviour ---------->> 39 | 40 | 41 | 42 | 43 | #region <<---------- General ---------->> 44 | 45 | private void SetReleaseRequestedNever() { 46 | this._timeReleaseRequested = float.PositiveInfinity; 47 | } 48 | 49 | protected float ElapsedTimeReleaseRequested() { 50 | return Time.realtimeSinceStartup - this._timeReleaseRequested; 51 | } 52 | 53 | protected bool IsDelayedReleaseEnabled() { 54 | return this.delayedReleaseSeconds > 0f; 55 | } 56 | 57 | protected override void RetainNow() { 58 | this.SetReleaseRequestedNever(); 59 | base.RetainNow(); 60 | } 61 | 62 | protected override void ReleaseNow() { 63 | if (this.isRetainedByMe) { 64 | this.SetReleaseRequestedNever(); 65 | } 66 | base.ReleaseNow(); 67 | } 68 | 69 | protected void ReleaseNowOrDelayed() { 70 | if (!this.IsDelayedReleaseEnabled()) { 71 | this.ReleaseNow(); 72 | return; 73 | } 74 | if (!this.isRetainedByMe) return; 75 | this._timeReleaseRequested = Time.realtimeSinceStartup; 76 | } 77 | 78 | #endregion <<---------- General ---------->> 79 | } 80 | } -------------------------------------------------------------------------------- /Legacy/Power Profiles/Components/PowerProfileComponentDelayedRelease.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: c6bd56bdc6cde4bc1a55c7d2927bf21e 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Legacy/Power Profiles/Components/PowerProfileInputField.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using UnityEngine; 3 | using UnityEngine.UI; 4 | 5 | namespace PWR.LowPowerMemoryConsumption { 6 | 7 | [RequireComponent(typeof(InputField))] 8 | [Obsolete("OBSOLETE, use RateRequestInputFieldComponent instead.")] 9 | public class PowerProfileInputField : PowerProfileComponentDelayedRelease { 10 | 11 | #region <<---------- Properties and Fields ---------->> 12 | 13 | private InputField _inputField; 14 | 15 | private bool IsInputFieldFocused { 16 | get { return this._isInputFieldFocused; } 17 | set { 18 | if (this._isInputFieldFocused == value) return; 19 | this._isInputFieldFocused = value; 20 | this.OnInputFieldFocusChanged(this._isInputFieldFocused); 21 | } 22 | } 23 | private bool _isInputFieldFocused; 24 | 25 | #endregion <<---------- Properties and Fields ---------->> 26 | 27 | 28 | 29 | 30 | #region <<---------- MonoBehaviour ---------->> 31 | 32 | protected override void Awake() { 33 | base.Awake(); 34 | this._inputField = this.GetComponent(); 35 | } 36 | 37 | protected override void OnEnable() { 38 | //do not call base to prevent auto retain 39 | this._inputField.onEndEdit.AddListener(this.OnInputFieldValueChangedOrEndEdit); 40 | this._inputField.onValueChanged.AddListener(this.OnInputFieldValueChangedOrEndEdit); 41 | this.IsInputFieldFocused = this._inputField.isFocused; 42 | } 43 | 44 | protected override void OnDisable() { 45 | this._inputField.onEndEdit.RemoveListener(this.OnInputFieldValueChangedOrEndEdit); 46 | this._inputField.onValueChanged.RemoveListener(this.OnInputFieldValueChangedOrEndEdit); 47 | 48 | this._isInputFieldFocused = false; 49 | base.OnDisable(); 50 | } 51 | 52 | #endregion <<---------- MonoBehaviour ---------->> 53 | 54 | 55 | 56 | 57 | #region <<---------- Callbacks ---------->> 58 | 59 | protected virtual void OnInputFieldFocusChanged(bool isFocused) { 60 | if (isFocused) { 61 | this.RetainNow(); 62 | return; 63 | } 64 | this.ReleaseNowOrDelayed(); 65 | } 66 | 67 | protected virtual void OnInputFieldValueChangedOrEndEdit(string value) { 68 | this.IsInputFieldFocused = this._inputField.isFocused; 69 | } 70 | 71 | #endregion <<---------- Callbacks ---------->> 72 | } 73 | } -------------------------------------------------------------------------------- /Legacy/Power Profiles/Components/PowerProfileInputField.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 495e2b50d379c4e3bb197191c69cf1f0 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Legacy/Power Profiles/Components/PowerProfileScrollRect.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using UnityEngine; 3 | using UnityEngine.UI; 4 | 5 | namespace PWR.LowPowerMemoryConsumption { 6 | 7 | [RequireComponent(typeof(ScrollRect))] 8 | [Obsolete("OBSOLETE, use RateRequestScrollRectComponent instead.")] 9 | public class PowerProfileScrollRect : PowerProfileComponentDelayedRelease { 10 | 11 | #region <<---------- Properties and Fields ---------->> 12 | 13 | private ScrollRect _scrollRect; 14 | 15 | #endregion <<---------- Properties and Fields ---------->> 16 | 17 | 18 | 19 | 20 | #region <<---------- MonoBehaviour ---------->> 21 | 22 | protected override void Awake() { 23 | base.Awake(); 24 | this._scrollRect = this.GetComponent(); 25 | } 26 | 27 | protected override void OnEnable() { 28 | //do not call base to prevent auto retain 29 | this._scrollRect.onValueChanged.AddListener(this.OnScrollRectValueChanged); 30 | this.OnScrollRectValueChanged(Vector2.zero); 31 | } 32 | 33 | protected override void OnDisable() { 34 | this._scrollRect.onValueChanged.RemoveListener(this.OnScrollRectValueChanged); 35 | base.OnDisable(); 36 | } 37 | 38 | #endregion <<---------- MonoBehaviour ---------->> 39 | 40 | 41 | 42 | 43 | #region <<---------- Callbacks ---------->> 44 | 45 | protected virtual void OnScrollRectValueChanged(Vector2 normalizedPosition) { 46 | this.RetainNow(); 47 | this.ReleaseNowOrDelayed(); 48 | } 49 | 50 | #endregion <<---------- Callbacks ---------->> 51 | } 52 | } -------------------------------------------------------------------------------- /Legacy/Power Profiles/Components/PowerProfileScrollRect.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 668bb842b76a8412285ffaab38a5b210 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Legacy/Power Profiles/Components/PowerProfileTMPInputField.cs: -------------------------------------------------------------------------------- 1 | //#define TM_PRO 2 | 3 | using System; 4 | using UnityEngine; 5 | #if TM_PRO 6 | using TMPro; 7 | #endif 8 | 9 | namespace PWR.LowPowerMemoryConsumption { 10 | 11 | #if TM_PRO 12 | [RequireComponent(typeof(TMP_InputField))] 13 | #endif 14 | [Obsolete("OBSOLETE, use RateRequestTMPInputFieldComponent instead.")] 15 | public class PowerProfileTMPInputField : PowerProfileComponentDelayedRelease { 16 | 17 | #region <<---------- Properties and Fields ---------->> 18 | 19 | #if TM_PRO 20 | private TMP_InputField _inputField; 21 | #endif 22 | 23 | private bool IsInputFieldFocused { 24 | get { return this._isInputFieldFocused; } 25 | set { 26 | if (this._isInputFieldFocused == value) return; 27 | this._isInputFieldFocused = value; 28 | this.OnInputFieldFocusChanged(this._isInputFieldFocused); 29 | } 30 | } 31 | private bool _isInputFieldFocused; 32 | 33 | #endregion <<---------- Properties and Fields ---------->> 34 | 35 | 36 | 37 | 38 | #region <<---------- MonoBehaviour ---------->> 39 | 40 | 41 | protected override void Awake() { 42 | base.Awake(); 43 | #if TM_PRO 44 | this._inputField = this.GetComponent(); 45 | #else 46 | Debug.LogWarning("[" + this.GetType().Name + "] '#define TM_PRO' is not enabled on script, remove comment on first line of file 'PowerProfileTMPInputField.cs'", this); 47 | #endif 48 | } 49 | 50 | #if TM_PRO 51 | protected override void OnEnable() { 52 | //do not call base to prevent auto retain 53 | this._inputField.onEndEdit.AddListener(this.OnInputFieldValueChangedOrEndEdit); 54 | this._inputField.onValueChanged.AddListener(this.OnInputFieldValueChangedOrEndEdit); 55 | this.IsInputFieldFocused = this._inputField.isFocused; 56 | } 57 | 58 | protected override void OnDisable() { 59 | this._inputField.onEndEdit.RemoveListener(this.OnInputFieldValueChangedOrEndEdit); 60 | this._inputField.onValueChanged.RemoveListener(this.OnInputFieldValueChangedOrEndEdit); 61 | 62 | this._isInputFieldFocused = false; 63 | base.OnDisable(); 64 | } 65 | #endif 66 | 67 | #endregion <<---------- MonoBehaviour ---------->> 68 | 69 | 70 | 71 | 72 | #region <<---------- Callbacks ---------->> 73 | 74 | protected virtual void OnInputFieldFocusChanged(bool isFocused) { 75 | if (isFocused) { 76 | this.RetainNow(); 77 | return; 78 | } 79 | this.ReleaseNowOrDelayed(); 80 | } 81 | 82 | #if TM_PRO 83 | protected virtual void OnInputFieldValueChangedOrEndEdit(string value) { 84 | this.IsInputFieldFocused = this._inputField.isFocused; 85 | } 86 | #endif 87 | 88 | #endregion <<---------- Callbacks ---------->> 89 | } 90 | } -------------------------------------------------------------------------------- /Legacy/Power Profiles/Components/PowerProfileTMPInputField.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 3c43c3d62f3d1445290bcb4ab91a8963 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Legacy/Power Profiles/Components/PowerProfileTouches.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using UnityEngine; 3 | 4 | namespace PWR.LowPowerMemoryConsumption { 5 | 6 | [Obsolete("OBSOLETE, use RateRequestTouchComponent instead")] 7 | public class PowerProfileTouches : PowerProfileComponentDelayedRelease { 8 | 9 | #region <<---------- Properties and Fields ---------->> 10 | 11 | protected bool HasTouches { 12 | get { return this._hasTouches; } 13 | private set { 14 | if (this._hasTouches == value) return; 15 | this._hasTouches = value; 16 | this.OnHasTouchesChanged(this._hasTouches); 17 | } 18 | } 19 | private bool _hasTouches; 20 | 21 | #endregion <<---------- Properties and Fields ---------->> 22 | 23 | 24 | 25 | 26 | #region <<---------- MonoBehaviour ---------->> 27 | 28 | protected override void OnEnable() { 29 | //do not call base to prevent auto retain 30 | this.HasTouches = this.GetTouchCount() > 0; 31 | } 32 | 33 | protected override void Update() { 34 | this.HasTouches = this.GetTouchCount() > 0; 35 | base.Update(); 36 | } 37 | 38 | protected override void FixedUpdate() { 39 | this.HasTouches = this.GetTouchCount() > 0; 40 | base.FixedUpdate(); 41 | } 42 | 43 | protected override void OnDisable() { 44 | this._hasTouches = false; 45 | base.OnDisable(); 46 | } 47 | 48 | #endregion <<---------- MonoBehaviour ---------->> 49 | 50 | 51 | 52 | 53 | #region <<---------- Callbacks ---------->> 54 | 55 | protected virtual void OnHasTouchesChanged(bool hasTouches) { 56 | if (hasTouches) { 57 | this.RetainNow(); 58 | return; 59 | } 60 | this.ReleaseNowOrDelayed(); 61 | } 62 | 63 | #endregion <<---------- Callbacks ---------->> 64 | 65 | 66 | 67 | 68 | #region <<---------- General ---------->> 69 | 70 | private int GetTouchCount() { 71 | #if UNITY_EDITOR 72 | if (Input.GetMouseButton(0)) return 1; 73 | #endif 74 | return Input.touchCount; 75 | } 76 | 77 | #endregion <<---------- General ---------->> 78 | } 79 | } -------------------------------------------------------------------------------- /Legacy/Power Profiles/Components/PowerProfileTouches.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: ad3956f6e889547549935bac1142eb16 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Legacy/Power Profiles/PowerProfile.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Linq; 3 | using System.Collections.Generic; 4 | using UnityEngine; 5 | 6 | #if UNITY_EDITOR 7 | using UnityEditor; 8 | #endif 9 | 10 | namespace PWR.LowPowerMemoryConsumption { 11 | 12 | [Serializable] 13 | [Obsolete] 14 | public abstract class PowerProfile : ScriptableObject { 15 | 16 | #region <<---------- Properties and Fields ---------->> 17 | 18 | [SerializeField] private string _identifier; 19 | 20 | /// 21 | /// Identifier to help find this object on enumerable. 22 | /// 23 | public string Identifier { 24 | get { return this._identifier; } 25 | set { this._identifier = value; } 26 | } 27 | 28 | /// 29 | /// Indicates if retain count is greater than zero. 30 | /// 31 | public bool IsRetained { 32 | get { return this._isRetained; } 33 | private set { 34 | if (this._isRetained == value) return; 35 | this._isRetained = value; 36 | this.OnIsRetainedChanged(this._isRetained); 37 | } 38 | } 39 | private bool _isRetained; 40 | 41 | /// 42 | /// Retain count. 43 | /// 44 | public int RetainCount { 45 | get { return this._retainCount; } 46 | } 47 | private int _retainCount = 0; 48 | 49 | /// 50 | /// All enabled instances. 51 | /// 52 | public static IEnumerable Instances { 53 | get { 54 | if (_instances != null) return _instances; 55 | return Enumerable.Empty(); 56 | } 57 | } 58 | private static HashSet _instances; 59 | 60 | #endregion <<---------- Properties and Fields ---------->> 61 | 62 | 63 | 64 | 65 | #region <<---------- Scriptable Object ---------->> 66 | 67 | #if UNITY_EDITOR 68 | protected virtual void Awake() { 69 | EditorApplication.playModeStateChanged += (state) => { 70 | if (state == PlayModeStateChange.EnteredPlayMode || state == PlayModeStateChange.ExitingEditMode) { 71 | this._retainCount = 0; 72 | } 73 | }; 74 | } 75 | #endif 76 | 77 | protected virtual void OnEnable() { 78 | this.AddToStaticInstances(); 79 | } 80 | 81 | protected virtual void OnDisable() { 82 | this.RemoveFromStaticInstances(); 83 | } 84 | 85 | #endregion <<---------- Scriptable Object ---------->> 86 | 87 | 88 | 89 | 90 | #region <<---------- Callbacks ---------->> 91 | 92 | protected abstract void OnIsRetainedChanged(bool isRetained); 93 | 94 | #endregion <<---------- Callbacks ---------->> 95 | 96 | 97 | 98 | 99 | #region <<---------- General ---------->> 100 | 101 | /// 102 | /// Increase retain count to keep profile requests active. 103 | /// 104 | public void Retain() { 105 | #if UNITY_EDITOR 106 | if (!Application.isPlaying) { 107 | Debug.LogWarning("[" + this.GetType().Name + "/" + this.name + "] Retain() is only allowed while in play mode", this); 108 | } 109 | #endif 110 | this._retainCount += 1; 111 | if (this._retainCount < 0) { 112 | Debug.LogWarning("[" + this.GetType().Name + "/" + this.name + "] retain count is " + this._retainCount, this); 113 | } 114 | this.IsRetained = this._retainCount > 0; 115 | } 116 | 117 | /// 118 | /// Decrease retain count. When reach zero, profile requests will be stoped. 119 | /// 120 | public void Release() { 121 | #if UNITY_EDITOR 122 | if (!Application.isPlaying) { 123 | Debug.LogWarning("[" + this.GetType().Name + "/" + this.name + "] Release() is only allowed while in play mode", this); 124 | } 125 | #endif 126 | this._retainCount -= 1; 127 | if (this._retainCount < 0) { 128 | Debug.LogWarning("[" + this.GetType().Name + "/" + this.name + "] retain count is " + this._retainCount, this); 129 | } 130 | this.IsRetained = this._retainCount > 0; 131 | } 132 | 133 | /// 134 | /// Retain or release. 135 | /// 136 | /// If true will retain, otherwise release. 137 | public void RetainOrRelease(bool retain) { 138 | if (retain) this.Retain(); 139 | else this.Release(); 140 | } 141 | 142 | /// 143 | /// Release or retain. 144 | /// 145 | /// If true will release, otherwise retain. 146 | public void ReleaseOrRetain(bool release) { 147 | if (release) this.Release(); 148 | else this.Retain(); 149 | } 150 | 151 | /// 152 | /// All enabled instances of type T. 153 | /// 154 | public static IEnumerable InstancesOfType() where T : PowerProfile { 155 | return Instances.Where(i => i.GetType() == typeof(T)).Select(i => (T)i); 156 | } 157 | 158 | private void AddToStaticInstances() { 159 | if (_instances == null) _instances = new HashSet(); 160 | _instances.Add(this); 161 | } 162 | 163 | private void RemoveFromStaticInstances() { 164 | if (_instances == null) return; 165 | _instances.Remove(this); 166 | } 167 | 168 | #endregion <<---------- General ---------->> 169 | } 170 | } -------------------------------------------------------------------------------- /Legacy/Power Profiles/PowerProfile.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 44cec36499a9449319501230b661a1c1 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Legacy/Power Profiles/PowerProfileCombo.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using UnityEngine; 4 | 5 | #if UNITY_EDITOR 6 | using UnityEditor; 7 | using UnityEditorInternal; 8 | #endif 9 | 10 | namespace PWR.LowPowerMemoryConsumption { 11 | 12 | [Obsolete] 13 | public class PowerProfileCombo : PowerProfile { 14 | 15 | #region <<---------- Properties and Fields ---------->> 16 | 17 | [SerializeField][HideInInspector] private List _profiles; 18 | 19 | #endregion <<---------- Properties and Fields ---------->> 20 | 21 | 22 | 23 | 24 | #region <<---------- Callbacks ---------->> 25 | 26 | protected override void OnIsRetainedChanged(bool isRetained) { 27 | if (this._profiles == null) return; 28 | int count = this._profiles.Count; 29 | if (count <= 0) return; 30 | PowerProfile profile; 31 | for (int i = 0; i < count; i++) { 32 | profile = this._profiles[i]; 33 | if (profile == null) continue; 34 | if (profile == this) { 35 | Debug.LogError("[" + this.GetType().Name + "/" + this.name + "] recursive interation, this object is inside its own profile list", this); 36 | continue; 37 | } 38 | profile.RetainOrRelease(isRetained); 39 | } 40 | } 41 | 42 | #endregion <<---------- Callbacks ---------->> 43 | 44 | 45 | 46 | 47 | #region <<---------- Custom Inspector ---------->> 48 | #if UNITY_EDITOR 49 | [CustomEditor(typeof(PowerProfileCombo), true)] 50 | private class CustomInspector : Editor { 51 | private ReorderableList reordableProfiles; 52 | private void OnEnable() { 53 | this.reordableProfiles = new ReorderableList( 54 | this.serializedObject, 55 | this.serializedObject.FindProperty("_profiles"), 56 | true, 57 | true, 58 | true, 59 | true 60 | ); 61 | this.reordableProfiles.drawHeaderCallback = (position) => { 62 | EditorGUI.LabelField(position, "Profile List"); 63 | }; 64 | this.reordableProfiles.elementHeight = (EditorGUIUtility.singleLineHeight * 1f) + (EditorGUIUtility.standardVerticalSpacing * 2f) + 8f; 65 | this.reordableProfiles.drawElementCallback = (rect, index, isActive, isFocused) => { 66 | rect.y += (EditorGUIUtility.standardVerticalSpacing * 1f) + 4f; 67 | rect.height = EditorGUIUtility.singleLineHeight; 68 | EditorGUI.PropertyField(rect, this.reordableProfiles.serializedProperty.GetArrayElementAtIndex(index), GUIContent.none); 69 | }; 70 | } 71 | public override void OnInspectorGUI() { 72 | this.serializedObject.Update(); 73 | this.DrawDefaultInspector(); 74 | EditorGUI.BeginChangeCheck(); 75 | this.reordableProfiles.DoLayoutList(); 76 | if (EditorGUI.EndChangeCheck()) { 77 | this.serializedObject.ApplyModifiedProperties(); 78 | } 79 | } 80 | } 81 | #endif 82 | #endregion <<---------- Custom Inspector ---------->> 83 | } 84 | } -------------------------------------------------------------------------------- /Legacy/Power Profiles/PowerProfileCombo.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 3e8309ef88e694fc08292d5ff2af50ad 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Legacy/Power Profiles/PowerProfileFrameRate.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using UnityEngine; 3 | 4 | namespace PWR.LowPowerMemoryConsumption { 5 | 6 | [CreateAssetMenuAttribute(menuName="PWR/Power Profiles/Frame Rate",order=1001)] 7 | [Obsolete] 8 | public class PowerProfileFrameRate : PowerProfile { 9 | 10 | #region <<---------- Properties and Fields ---------->> 11 | 12 | [SerializeField] private FrameRateType _type; 13 | 14 | [SerializeField][Range(FrameRateRequest.MinRate, 120)] private int _rate = 30; 15 | 16 | /// 17 | /// Frame rate type. 18 | /// 19 | public FrameRateType Type { 20 | get { return this._type; } 21 | set { 22 | this._type = value; 23 | if (!Application.isPlaying || this._request.Type == this._type) return; 24 | this.OnIsRetainedChanged(this.IsRetained); 25 | } 26 | } 27 | 28 | /// 29 | /// Frame rate value. 30 | /// 31 | public int Rate { 32 | get { return this._rate; } 33 | set { 34 | this._rate = value; 35 | if (!Application.isPlaying || this._request.Rate == this._rate) return; 36 | this.OnIsRetainedChanged(this.IsRetained); 37 | } 38 | } 39 | 40 | private FrameRateRequest _request; 41 | 42 | #endregion <<---------- Properties and Fields ---------->> 43 | 44 | 45 | 46 | 47 | #region <<---------- SriptableObject ---------->> 48 | 49 | #if UNITY_EDITOR 50 | 51 | protected virtual void OnValidate() { 52 | if (!Application.isPlaying) return; 53 | this.OnIsRetainedChanged(this.IsRetained); 54 | } 55 | 56 | protected virtual void Reset() { 57 | if (!Application.isPlaying) return; 58 | this.OnIsRetainedChanged(this.IsRetained); 59 | } 60 | 61 | #endif 62 | 63 | #endregion <<---------- SriptableObject ---------->> 64 | 65 | 66 | 67 | 68 | #region <<---------- Callbacks ---------->> 69 | 70 | protected override void OnIsRetainedChanged(bool isRetained) { 71 | FrameRateManager.Instance.StopRequest(this._request); 72 | if (!isRetained) { 73 | this._request = FrameRateRequest.Invalid; 74 | return; 75 | } 76 | this._request = FrameRateManager.Instance.StartRequest(this._type, this._rate); 77 | } 78 | 79 | #endregion <<---------- Callbacks ---------->> 80 | } 81 | } -------------------------------------------------------------------------------- /Legacy/Power Profiles/PowerProfileFrameRate.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 352377d59db6544a4a590aed0c7ad548 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Legacy/Power Profiles/PowerProfileRenderInterval.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using UnityEngine; 3 | 4 | namespace PWR.LowPowerMemoryConsumption { 5 | 6 | [CreateAssetMenuAttribute(menuName="PWR/Power Profiles/Render Interval",order=1002)] 7 | [Obsolete] 8 | public class PowerProfileRenderInterval : PowerProfile { 9 | 10 | #region <<---------- Properties and Fields ---------->> 11 | 12 | [SerializeField] private RenderIntervalManagerPointer _managerPointer; 13 | 14 | [SerializeField][Range(RenderIntervalRequest.MinInterval, 60)] private int _interval = RenderIntervalRequest.MinInterval; 15 | 16 | /// 17 | /// Render interval value. 18 | /// 19 | public int Interval { 20 | get { return this._interval; } 21 | set { 22 | this._interval = value; 23 | if (!Application.isPlaying || this._request.Interval == this._interval) return; 24 | this.OnIsRetainedChanged(this.IsRetained); 25 | } 26 | } 27 | 28 | /// 29 | /// Manager pointer. 30 | /// 31 | public RenderIntervalManagerPointer ManagerPointer { 32 | get { 33 | if (this._managerPointer == null) { 34 | this._managerPointer = new RenderIntervalManagerPointer(); 35 | if (Application.isPlaying) { 36 | var mngr = this.ManagerPointer.GetManager(); 37 | int myManagerInstanceID = mngr == null ? -1 : mngr.GetInstanceID(); 38 | if (myManagerInstanceID != this._request.ManagerInstanceID) { 39 | this.OnIsRetainedChanged(this.IsRetained); 40 | } 41 | } 42 | } 43 | return this._managerPointer; 44 | } 45 | } 46 | 47 | private RenderIntervalRequest _request; 48 | 49 | #endregion <<---------- Properties and Fields ---------->> 50 | 51 | 52 | 53 | 54 | #region <<---------- SriptableObject ---------->> 55 | 56 | protected override void OnEnable() { 57 | base.OnEnable(); 58 | this.ManagerPointer.Changed += (pointer) => { 59 | if (!Application.isPlaying || this == null || !this.IsRequestValuesDifferentFromFields()) return; 60 | this.OnIsRetainedChanged(this.IsRetained); 61 | }; 62 | } 63 | 64 | #if UNITY_EDITOR 65 | 66 | protected virtual void OnValidate() { 67 | if (!Application.isPlaying) return; 68 | this.OnIsRetainedChanged(this.IsRetained); 69 | } 70 | 71 | protected virtual void Reset() { 72 | if (!Application.isPlaying) return; 73 | this.OnIsRetainedChanged(this.IsRetained); 74 | } 75 | 76 | #endif 77 | 78 | #endregion <<---------- SriptableObject ---------->> 79 | 80 | 81 | 82 | 83 | #region <<---------- Callbacks ---------->> 84 | 85 | protected override void OnIsRetainedChanged(bool isRetained) { 86 | var mngr = this.ManagerPointer.GetManager(); 87 | if (mngr == null) return; 88 | mngr.StopRequest(this._request); 89 | if (!isRetained) { 90 | this._request = RenderIntervalRequest.Invalid; 91 | return; 92 | } 93 | this._request = mngr.StartRequest(this._interval); 94 | } 95 | 96 | #endregion <<---------- Callbacks ---------->> 97 | 98 | 99 | 100 | 101 | #region <<---------- General ---------->> 102 | 103 | private bool IsRequestValuesDifferentFromFields() { 104 | if (this._request.Interval != this._interval) return true; 105 | var mngr = this.ManagerPointer.GetManager(); 106 | int myManagerInstanceID = mngr == null ? -1 : mngr.GetInstanceID(); 107 | return this._request.ManagerInstanceID != myManagerInstanceID; 108 | } 109 | 110 | #endregion <<---------- General ---------->> 111 | } 112 | } -------------------------------------------------------------------------------- /Legacy/Power Profiles/PowerProfileRenderInterval.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: b15bb7f47fc1342bdb9f6e31075255fe 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Legacy/Render Interval.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 34d9875c3bfda4872a6d81e3454fb014 3 | folderAsset: yes 4 | timeCreated: 1534968666 5 | licenseType: Pro 6 | DefaultImporter: 7 | externalObjects: {} 8 | userData: 9 | assetBundleName: 10 | assetBundleVariant: 11 | -------------------------------------------------------------------------------- /Legacy/Render Interval/RenderIntervalManager.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using UnityEngine; 3 | using UniRate; 4 | 5 | namespace PWR.LowPowerMemoryConsumption { 6 | 7 | [DisallowMultipleComponent] 8 | [Obsolete("OBSOLETE, use RateManager inside UniRate namespace instead.")] 9 | public class RenderIntervalManager : MonoBehaviour { 10 | 11 | #region <<---------- Initializers ---------->> 12 | 13 | protected RenderIntervalManager() { } 14 | 15 | #endregion <<---------- Initializers ---------->> 16 | 17 | 18 | 19 | 20 | #region <<---------- Properties and Fields ---------->> 21 | 22 | [Obsolete("OBSOLETE, use RateManager.Instance.MaximumRenderInterval instead.")] 23 | public int FallbackRenderInterval { 24 | get => RateManager.Instance.MaximumRenderInterval; 25 | set => RateManager.Instance.MaximumRenderInterval = value; 26 | } 27 | 28 | [Obsolete("OBSOLETE, use RateManager.Instance.RenderInterval.Current instead.")] 29 | public int RenderInterval => RateManager.Instance.RenderInterval.Current; 30 | 31 | [Obsolete("OBSOLETE, use RateManager.Instance.WillRender instead.")] 32 | public bool IsRendering => RateManager.Instance.WillRender; 33 | 34 | [Obsolete("OBSOLETE, use RateManager.Instance.RenderIntervalChanged instead.")] 35 | public event Action RenderIntervalChanged { 36 | add { 37 | this._renderIntervalChanged -= value; 38 | this._renderIntervalChanged += value; 39 | } 40 | remove { 41 | this._renderIntervalChanged -= value; 42 | } 43 | } 44 | private Action _renderIntervalChanged; 45 | 46 | [Obsolete(null, true)] 47 | public event Action IsRenderingChanged { 48 | add { } 49 | remove { } 50 | } 51 | 52 | #endregion <<---------- Properties and Fields ---------->> 53 | 54 | 55 | 56 | 57 | #region <<---------- MonoBehaviour ---------->> 58 | 59 | protected virtual void Awake() { 60 | RateManager.Instance.RenderIntervalChanged += this.OnRenderIntervalChanged; 61 | } 62 | 63 | protected virtual void OnDestroy() { 64 | var rateManager = RateManager.Instance; 65 | if (rateManager == null) return; 66 | rateManager.RenderIntervalChanged -= this.OnRenderIntervalChanged; 67 | } 68 | 69 | #endregion <<---------- MonoBehaviour ---------->> 70 | 71 | 72 | 73 | 74 | #region <<---------- Callbacks ---------->> 75 | 76 | private void OnRenderIntervalChanged(RateManager manager, int interval) { 77 | var e = this._renderIntervalChanged; 78 | if (e == null) return; 79 | e(this, interval); 80 | } 81 | 82 | #endregion <<---------- Callbacks ---------->> 83 | 84 | 85 | 86 | 87 | #region <<---------- Requests Management ---------->> 88 | 89 | [Obsolete("OBSOLETE, use RateManager.Instance.RequestRenderInterval() instead")] 90 | public RenderIntervalRequest StartRequest(int interval) { 91 | if (interval <= 0) return RenderIntervalRequest.Invalid; 92 | var request = RateManager.Instance.RequestRenderInterval(interval); 93 | if (request == null) return RenderIntervalRequest.Invalid; 94 | return new RenderIntervalRequest(request); 95 | } 96 | 97 | public void StopRequest(RenderIntervalRequest request) { 98 | if (request.UniRateRequest == null || request.UniRateRequest.IsDisposed) return; 99 | request.UniRateRequest.Dispose(); 100 | } 101 | 102 | #endregion <<---------- Requests Management ---------->> 103 | } 104 | } -------------------------------------------------------------------------------- /Legacy/Render Interval/RenderIntervalManager.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: b7a2f92d5b1114a2ba21d54ae7b463f1 3 | timeCreated: 1535564693 4 | licenseType: Pro 5 | MonoImporter: 6 | externalObjects: {} 7 | serializedVersion: 2 8 | defaultReferences: [] 9 | executionOrder: 0 10 | icon: {instanceID: 0} 11 | userData: 12 | assetBundleName: 13 | assetBundleVariant: 14 | -------------------------------------------------------------------------------- /Legacy/Render Interval/RenderIntervalManagerPointer.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using UnityEngine; 3 | 4 | #if UNITY_EDITOR 5 | using UnityEditor; 6 | #endif 7 | 8 | namespace PWR.LowPowerMemoryConsumption { 9 | 10 | [Serializable] 11 | [Obsolete] 12 | public class RenderIntervalManagerPointer { 13 | 14 | #region <<---------- Properties and Fields ---------->> 15 | 16 | [SerializeField] private bool _byReference = true; 17 | 18 | [SerializeField] private string _identifier; 19 | 20 | [SerializeField] private RenderIntervalManager _reference; 21 | 22 | /// 23 | /// Event raised when any field change. 24 | /// 25 | public event Action Changed { 26 | add { 27 | this._changed -= value; 28 | this._changed += value; 29 | } 30 | remove { 31 | this._changed -= value; 32 | } 33 | } 34 | private Action _changed; 35 | 36 | /// 37 | /// Access manager by referece or by identifier? 38 | /// 39 | public bool ByReference { 40 | get { return this._byReference; } 41 | set { 42 | if (this._byReference == value) return; 43 | this._byReference = value; 44 | this.OnChanged(); 45 | } 46 | } 47 | 48 | /// 49 | /// Manager by reference. 50 | /// 51 | public RenderIntervalManager ManagerByReference { 52 | get { return this._reference; } 53 | set { 54 | if (this._reference == value) return; 55 | this._reference = value; 56 | this.OnChanged(); 57 | } 58 | } 59 | 60 | /// 61 | /// Manager by identifier. 62 | /// 63 | public string ManagerByIdentifier { 64 | get { return this._identifier; } 65 | set { 66 | if (this._identifier == value) return; 67 | this._identifier = value; 68 | this.OnChanged(); 69 | } 70 | } 71 | 72 | #endregion <<---------- Properties and Fields ---------->> 73 | 74 | 75 | 76 | 77 | #region <<---------- Callbacks ---------->> 78 | 79 | protected virtual void OnChanged() { 80 | if (this._changed == null) return; 81 | this._changed(this); 82 | } 83 | 84 | #endregion <<---------- Callbacks ---------->> 85 | 86 | 87 | 88 | 89 | #region <<---------- General ---------->> 90 | 91 | public RenderIntervalManager GetManager() => null; 92 | 93 | #endregion <<---------- General ---------->> 94 | 95 | 96 | 97 | 98 | #region <<---------- Custom Drawer ---------->> 99 | #if UNITY_EDITOR 100 | [CustomPropertyDrawer(typeof(RenderIntervalManagerPointer), true)] 101 | private class MyCustomDrawer : PropertyDrawer { 102 | private SerializedProperty GetPropByRef(SerializedProperty property) { 103 | return property.FindPropertyRelative("_byReference"); 104 | } 105 | private SerializedProperty GetPropRef(SerializedProperty property) { 106 | return property.FindPropertyRelative("_reference"); 107 | } 108 | private SerializedProperty GetPropId(SerializedProperty property) { 109 | return property.FindPropertyRelative("_identifier"); 110 | } 111 | public override float GetPropertyHeight(SerializedProperty property, GUIContent label) { 112 | int lines = 0; 113 | //label 114 | if (label != GUIContent.none && !string.IsNullOrEmpty(label.text)) lines += 1; 115 | //toggle 116 | lines += 1; 117 | 118 | var propByRef = this.GetPropByRef(property); 119 | //id 120 | if (!propByRef.boolValue || propByRef.hasMultipleDifferentValues) lines += 1; 121 | //ref 122 | if (propByRef.boolValue || propByRef.hasMultipleDifferentValues) lines += 1; 123 | 124 | return ((float)lines * EditorGUIUtility.singleLineHeight) + ((float)(lines - 1) * EditorGUIUtility.standardVerticalSpacing); 125 | } 126 | public override void OnGUI(Rect position, SerializedProperty property, GUIContent label) { 127 | label = EditorGUI.BeginProperty(position, label, property); 128 | 129 | var rectLine = position; 130 | rectLine.height = EditorGUIUtility.singleLineHeight; 131 | 132 | //label 133 | if (label != GUIContent.none && !string.IsNullOrEmpty(label.text)) { 134 | EditorGUI.PrefixLabel(rectLine, GUIUtility.GetControlID(FocusType.Passive), label); 135 | rectLine.y += rectLine.height + EditorGUIUtility.standardVerticalSpacing; 136 | } 137 | 138 | int originalIndent = EditorGUI.indentLevel; 139 | EditorGUI.indentLevel += 1; 140 | 141 | //toggle 142 | var propByRef = this.GetPropByRef(property); 143 | EditorGUI.BeginChangeCheck(); 144 | if (propByRef.hasMultipleDifferentValues) { 145 | EditorGUI.PropertyField(rectLine, propByRef, new GUIContent("by Reference")); 146 | } 147 | else { 148 | propByRef.boolValue = EditorGUI.ToggleLeft(rectLine, "by Reference", propByRef.boolValue); 149 | } 150 | if (EditorGUI.EndChangeCheck()) { 151 | property.serializedObject.ApplyModifiedProperties(); 152 | } 153 | rectLine.y += rectLine.height + EditorGUIUtility.standardVerticalSpacing; 154 | 155 | //id 156 | if (!propByRef.boolValue || propByRef.hasMultipleDifferentValues) { 157 | EditorGUI.BeginChangeCheck(); 158 | EditorGUI.PropertyField(rectLine, this.GetPropId(property)); 159 | if (EditorGUI.EndChangeCheck()) { 160 | property.serializedObject.ApplyModifiedProperties(); 161 | } 162 | rectLine.y += rectLine.height + EditorGUIUtility.standardVerticalSpacing; 163 | } 164 | 165 | //ref 166 | if (propByRef.boolValue || propByRef.hasMultipleDifferentValues) { 167 | EditorGUI.BeginChangeCheck(); 168 | EditorGUI.PropertyField(rectLine, this.GetPropRef(property)); 169 | if (EditorGUI.EndChangeCheck()) { 170 | property.serializedObject.ApplyModifiedProperties(); 171 | } 172 | } 173 | 174 | EditorGUI.indentLevel = originalIndent; 175 | EditorGUI.EndProperty(); 176 | } 177 | } 178 | #endif 179 | #endregion <<---------- Custom Drawer ---------->> 180 | } 181 | } -------------------------------------------------------------------------------- /Legacy/Render Interval/RenderIntervalManagerPointer.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 91adeb734d0584a6d886ab6f5369d0a5 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Legacy/Render Interval/RenderIntervalRequest.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace PWR.LowPowerMemoryConsumption { 4 | 5 | [Obsolete] 6 | public struct RenderIntervalRequest { 7 | 8 | #region <<---------- Initializers ---------->> 9 | 10 | public RenderIntervalRequest(UniRate.RenderIntervalRequest request) { 11 | this._interval = 0; 12 | this._managerInstanceID = -1; 13 | this._request = request; 14 | if (request == null) return; 15 | this._interval = request.RenderInterval; 16 | } 17 | 18 | #endregion <<---------- Initializers ---------->> 19 | 20 | 21 | 22 | 23 | #region <<---------- Properties and Fields ---------->> 24 | 25 | public UniRate.RenderIntervalRequest UniRateRequest => this._request; 26 | private readonly UniRate.RenderIntervalRequest _request; 27 | 28 | public int ManagerInstanceID => this._managerInstanceID; 29 | private readonly int _managerInstanceID; 30 | 31 | public int Interval => this._interval; 32 | private readonly int _interval; 33 | 34 | public bool IsValid => (this._interval >= MinInterval && this._request != null); 35 | 36 | public const int MinInterval = 1; 37 | 38 | public static readonly RenderIntervalRequest Invalid = new RenderIntervalRequest(null); 39 | 40 | #endregion <<---------- Properties and Fields ---------->> 41 | 42 | 43 | 44 | 45 | #region <<---------- General ---------->> 46 | 47 | public RenderIntervalManager FindManager() => null; 48 | 49 | #endregion <<---------- General ---------->> 50 | } 51 | } -------------------------------------------------------------------------------- /Legacy/Render Interval/RenderIntervalRequest.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 254f766ba6b7e4fcfb0a95fb4a8f0ff4 3 | timeCreated: 1535564693 4 | licenseType: Pro 5 | MonoImporter: 6 | externalObjects: {} 7 | serializedVersion: 2 8 | defaultReferences: [] 9 | executionOrder: 0 10 | icon: {instanceID: 0} 11 | userData: 12 | assetBundleName: 13 | assetBundleVariant: 14 | -------------------------------------------------------------------------------- /Legacy/Render Interval/RenderIntervalRequestComponent.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using UnityEngine; 3 | 4 | namespace PWR.LowPowerMemoryConsumption { 5 | 6 | [Obsolete("OBSOLETE, use RateRequestWhileEnabledComponent instead")] 7 | public class RenderIntervalRequestComponent : MonoBehaviour { 8 | 9 | #region <<---------- Initializers ---------->> 10 | 11 | protected RenderIntervalRequestComponent() { } 12 | 13 | #endregion <<---------- Initializers ---------->> 14 | 15 | 16 | 17 | 18 | #region <<---------- Properties and Fields ---------->> 19 | 20 | [SerializeField] private RenderIntervalManagerPointer _managerPointer; 21 | 22 | [SerializeField][Range(RenderIntervalRequest.MinInterval, 60)] private int _interval = RenderIntervalRequest.MinInterval; 23 | 24 | /// 25 | /// Render interval value. 26 | /// 27 | public int Interval { 28 | get { return this._interval; } 29 | set { 30 | this._interval = value; 31 | if (!Application.isPlaying || !this.IsRequestValuesDifferentFromFields()) return; 32 | this.AssertCurrentRequestRunning(this.isActiveAndEnabled); 33 | } 34 | } 35 | 36 | /// 37 | /// Manager pointer. 38 | /// 39 | public RenderIntervalManagerPointer ManagerPointer { 40 | get { 41 | if (this._managerPointer == null) { 42 | this._managerPointer = new RenderIntervalManagerPointer(); 43 | if (Application.isPlaying && this.IsRequestValuesDifferentFromFields()) { 44 | this.AssertCurrentRequestRunning(this.isActiveAndEnabled); 45 | } 46 | } 47 | return this._managerPointer; 48 | } 49 | } 50 | 51 | private RenderIntervalRequest _request; 52 | 53 | private bool _isApplicationQuitting = false; 54 | 55 | #endregion <<---------- Properties and Fields ---------->> 56 | 57 | 58 | 59 | 60 | #region <<---------- MonoBehaviour ---------->> 61 | 62 | protected virtual void Awake() { 63 | this.ManagerPointer.Changed += (pointer) => { 64 | if (!Application.isPlaying || this == null || !this.IsRequestValuesDifferentFromFields()) return; 65 | this.AssertCurrentRequestRunning(this.isActiveAndEnabled); 66 | }; 67 | } 68 | 69 | protected virtual void OnEnable() { 70 | this.AssertCurrentRequestRunning(true); 71 | } 72 | 73 | protected virtual void OnDisable() { 74 | if (this._isApplicationQuitting) return; 75 | this.AssertCurrentRequestRunning(false); 76 | } 77 | 78 | protected virtual void OnApplicationQuit() { 79 | this._isApplicationQuitting = true; 80 | } 81 | 82 | #if UNITY_EDITOR 83 | protected virtual void OnValidate() { 84 | if (!Application.isPlaying) return; 85 | this.AssertCurrentRequestRunning(this.isActiveAndEnabled); 86 | } 87 | protected virtual void OnReset() { 88 | if (!Application.isPlaying) return; 89 | this.AssertCurrentRequestRunning(this.isActiveAndEnabled); 90 | } 91 | #endif 92 | 93 | #endregion <<---------- MonoBehaviour ---------->> 94 | 95 | 96 | 97 | 98 | #region <<---------- General ---------->> 99 | 100 | private void AssertCurrentRequestRunning(bool running) { 101 | var mngr = this.ManagerPointer.GetManager(); 102 | if (mngr == null) return; 103 | mngr.StopRequest(this._request); 104 | if (!running) { 105 | this._request = RenderIntervalRequest.Invalid; 106 | return; 107 | } 108 | this._request = mngr.StartRequest(this._interval); 109 | } 110 | 111 | private bool IsRequestValuesDifferentFromFields() { 112 | if (this._request.Interval != this._interval) return true; 113 | var mngr = this.ManagerPointer.GetManager(); 114 | int myManagerInstanceID = mngr == null ? -1 : mngr.GetInstanceID(); 115 | return this._request.ManagerInstanceID != myManagerInstanceID; 116 | } 117 | 118 | #endregion <<---------- General ---------->> 119 | } 120 | } -------------------------------------------------------------------------------- /Legacy/Render Interval/RenderIntervalRequestComponent.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: b7a337e31f770407fac5a8d7a24367f8 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Legacy/Render Interval/RenderIntervalRequester.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace PWR.LowPowerMemoryConsumption { 4 | 5 | [Obsolete("OBSOLETE, use RateRequestWhileEnabledComponent instead")] 6 | public class RenderIntervalRequester : RenderIntervalRequestComponent { 7 | 8 | #region <<---------- Initializers ---------->> 9 | 10 | protected RenderIntervalRequester() { } 11 | 12 | #endregion <<---------- Initializers ---------->> 13 | } 14 | } -------------------------------------------------------------------------------- /Legacy/Render Interval/RenderIntervalRequester.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: cef5e52f037b54908bcc587756181cba 3 | timeCreated: 1535564693 4 | licenseType: Pro 5 | MonoImporter: 6 | externalObjects: {} 7 | serializedVersion: 2 8 | defaultReferences: [] 9 | executionOrder: 0 10 | icon: {instanceID: 0} 11 | userData: 12 | assetBundleName: 13 | assetBundleVariant: 14 | -------------------------------------------------------------------------------- /Legacy/Render Interval/RenderIntervalTrigger.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using UnityEngine; 3 | 4 | namespace PWR.LowPowerMemoryConsumption { 5 | 6 | [Obsolete] 7 | public class RenderIntervalTrigger : MonoBehaviour { 8 | 9 | #region <<---------- Properties and Fields ---------->> 10 | 11 | [SerializeField] private RenderIntervalManagerPointer _managerPointer; 12 | 13 | [SerializeField] private UnityEventInt _renderIntervalChanged; 14 | 15 | [SerializeField] private UnityEventBool _isRenderingChanged; 16 | 17 | /// 18 | /// Event raised when render interval changes. 19 | /// 20 | public UnityEventInt RenderIntervalChanged { 21 | get { 22 | if (this._renderIntervalChanged == null) { 23 | this._renderIntervalChanged = new UnityEventInt(); 24 | } 25 | return this._renderIntervalChanged; 26 | } 27 | } 28 | 29 | /// 30 | /// Event raised when is rendering changes. 31 | /// 32 | public UnityEventBool IsRenderingChanged { 33 | get { 34 | if (this._isRenderingChanged == null) { 35 | this._isRenderingChanged = new UnityEventBool(); 36 | } 37 | return this._isRenderingChanged; 38 | } 39 | } 40 | 41 | /// 42 | /// Render interval manager to listen. 43 | /// 44 | public RenderIntervalManagerPointer ManagerPointer { 45 | get { 46 | if (this._managerPointer == null) { 47 | this._managerPointer = new RenderIntervalManagerPointer(); 48 | this.NotifyAllEventsIfActiveEnabledPlaying(); 49 | this.StartListeningIfActiveEnabledPlaying(); 50 | } 51 | return this._managerPointer; 52 | } 53 | } 54 | 55 | private bool _isApplicationQuitting = false; 56 | 57 | #endregion <<---------- Properties and Fields ---------->> 58 | 59 | 60 | 61 | 62 | #region <<---------- MonoBehaviour ---------->> 63 | 64 | protected virtual void Awake() { 65 | this.ManagerPointer.Changed += (pointer) => { 66 | if (this == null) return; 67 | this.NotifyAllEventsIfActiveEnabledPlaying(); 68 | this.StartListeningIfActiveEnabledPlaying(); 69 | }; 70 | } 71 | 72 | protected virtual void OnEnable() { 73 | this.NotifyAllEvents(); 74 | this.StartListeningIfActiveEnabledPlaying(); 75 | } 76 | 77 | protected virtual void OnDisable() { 78 | if (this._isApplicationQuitting || this._managerPointer == null) return; 79 | var mngr = this._managerPointer.GetManager(); 80 | if (mngr == null) return; 81 | 82 | mngr.RenderIntervalChanged -= this.OnRenderIntervalChanged; 83 | mngr.IsRenderingChanged -= this.OnIsRenderingChanged; 84 | } 85 | 86 | protected virtual void OnApplicationQuit() { 87 | this._isApplicationQuitting = true; 88 | } 89 | 90 | #if UNITY_EDITOR 91 | protected virtual void OnValidate() { 92 | this.NotifyAllEventsIfActiveEnabledPlaying(); 93 | this.StartListeningIfActiveEnabledPlaying(); 94 | } 95 | #endif 96 | 97 | #endregion <<---------- MonoBehaviour ---------->> 98 | 99 | 100 | 101 | 102 | #region <<---------- General ---------->> 103 | 104 | private void NotifyAllEventsIfActiveEnabledPlaying() { 105 | if (!this.isActiveAndEnabled) return; 106 | #if UNITY_EDITOR 107 | if (!Application.isPlaying) return; 108 | #endif 109 | this.NotifyAllEvents(); 110 | } 111 | 112 | private void NotifyAllEvents() { 113 | RenderIntervalManager mngr = null; 114 | if (this._managerPointer != null) { 115 | mngr = this._managerPointer.GetManager(); 116 | } 117 | this.OnRenderIntervalChanged(mngr); 118 | this.OnIsRenderingChanged(mngr); 119 | } 120 | 121 | protected void StartListeningIfActiveEnabledPlaying() { 122 | if (!this.isActiveAndEnabled || this._managerPointer == null) return; 123 | #if UNITY_EDITOR 124 | if (!Application.isPlaying) return; 125 | #endif 126 | var mngr = this._managerPointer.GetManager(); 127 | mngr.RenderIntervalChanged += this.OnRenderIntervalChanged; 128 | mngr.IsRenderingChanged += this.OnIsRenderingChanged; 129 | } 130 | 131 | protected void OnIsRenderingChanged(RenderIntervalManager myManager) { 132 | if (myManager == null) { 133 | this.OnIsRenderingChanged(null, false); 134 | return; 135 | } 136 | this.OnIsRenderingChanged(myManager, myManager.IsRendering); 137 | } 138 | protected virtual void OnIsRenderingChanged(RenderIntervalManager manager, bool isRendering) { 139 | RenderIntervalManager mngr = null; 140 | if (this._managerPointer != null) { 141 | mngr = this._managerPointer.GetManager(); 142 | } 143 | 144 | if (mngr == null || mngr != manager) { 145 | if (manager != null) { 146 | manager.IsRenderingChanged -= this.OnIsRenderingChanged; 147 | } 148 | return; 149 | } 150 | if (this._isRenderingChanged != null) this._isRenderingChanged.Invoke(isRendering); 151 | } 152 | 153 | protected void OnRenderIntervalChanged(RenderIntervalManager myManager) { 154 | if (myManager == null) { 155 | this.OnRenderIntervalChanged(null, RenderIntervalRequest.MinInterval); 156 | return; 157 | } 158 | this.OnRenderIntervalChanged(myManager, myManager.RenderInterval); 159 | } 160 | protected virtual void OnRenderIntervalChanged(RenderIntervalManager manager, int interval) { 161 | RenderIntervalManager mngr = null; 162 | if (this._managerPointer != null) { 163 | mngr = this._managerPointer.GetManager(); 164 | } 165 | 166 | if (mngr == null || mngr != manager) { 167 | if (manager != null) { 168 | manager.RenderIntervalChanged -= this.OnRenderIntervalChanged; 169 | } 170 | return; 171 | } 172 | if (this._renderIntervalChanged != null) this._renderIntervalChanged.Invoke(interval); 173 | } 174 | 175 | #endregion <<---------- General ---------->> 176 | 177 | 178 | 179 | 180 | #region <<---------- Legacy Support ---------->> 181 | 182 | // ObsoletedWarning 2019/05/09 - ObsoletedError 2019/05/09 183 | [System.Obsolete("use ManagerPointer instead", true)] 184 | public RenderIntervalManager Manager { 185 | get { return this.ManagerPointer.ManagerByReference; } 186 | set { 187 | this.ManagerPointer.ManagerByReference = value; 188 | this.StartListeningIfActiveEnabledPlaying(); 189 | } 190 | } 191 | 192 | #endregion <<---------- Legacy Support ---------->> 193 | } 194 | } -------------------------------------------------------------------------------- /Legacy/Render Interval/RenderIntervalTrigger.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: f76eae0c6f66c48889c7fa2c52795cd1 3 | timeCreated: 1535564693 4 | licenseType: Pro 5 | MonoImporter: 6 | externalObjects: {} 7 | serializedVersion: 2 8 | defaultReferences: [] 9 | executionOrder: 0 10 | icon: {instanceID: 0} 11 | userData: 12 | assetBundleName: 13 | assetBundleVariant: 14 | -------------------------------------------------------------------------------- /Legacy/UniRate.Legacy.asmdef: -------------------------------------------------------------------------------- 1 | { 2 | "name": "UniRate.Legacy", 3 | "references": [ 4 | "UniRate" 5 | ], 6 | "includePlatforms": [], 7 | "excludePlatforms": [], 8 | "allowUnsafeCode": false, 9 | "overrideReferences": false, 10 | "precompiledReferences": [], 11 | "autoReferenced": true, 12 | "defineConstraints": [], 13 | "versionDefines": [], 14 | "noEngineReferences": false 15 | } -------------------------------------------------------------------------------- /Legacy/UniRate.Legacy.asmdef.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 6b952becdd5da4539900efc4b3eebd54 3 | AssemblyDefinitionImporter: 4 | externalObjects: {} 5 | userData: 6 | assetBundleName: 7 | assetBundleVariant: 8 | -------------------------------------------------------------------------------- /README.md.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 29a08608f4b7942828835b9e2f859080 3 | timeCreated: 1534017037 4 | licenseType: Free 5 | TextScriptImporter: 6 | externalObjects: {} 7 | userData: 8 | assetBundleName: 9 | assetBundleVariant: 10 | -------------------------------------------------------------------------------- /Runtime.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 31a295a13a8aa4bf1acec399c0087f50 3 | folderAsset: yes 4 | DefaultImporter: 5 | externalObjects: {} 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Runtime/Components.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 1c8673a0158ab43d0aaec2a5afd1d3ce 3 | folderAsset: yes 4 | DefaultImporter: 5 | externalObjects: {} 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Runtime/Components/RateRequestAnimationComponent.cs: -------------------------------------------------------------------------------- 1 | using UnityEngine; 2 | 3 | #if UNITY_2021_1_OR_NEWER 4 | using UnityApplication = UnityEngine.Device.Application; 5 | #else 6 | using UnityApplication = UnityEngine.Application; 7 | #endif 8 | 9 | namespace UniRate { 10 | 11 | [RequireComponent(typeof(Animation))] 12 | public class RateRequestAnimationComponent : RateRequestComponent { 13 | 14 | #region <<---------- Properties and Fields ---------->> 15 | 16 | [SerializeField] [HideInInspector] private string _clipName; 17 | 18 | private Animation _animation; 19 | 20 | #endregion <<---------- Properties and Fields ---------->> 21 | 22 | 23 | 24 | 25 | #region <<---------- MonoBehaviour ---------->> 26 | 27 | protected override void Awake() { 28 | base.Awake(); 29 | this._animation = this.GetComponent(); 30 | } 31 | 32 | private void OnEnable() { 33 | this.ShouldActivateRequests = this.GetIsAnimationPlaying(this._animation, this._clipName); 34 | } 35 | 36 | private void Update() { 37 | this.ShouldActivateRequests = this.GetIsAnimationPlaying(this._animation, this._clipName); 38 | this.StopRequestsIfDelayed(); 39 | } 40 | 41 | #if UNITY_EDITOR 42 | protected override void OnValidate() { 43 | if (UnityApplication.isPlaying && this.isActiveAndEnabled && this.Manager != null) { 44 | this.ShouldActivateRequests = this.GetIsAnimationPlaying(this._animation, this._clipName); 45 | } 46 | base.OnValidate(); 47 | } 48 | #endif 49 | 50 | #endregion <<---------- MonoBehaviour ---------->> 51 | 52 | 53 | 54 | 55 | #region <<---------- General ---------->> 56 | 57 | private bool GetIsAnimationPlaying(Animation animation, string clipName) { 58 | if (!animation.isActiveAndEnabled) return false; 59 | if (string.IsNullOrEmpty(clipName)) { 60 | return animation.isPlaying; 61 | } 62 | return animation.IsPlaying(clipName); 63 | } 64 | 65 | #endregion <<---------- General ---------->> 66 | } 67 | } -------------------------------------------------------------------------------- /Runtime/Components/RateRequestAnimationComponent.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: c47ef96e85c8e462cbfc2665b61fd8af 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Runtime/Components/RateRequestAnimatorComponent.cs: -------------------------------------------------------------------------------- 1 | using UnityEngine; 2 | 3 | #if UNITY_2021_1_OR_NEWER 4 | using UnityApplication = UnityEngine.Device.Application; 5 | #else 6 | using UnityApplication = UnityEngine.Application; 7 | #endif 8 | 9 | namespace UniRate { 10 | 11 | [RequireComponent(typeof(Animator))] 12 | public class RateRequestAnimatorComponent : RateRequestComponent { 13 | 14 | #region <<---------- Properties and Fields ---------->> 15 | 16 | [SerializeField] [HideInInspector] private bool _activateRequestsInTransitions = true; 17 | [SerializeField] [HideInInspector] private string _layerName; 18 | [SerializeField] [HideInInspector] private string _stateName; 19 | 20 | private (int hash, bool hasHash) _stateInfo; 21 | private Animator _animator; 22 | 23 | #endregion <<---------- Properties and Fields ---------->> 24 | 25 | 26 | 27 | 28 | #region <<---------- MonoBehaviour ---------->> 29 | 30 | protected override void Awake() { 31 | base.Awake(); 32 | this._animator = this.GetComponent(); 33 | this._stateInfo = this.GetStateInfo(this._stateName); 34 | } 35 | 36 | private void OnEnable() { 37 | this.ShouldActivateRequests = this.GetIsAnimatorPlayingOrInTransition( 38 | this._animator, 39 | this._layerName, 40 | this._stateInfo.hash, 41 | this._stateInfo.hasHash, 42 | this._activateRequestsInTransitions 43 | ); 44 | } 45 | 46 | private void Update() { 47 | this.ShouldActivateRequests = this.GetIsAnimatorPlayingOrInTransition( 48 | this._animator, 49 | this._layerName, 50 | this._stateInfo.hash, 51 | this._stateInfo.hasHash, 52 | this._activateRequestsInTransitions 53 | ); 54 | this.StopRequestsIfDelayed(); 55 | } 56 | 57 | #if UNITY_EDITOR 58 | protected override void OnValidate() { 59 | if (UnityApplication.isPlaying) { 60 | this._stateInfo = this.GetStateInfo(this._stateName); 61 | } 62 | if (UnityApplication.isPlaying && !this.isActiveAndEnabled && this.Manager != null) { 63 | this.ShouldActivateRequests = this.GetIsAnimatorPlayingOrInTransition( 64 | this._animator, 65 | this._layerName, 66 | this._stateInfo.hash, 67 | this._stateInfo.hasHash, 68 | this._activateRequestsInTransitions 69 | ); 70 | } 71 | base.OnValidate(); 72 | } 73 | #endif 74 | 75 | #endregion <<---------- MonoBehaviour ---------->> 76 | 77 | 78 | 79 | 80 | #region <<---------- General ---------->> 81 | 82 | private (int hash, bool hasHash) GetStateInfo(string stateName) { 83 | bool hasStateName = !string.IsNullOrEmpty(stateName); 84 | return ( 85 | (hasStateName ? Animator.StringToHash(stateName) : 0), 86 | hasStateName 87 | ); 88 | } 89 | 90 | private bool GetIsAnimatorInTransitionAtLayer(Animator animator, int layerIndex) { 91 | return animator.IsInTransition(layerIndex); 92 | } 93 | 94 | private bool GetIsAnimatorPlayingInStateAtLayer(Animator animator, int layerIndex, int stateHash, bool hasStateHash) { 95 | var stateInfo = animator.GetCurrentAnimatorStateInfo(layerIndex); 96 | if (stateInfo.speed == 0f || stateInfo.speedMultiplier == 0f) return false; 97 | if (hasStateHash && stateInfo.shortNameHash != stateHash) return false; 98 | return (stateInfo.loop || stateInfo.normalizedTime < 1f); 99 | } 100 | 101 | private bool GetIsAnimatorPlayingOrInTransition(Animator animator, string layerName, int stateHash, bool hasStateHash, bool activateRequestsInTransitions) { 102 | if (!animator.isActiveAndEnabled || animator.speed == 0f) return false; 103 | 104 | if (!string.IsNullOrEmpty(layerName)) { 105 | int layerIndex = animator.GetLayerIndex(layerName); 106 | if (layerIndex >= 0) { 107 | if (activateRequestsInTransitions && this.GetIsAnimatorInTransitionAtLayer(animator, layerIndex)) return true; 108 | if (this.GetIsAnimatorPlayingInStateAtLayer(animator, layerIndex, stateHash, hasStateHash)) return true; 109 | } 110 | } 111 | else { 112 | for (int layerIndex = animator.layerCount - 1; layerIndex >= 0; layerIndex--) { 113 | if (activateRequestsInTransitions && this.GetIsAnimatorInTransitionAtLayer(animator, layerIndex)) return true; 114 | if (this.GetIsAnimatorPlayingInStateAtLayer(animator, layerIndex, stateHash, hasStateHash)) return true; 115 | } 116 | } 117 | 118 | return false; 119 | } 120 | 121 | #endregion <<---------- General ---------->> 122 | } 123 | } -------------------------------------------------------------------------------- /Runtime/Components/RateRequestAnimatorComponent.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: aa03a3f6c8a5c4a588acdfad430e9bf2 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Runtime/Components/RateRequestComponent.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: f3cbee4061e7744d0a90eac5fe2db7cf 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Runtime/Components/RateRequestInputFieldComponent.cs: -------------------------------------------------------------------------------- 1 | using UnityEngine; 2 | using UnityEngine.UI; 3 | 4 | namespace UniRate { 5 | 6 | [RequireComponent(typeof(InputField))] 7 | public class RateRequestInputFieldComponent : RateRequestComponent { 8 | 9 | #region <<---------- Properties and Fields ---------->> 10 | 11 | private InputField _inputField; 12 | 13 | #endregion <<---------- Properties and Fields ---------->> 14 | 15 | 16 | 17 | 18 | #region <<---------- MonoBehaviour ---------->> 19 | 20 | protected override void Awake() { 21 | base.Awake(); 22 | this._inputField = this.GetComponent(); 23 | } 24 | 25 | private void OnEnable() { 26 | this._inputField.onEndEdit.AddListener(this.OnInputFieldEndEdit); 27 | this._inputField.onValueChanged.AddListener(this.OnInputFieldValueChanged); 28 | this.ShouldActivateRequests = this._inputField.isFocused; 29 | } 30 | 31 | private void Update() { 32 | this.ShouldActivateRequests = this._inputField.isFocused; 33 | this.StopRequestsIfDelayed(); 34 | } 35 | 36 | protected override void OnDisable() { 37 | this._inputField.onEndEdit.RemoveListener(this.OnInputFieldEndEdit); 38 | this._inputField.onValueChanged.RemoveListener(this.OnInputFieldValueChanged); 39 | base.OnDisable(); 40 | } 41 | 42 | #endregion <<---------- MonoBehaviour ---------->> 43 | 44 | 45 | 46 | 47 | #region <<---------- Callbacks ---------->> 48 | 49 | private void OnInputFieldEndEdit(string value) { 50 | this.ShouldActivateRequests = false; 51 | } 52 | 53 | private void OnInputFieldValueChanged(string value) { 54 | this.ShouldActivateRequests = true; 55 | } 56 | 57 | #endregion <<---------- Callbacks ---------->> 58 | } 59 | } -------------------------------------------------------------------------------- /Runtime/Components/RateRequestInputFieldComponent.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 3548020e712344200b51c36afa1ead60 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Runtime/Components/RateRequestScrollRectComponent.cs: -------------------------------------------------------------------------------- 1 | using UnityEngine; 2 | using UnityEngine.UI; 3 | 4 | namespace UniRate { 5 | 6 | [RequireComponent(typeof(ScrollRect))] 7 | public class RateRequestScrollRectComponent : RateRequestComponent { 8 | 9 | #region <<---------- Properties and Fields ---------->> 10 | 11 | private ScrollRect _scrollRect; 12 | 13 | #endregion <<---------- Properties and Fields ---------->> 14 | 15 | 16 | 17 | 18 | #region <<---------- MonoBahviour ---------->> 19 | 20 | protected override void Awake() { 21 | base.Awake(); 22 | this._scrollRect = this.GetComponent(); 23 | } 24 | 25 | private void OnEnable() { 26 | this._scrollRect.onValueChanged.AddListener(this.OnScrollRectValueChanged); 27 | this.ShouldActivateRequests = this.GetIsScrollRectMoving(this._scrollRect); 28 | } 29 | 30 | private void Update() { 31 | this.ShouldActivateRequests = this.GetIsScrollRectMoving(this._scrollRect); 32 | this.StopRequestsIfDelayed(); 33 | } 34 | 35 | protected override void OnDisable() { 36 | this._scrollRect.onValueChanged.RemoveListener(this.OnScrollRectValueChanged); 37 | base.OnDisable(); 38 | } 39 | 40 | #endregion <<---------- MonoBahviour ---------->> 41 | 42 | 43 | 44 | 45 | #region <<---------- Callbacks ---------->> 46 | 47 | private void OnScrollRectValueChanged(Vector2 normalizedPosition) { 48 | this.ShouldActivateRequests = true; 49 | } 50 | 51 | #endregion <<---------- Callbacks ---------->> 52 | 53 | 54 | 55 | 56 | #region <<---------- General ---------->> 57 | 58 | private bool GetIsScrollRectMoving(ScrollRect scrollRect) { 59 | var velocity = scrollRect.velocity; 60 | return (!this.IsFloatApproximatelyWithThreshold(velocity.x, 0f, 0.0001f) || !this.IsFloatApproximatelyWithThreshold(velocity.y, 0f, 0.0001f)); 61 | } 62 | 63 | private bool IsFloatApproximatelyWithThreshold(float value, float compareValue, float threshold) { 64 | return (value >= (compareValue - threshold) && value <= (compareValue + threshold)); 65 | } 66 | 67 | #endregion <<---------- General ---------->> 68 | } 69 | } -------------------------------------------------------------------------------- /Runtime/Components/RateRequestScrollRectComponent.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 427cec0eda6af48909c285d1017766ba 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Runtime/Components/RateRequestTMPInputFieldComponent.cs: -------------------------------------------------------------------------------- 1 | #if TMPRO 2 | using UnityEngine; 3 | using TMPro; 4 | 5 | namespace UniRate { 6 | 7 | [RequireComponent(typeof(TMP_InputField))] 8 | public class RateRequestTMPInputFieldComponent : RateRequestComponent { 9 | 10 | #region <<---------- Properties and Fields ---------->> 11 | 12 | private TMP_InputField _inputField; 13 | 14 | #endregion <<---------- Properties and Fields ---------->> 15 | 16 | 17 | 18 | 19 | #region <<---------- MonoBehaviour ---------->> 20 | 21 | protected override void Awake() { 22 | base.Awake(); 23 | this._inputField = this.GetComponent(); 24 | } 25 | 26 | private void OnEnable() { 27 | this._inputField.onEndEdit.AddListener(this.OnInputFieldEndEdit); 28 | this._inputField.onValueChanged.AddListener(this.OnInputFieldValueChanged); 29 | this.ShouldActivateRequests = this._inputField.isFocused; 30 | } 31 | 32 | private void Update() { 33 | this.ShouldActivateRequests = this._inputField.isFocused; 34 | this.StopRequestsIfDelayed(); 35 | } 36 | 37 | protected override void OnDisable() { 38 | this._inputField.onEndEdit.RemoveListener(this.OnInputFieldEndEdit); 39 | this._inputField.onValueChanged.RemoveListener(this.OnInputFieldValueChanged); 40 | base.OnDisable(); 41 | } 42 | 43 | #endregion <<---------- MonoBehaviour ---------->> 44 | 45 | 46 | 47 | 48 | #region <<---------- Callbacks ---------->> 49 | 50 | private void OnInputFieldEndEdit(string value) { 51 | this.ShouldActivateRequests = false; 52 | } 53 | 54 | private void OnInputFieldValueChanged(string value) { 55 | this.ShouldActivateRequests = true; 56 | } 57 | 58 | #endregion <<---------- Callbacks ---------->> 59 | } 60 | } 61 | #endif -------------------------------------------------------------------------------- /Runtime/Components/RateRequestTMPInputFieldComponent.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 03f8daa6edbed47edace2464f131a618 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Runtime/Components/RateRequestTouchComponent.cs: -------------------------------------------------------------------------------- 1 | using UnityEngine; 2 | 3 | namespace UniRate { 4 | 5 | public class RateRequestTouchComponent : RateRequestComponent { 6 | 7 | #region <<---------- MonoBehaviour ---------->> 8 | 9 | private void OnEnable() { 10 | this.ShouldActivateRequests = this.GetHasTouchesOrClicks(); 11 | } 12 | 13 | private void Update() { 14 | this.ShouldActivateRequests = this.GetHasTouchesOrClicks(); 15 | this.StopRequestsIfDelayed(); 16 | } 17 | 18 | #endregion <<---------- MonoBehaviour ---------->> 19 | 20 | 21 | 22 | 23 | #region <<---------- General ---------->> 24 | 25 | private bool GetHasTouchesOrClicks() { 26 | return ( 27 | Input.touchCount > 0 28 | || Input.GetMouseButton(0) // left click 29 | || Input.GetMouseButton(1) // right click 30 | || Input.GetMouseButton(2) // middle click 31 | ); 32 | } 33 | 34 | #endregion <<---------- General ---------->> 35 | } 36 | } -------------------------------------------------------------------------------- /Runtime/Components/RateRequestTouchComponent.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 593512c9ab2a34767944e0640b08ee09 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Runtime/Components/RateRequestWhileEnabledComponent.cs: -------------------------------------------------------------------------------- 1 | namespace UniRate { 2 | 3 | public class RateRequestWhileEnabledComponent : RateRequestComponent { 4 | 5 | #region <<---------- MonoBehaviour ---------->> 6 | 7 | private void OnEnable() { 8 | this.ShouldActivateRequests = true; 9 | } 10 | 11 | #endregion <<---------- MonoBehaviour ---------->> 12 | } 13 | } -------------------------------------------------------------------------------- /Runtime/Components/RateRequestWhileEnabledComponent.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 5f3cf6ec937d644b4b1a65c086b58b62 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Runtime/Controllers.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 3680ff1f195b64844b6e029adbe260bb 3 | folderAsset: yes 4 | DefaultImporter: 5 | externalObjects: {} 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Runtime/Controllers/RateManagerFixedUpdateRateController.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using UnityEngine; 3 | using UniRate.Debug; 4 | 5 | namespace UniRate.Internals { 6 | 7 | public class RateManagerFixedUpdateRateController : RateManagerValueController { 8 | 9 | #region <<---------- Initializers ---------->> 10 | 11 | public RateManagerFixedUpdateRateController(RateManager rateManager, int minimumFixedUpdateRate) : base(rateManager, minimumFixedUpdateRate, false, "fixed update rate") { 12 | 13 | } 14 | 15 | #endregion <<---------- Initializers ---------->> 16 | 17 | 18 | 19 | 20 | #region <<---------- Properties and Fields ---------->> 21 | 22 | /// 23 | /// Minimum fixed update rate per seconds allowed. 24 | /// 25 | public int Minimum { 26 | get => this.LimitValue; 27 | set => this.LimitValue = value; 28 | } 29 | 30 | /// 31 | /// Event raised when changes. 32 | /// 33 | public event Action MinimumChanged { 34 | add { 35 | this.LimitChanged += value; 36 | } 37 | remove { 38 | this.LimitChanged -= value; 39 | } 40 | } 41 | 42 | #endregion <<---------- Properties and Fields ---------->> 43 | 44 | 45 | 46 | 47 | #region <<---------- General ---------->> 48 | 49 | /// 50 | /// Create a new . 51 | /// 52 | public FixedUpdateRateRequest Request(int fixedUpdateRate) { 53 | return this.BaseRequest(new FixedUpdateRateRequest(this, fixedUpdateRate), 1); 54 | } 55 | 56 | protected override void ApplyTargetValueToUnitySettings() { 57 | float fixedDeltaTime = 1f / (float)this.Target; 58 | if (fixedDeltaTime == Time.fixedDeltaTime) return; 59 | if (RateDebug.IsLogLevelActive(RateLogLevel.Trace)) { 60 | RateDebug.Log(RateLogLevel.Trace, $"setting Time.fixedDeltaTime to {fixedDeltaTime.ToString("0.0##")}"); 61 | } 62 | Time.fixedDeltaTime = fixedDeltaTime; 63 | } 64 | 65 | #endregion <<---------- General ---------->> 66 | 67 | 68 | 69 | 70 | #region <<---------- MonoBehaviour Executions ---------->> 71 | 72 | internal void ExecuteMonoBehaviourFixedUpdate(float fixedUnscaledDeltaTime) { 73 | this.ApplyTargetValueToUnitySettings(); 74 | this.Current = Mathf.RoundToInt(1f / fixedUnscaledDeltaTime); 75 | } 76 | 77 | #endregion <<---------- MonoBehaviour Executions ---------->> 78 | } 79 | } -------------------------------------------------------------------------------- /Runtime/Controllers/RateManagerFixedUpdateRateController.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 561a789fdebee45d2a0ad34e66a58aea 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Runtime/Controllers/RateManagerRenderIntervalController.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using UniRate.Debug; 3 | 4 | #if UNITY_2019_3_OR_NEWER 5 | using UnityEngine.Rendering; 6 | #endif 7 | 8 | namespace UniRate.Internals { 9 | 10 | public class RateManagerRenderIntervalController : RateManagerValueController { 11 | 12 | #region <<---------- Initializers ---------->> 13 | 14 | public RateManagerRenderIntervalController(RateManager rateManager, int maximumRenderInterval) : base(rateManager, maximumRenderInterval, true, "render interval") { 15 | 16 | } 17 | 18 | #endregion <<---------- Initializers ---------->> 19 | 20 | 21 | 22 | 23 | #region <<---------- Properties and Fields ---------->> 24 | 25 | /// 26 | /// Is render interval supported? 27 | /// 28 | public bool IsSupported { 29 | #if UNITY_2019_3_OR_NEWER 30 | get => true; 31 | #else 32 | get => false; 33 | #endif 34 | } 35 | 36 | /// 37 | /// Maximum render interval allowed. 38 | /// 39 | public int Maximum { 40 | get => this.LimitValue; 41 | set => this.LimitValue = value; 42 | } 43 | 44 | /// 45 | /// Current render rate. 46 | /// 47 | public int CurrentRenderRate { 48 | #if UNITY_2019_3_OR_NEWER 49 | get => OnDemandRendering.effectiveRenderFrameRate; 50 | #else 51 | get => this.RateManager.UpdateRate.Current; 52 | #endif 53 | } 54 | 55 | /// 56 | /// Will current frame render? 57 | /// 58 | public bool WillRender { 59 | #if UNITY_2019_3_OR_NEWER 60 | get => OnDemandRendering.willCurrentFrameRender; 61 | #else 62 | get => true; 63 | #endif 64 | } 65 | 66 | #if !UNITY_2019_3_OR_NEWER 67 | private bool _loggedNotSupportedOnce; 68 | #endif 69 | 70 | /// 71 | /// Event raised when changes. 72 | /// 73 | public event Action MaximumChanged { 74 | add { 75 | this.LimitChanged += value; 76 | } 77 | remove { 78 | this.LimitChanged -= value; 79 | } 80 | } 81 | 82 | #endregion <<---------- Properties and Fields ---------->> 83 | 84 | 85 | 86 | 87 | #region <<---------- General ---------->> 88 | 89 | /// 90 | /// Create a new . 91 | /// 92 | public RenderIntervalRequest Request(int renderInterval) { 93 | var request = this.BaseRequest(new RenderIntervalRequest(this, renderInterval), 1); 94 | #if !UNITY_2019_3_OR_NEWER 95 | this.LogNotSupportedOnce(); 96 | #endif 97 | return request; 98 | } 99 | 100 | protected override void ApplyTargetValueToUnitySettings() { 101 | #if UNITY_2019_3_OR_NEWER 102 | var targetRednerInterval = this.Target; 103 | if (OnDemandRendering.renderFrameInterval == targetRednerInterval) return; 104 | if (RateDebug.IsLogLevelActive(RateLogLevel.Trace)) { 105 | RateDebug.Log(RateLogLevel.Trace, $"setting OnDemandRendering.renderFrameInterval to {targetRednerInterval.ToString()}"); 106 | } 107 | OnDemandRendering.renderFrameInterval = targetRednerInterval; 108 | #endif 109 | } 110 | 111 | #if !UNITY_2019_3_OR_NEWER 112 | private void LogNotSupportedOnce() { 113 | if (this._loggedNotSupportedOnce) return; 114 | this._loggedNotSupportedOnce = true; 115 | if (RateDebug.IsLogLevelActive(RateLogLevel.Warning)) { 116 | RateDebug.Log(RateLogLevel.Warning, $"{this.ValueName} is only supported on Unity 2019.3 or newer"); 117 | } 118 | } 119 | #endif 120 | 121 | #endregion <<---------- General ---------->> 122 | 123 | 124 | 125 | 126 | #region <<---------- MonoBehaviour Executions ---------->> 127 | 128 | internal void ExecuteMonoBehaviourUpdate() { 129 | this.ApplyTargetValueToUnitySettings(); 130 | #if UNITY_2019_3_OR_NEWER 131 | this.Current = OnDemandRendering.renderFrameInterval; 132 | #else 133 | this.CurrentValue = 1; 134 | #endif 135 | } 136 | 137 | #endregion <<---------- MonoBehaviour Executions ---------->> 138 | } 139 | } -------------------------------------------------------------------------------- /Runtime/Controllers/RateManagerRenderIntervalController.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: f6de9140847324eac9ed2f488875b321 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Runtime/Controllers/RateManagerUpdateRateController.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using UnityEngine; 3 | using UniRate.Debug; 4 | 5 | #if UNITY_2021_1_OR_NEWER 6 | using UnityApplication = UnityEngine.Device.Application; 7 | using UnityScreen = UnityEngine.Device.Screen; 8 | #else 9 | using UnityApplication = UnityEngine.Application; 10 | using UnityScreen = UnityEngine.Screen; 11 | #endif 12 | 13 | namespace UniRate.Internals { 14 | 15 | public class RateManagerUpdateRateController : RateManagerValueController { 16 | 17 | #region <<---------- Initializers ---------->> 18 | 19 | public RateManagerUpdateRateController(RateManager rateManager, int minimumUpdateRate, UpdateRateMode mode) : base(rateManager, minimumUpdateRate, false, "update rate") { 20 | this._mode = mode; 21 | if (RateDebug.IsLogLevelActive(RateLogLevel.Info)) { 22 | RateDebug.Log(RateLogLevel.Info, $"created controller with {this.ValueName} mode {this._mode.ToString()}"); 23 | } 24 | } 25 | 26 | #endregion <<---------- Initializers ---------->> 27 | 28 | 29 | 30 | 31 | #region <<---------- Properties and Fields ---------->> 32 | 33 | /// 34 | /// Minimum update rate per seconds allowed. 35 | /// 36 | public int Minimum { 37 | get => this.LimitValue; 38 | set => this.LimitValue = value; 39 | } 40 | 41 | /// 42 | /// Update rate mode. 43 | /// 44 | public UpdateRateMode Mode { 45 | get => this._mode; 46 | set { 47 | if (this._mode == value) return; 48 | this._mode = value; 49 | this.OnModeChanged(this._mode); 50 | } 51 | } 52 | private UpdateRateMode _mode; 53 | 54 | /// 55 | /// Event raised when changes. 56 | /// 57 | public event Action MinimumChanged { 58 | add { 59 | this.LimitChanged += value; 60 | } 61 | remove { 62 | this.LimitChanged -= value; 63 | } 64 | } 65 | 66 | /// 67 | /// Event raised when changes. 68 | /// 69 | public event Action ModeChanged { 70 | add { 71 | this._modeChanged -= value; 72 | this._modeChanged += value; 73 | } 74 | remove { 75 | this._modeChanged -= value; 76 | } 77 | } 78 | private Action _modeChanged; 79 | 80 | #endregion <<---------- Properties and Fields ---------->> 81 | 82 | 83 | 84 | 85 | #region <<---------- Callbacks ---------->> 86 | 87 | protected virtual void OnModeChanged(UpdateRateMode mode) { 88 | if (RateDebug.IsLogLevelActive(RateLogLevel.Info)) { 89 | RateDebug.Log(RateLogLevel.Info, $"{this.ValueName} mode changed to {mode.ToString()}"); 90 | } 91 | this.ApplyTargetValueToUnitySettings(); 92 | var e = this._modeChanged; 93 | if (e == null) return; 94 | e(this.RateManager, mode); 95 | } 96 | 97 | #endregion <<---------- Callbacks ---------->> 98 | 99 | 100 | 101 | 102 | #region <<---------- General ---------->> 103 | 104 | /// 105 | /// Create a new . 106 | /// 107 | public UpdateRateRequest Request(int updateRate) { 108 | return this.BaseRequest(new UpdateRateRequest(this, updateRate), 1); 109 | } 110 | 111 | protected override void ApplyTargetValueToUnitySettings() { 112 | int targetFrameRate = this.Target; 113 | int vSyncCount; 114 | 115 | switch (this.Mode) { 116 | 117 | case UpdateRateMode.ApplicationTargetFrameRate: 118 | vSyncCount = 0; 119 | break; 120 | 121 | case UpdateRateMode.VSyncCount: 122 | // UNITY DOCS https://docs.unity3d.com/ScriptReference/QualitySettings-vSyncCount.html?_ga=2.244925125.1929096148.1586530815-1497395495.1586530815 123 | // If QualitySettings.vSyncCount is set to a value other than 'Don't Sync' (0), the value of Application.targetFrameRate will be ignored. 124 | // QualitySettings.vSyncCount value must be 0, 1, 2, 3, or 4. 125 | // QualitySettings.vSyncCount is ignored on iOS. 126 | vSyncCount = Mathf.Clamp( 127 | UnityScreen.currentResolution.refreshRate / targetFrameRate, 128 | 1, 129 | 4 130 | ); 131 | break; 132 | 133 | default: throw new NotImplementedException($"not handling {nameof(UpdateRateMode)}.{this.Mode.ToString()}"); 134 | } 135 | 136 | if (QualitySettings.vSyncCount != vSyncCount) { 137 | if (RateDebug.IsLogLevelActive(RateLogLevel.Trace)) { 138 | RateDebug.Log(RateLogLevel.Trace, $"setting QualitySettings.vSyncCount to {vSyncCount.ToString()}"); 139 | } 140 | QualitySettings.vSyncCount = vSyncCount; 141 | } 142 | 143 | if (UnityApplication.targetFrameRate != targetFrameRate) { 144 | if (RateDebug.IsLogLevelActive(RateLogLevel.Trace)) { 145 | RateDebug.Log(RateLogLevel.Trace, $"setting Application.targetFrameRate to {targetFrameRate.ToString()}"); 146 | } 147 | UnityApplication.targetFrameRate = targetFrameRate; 148 | } 149 | } 150 | 151 | #endregion <<---------- General ---------->> 152 | 153 | 154 | 155 | 156 | #region <<---------- MonoBehaviour Executions ---------->> 157 | 158 | internal void ExecuteMonoBehaviourUpdate(float unscaledDeltaTime) { 159 | this.ApplyTargetValueToUnitySettings(); 160 | this.Current = Mathf.RoundToInt(1f / unscaledDeltaTime); 161 | } 162 | 163 | #endregion <<---------- MonoBehaviour Executions ---------->> 164 | } 165 | } -------------------------------------------------------------------------------- /Runtime/Controllers/RateManagerUpdateRateController.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 55325c3f6c8984146ad52b225e6156de 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Runtime/Controllers/RateManagerValueController.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 532036c6009944c18b648432a0026f28 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Runtime/Debug.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 4e91777de855c4ee5932ee516fe51358 3 | folderAsset: yes 4 | DefaultImporter: 5 | externalObjects: {} 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Runtime/Debug/RateDebug.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Diagnostics; 3 | using UnityEngine; 4 | #if UNITY_EDITOR 5 | using UnityEditor; 6 | #endif 7 | using UnityDebug = UnityEngine.Debug; 8 | using UnityObject = UnityEngine.Object; 9 | 10 | namespace UniRate.Debug { 11 | 12 | public static class RateDebug { 13 | 14 | #region <<---------- Initializers ---------->> 15 | 16 | static RateDebug() { 17 | #if UNITY_EDITOR 18 | LogLevel = (IsDebugBuild ? RateLogLevel.Debug : RateLogLevel.Info); 19 | #else 20 | LogLevel = (IsDebugBuild ? RateLogLevel.Info : RateLogLevel.Warning); 21 | #endif 22 | 23 | ScreenDataBackgroundColor = new Color(0, 0, 0, 0.25f); 24 | ScreenDataFontSize = 12; 25 | ScreenDataFontColor = Color.white; 26 | ScreenDataVerbose = true; 27 | DisplayOnScreenData = IsDebugBuild; 28 | } 29 | 30 | #endregion <<---------- Initializers ---------->> 31 | 32 | 33 | 34 | 35 | #region <<---------- Properties and Fields ---------->> 36 | 37 | public static bool IsDebugBuild { 38 | get { 39 | #if UNITY_EDITOR 40 | return EditorUserBuildSettings.development; 41 | #else 42 | return UnityDebug.isDebugBuild; 43 | #endif 44 | } 45 | } 46 | 47 | public static RateLogLevel LogLevel { get; set; } 48 | 49 | public static bool DisplayOnScreenData { get; set; } 50 | 51 | public static bool ScreenDataVerbose { get; set; } 52 | 53 | public static Color ScreenDataBackgroundColor { 54 | get => _screenDataBackgroundColor; 55 | set { 56 | if (_screenDataBackgroundColor == value) return; 57 | _screenDataBackgroundColor = value; 58 | OnScreenDataBackgroundColorChanged(_screenDataBackgroundColor); 59 | } 60 | } 61 | private static Color _screenDataBackgroundColor; 62 | 63 | public static int ScreenDataFontSize { 64 | get => _screenDataFontSize; 65 | set { 66 | if (_screenDataFontSize == value) return; 67 | _screenDataFontSize = value; 68 | OnScreenDataFontSizeChanged(_screenDataFontSize); 69 | } 70 | } 71 | private static int _screenDataFontSize; 72 | 73 | public static Color ScreenDataFontColor { 74 | get => _screenDataFontColor; 75 | set { 76 | if (_screenDataFontColor == value) return; 77 | _screenDataFontColor = value; 78 | OnScreenDataFontColorChanged(_screenDataFontColor); 79 | } 80 | } 81 | private static Color _screenDataFontColor; 82 | 83 | private static Texture2D ScreenDataBackgroundTexture { 84 | get { 85 | if (_screenDataBackgroundTexture == null) { 86 | _screenDataBackgroundTexture = CreateScreenDataBackgroundTexture(_screenDataBackgroundColor); 87 | } 88 | return _screenDataBackgroundTexture; 89 | } 90 | } 91 | private static Texture2D _screenDataBackgroundTexture; 92 | 93 | internal static GUIStyle ScreenDataStyle { 94 | get { 95 | if (_screenDataStyle == null) { 96 | _screenDataStyle = CreateScreenDataStyle( 97 | _screenDataFontSize, 98 | _screenDataFontColor, 99 | ScreenDataBackgroundTexture 100 | ); 101 | } 102 | return _screenDataStyle; 103 | } 104 | } 105 | private static GUIStyle _screenDataStyle; 106 | 107 | private const string LOG_PREFIX = "[UniRate] "; 108 | 109 | #endregion <<---------- Properties and Fields ---------->> 110 | 111 | 112 | 113 | 114 | #region <<---------- Callbacks ---------->> 115 | 116 | private static void OnScreenDataBackgroundColorChanged(Color color) { 117 | if (_screenDataBackgroundTexture != null) { 118 | UnityObject.Destroy(_screenDataBackgroundTexture); 119 | _screenDataBackgroundTexture = null; 120 | } 121 | if (_screenDataStyle == null) return; 122 | _screenDataStyle.normal.background = ScreenDataBackgroundTexture; 123 | } 124 | 125 | private static void OnScreenDataFontSizeChanged(int fontSize) { 126 | if (_screenDataStyle == null) return; 127 | _screenDataStyle.fontSize = fontSize; 128 | } 129 | 130 | private static void OnScreenDataFontColorChanged(Color color) { 131 | if (_screenDataStyle == null) return; 132 | _screenDataStyle.normal.textColor = color; 133 | } 134 | 135 | #endregion <<---------- Callbacks ---------->> 136 | 137 | 138 | 139 | 140 | #region <<---------- General ---------->> 141 | 142 | public static bool IsLogLevelActive(RateLogLevel level) { 143 | return (level >= LogLevel); 144 | } 145 | 146 | internal static void Log(RateLogLevel level, string message, UnityObject context = null) { 147 | switch (level) { 148 | case RateLogLevel.Trace: UnityDebug.Log($"{LOG_PREFIX}{message}", context); return; 149 | case RateLogLevel.Debug: UnityDebug.Log($"{LOG_PREFIX}{message}", context); return; 150 | case RateLogLevel.Info: UnityDebug.Log($"{LOG_PREFIX}{message}", context); return; 151 | case RateLogLevel.Warning: UnityDebug.LogWarning($"{LOG_PREFIX}{message}", context); return; 152 | case RateLogLevel.Error: UnityDebug.LogError($"{LOG_PREFIX}{message}", context); return; 153 | case RateLogLevel.Off: return; 154 | default: throw new NotImplementedException($"not handling {nameof(RateLogLevel)}.{level.ToString()}"); 155 | } 156 | } 157 | 158 | private static Texture2D CreateScreenDataBackgroundTexture(Color color) { 159 | var texture = new Texture2D(1, 1); 160 | var colorArray = texture.GetPixels(); 161 | for (int i = colorArray.Length - 1; i >= 0; i--) { 162 | colorArray[i] = color; 163 | } 164 | texture.SetPixels(colorArray); 165 | texture.Apply(); 166 | return texture; 167 | } 168 | 169 | private static GUIStyle CreateScreenDataStyle(int fontSize, Color fontColor, Texture2D backgroundTexture) { 170 | var style = new GUIStyle(GUI.skin.label); 171 | style.fontSize = fontSize; 172 | style.normal.textColor = fontColor; 173 | style.normal.background = backgroundTexture; 174 | style.padding = new RectOffset(2, 2, 1, 1); 175 | return style; 176 | } 177 | 178 | internal static string GetCurrentStackTrace(int skipFrames) { 179 | var stackTraceObject = new StackTrace(skipFrames + 1, true); 180 | return stackTraceObject?.ToString(); 181 | } 182 | 183 | #endregion <<---------- General ---------->> 184 | } 185 | } -------------------------------------------------------------------------------- /Runtime/Debug/RateDebug.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 5fe0336162440483c9bf2341b06df422 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Runtime/Debug/RateLogLevel.cs: -------------------------------------------------------------------------------- 1 | namespace UniRate.Debug { 2 | 3 | public enum RateLogLevel { 4 | Trace, 5 | Debug, 6 | Info, 7 | Warning, 8 | Error, 9 | Off 10 | } 11 | } -------------------------------------------------------------------------------- /Runtime/Debug/RateLogLevel.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 8f34292349bb1445aa0ccf5e0187e62c 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Runtime/Debug/RateRequestTrackInfo.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Linq; 3 | 4 | namespace UniRate.Debug { 5 | 6 | public readonly struct RateRequestTrackInfo { 7 | 8 | #region <<---------- Initializers ---------->> 9 | 10 | private RateRequestTrackInfo(int identifier, RateRequestType type, int value, DateTime startedTime, string stackTraceStart, bool isActive, DateTime finishedTime, string stackTraceFinish) { 11 | this.Identifier = identifier; 12 | this.Type = type; 13 | this.Value = value; 14 | this.StartedTime = startedTime; 15 | this.StackTraceStart = stackTraceStart; 16 | this.StackTraceStartFirstLine = stackTraceStart?.Split(_stackTraceSplitChars, StringSplitOptions.RemoveEmptyEntries).FirstOrDefault(); 17 | this.IsActive = isActive; 18 | this.FinishedTime = finishedTime; 19 | this.StackTraceFinish = stackTraceFinish; 20 | this.StackTraceFinishFirstLine = stackTraceFinish?.Split(_stackTraceSplitChars, StringSplitOptions.RemoveEmptyEntries).FirstOrDefault(); 21 | } 22 | 23 | public static RateRequestTrackInfo ForRequestDidStarted(RateRequest request, bool captureStackTrace, int skipStackTraceFrames) { 24 | return new RateRequestTrackInfo( 25 | request.GetHashCode(), 26 | request.Type, 27 | request.Value, 28 | DateTime.UtcNow, 29 | captureStackTrace ? RateDebug.GetCurrentStackTrace(skipStackTraceFrames + 1) : null, 30 | true, 31 | DateTime.MinValue, 32 | null 33 | ); 34 | } 35 | 36 | public static RateRequestTrackInfo ForRequestUnknownStarted(RateRequest request) { 37 | return new RateRequestTrackInfo( 38 | request.GetHashCode(), 39 | request.Type, 40 | request.Value, 41 | DateTime.MinValue, 42 | null, 43 | true, 44 | DateTime.MinValue, 45 | null 46 | ); 47 | } 48 | 49 | #endregion <<---------- Initializers ---------->> 50 | 51 | 52 | 53 | 54 | #region <<---------- Propertie and Fields ---------->> 55 | 56 | private static readonly char[] _stackTraceSplitChars = new[] { 57 | '\n' 58 | }; 59 | 60 | public int Identifier { get; } 61 | 62 | public RateRequestType Type { get; } 63 | 64 | public int Value { get; } 65 | 66 | public DateTime StartedTime { get; } 67 | 68 | public string StackTraceStart { get; } 69 | 70 | public string StackTraceStartFirstLine { get; } 71 | 72 | public bool IsActive { get; } 73 | 74 | public DateTime FinishedTime { get; } 75 | 76 | public string StackTraceFinish { get; } 77 | 78 | public string StackTraceFinishFirstLine { get; } 79 | 80 | #endregion <<---------- Propertie and Fields ---------->> 81 | 82 | 83 | 84 | 85 | #region <<---------- General ---------->> 86 | 87 | public RateRequestTrackInfo ForRequestDidFinished(bool captureStackTrace, int skipStackTraceFrames) { 88 | return new RateRequestTrackInfo( 89 | this.Identifier, 90 | this.Type, 91 | this.Value, 92 | this.StartedTime, 93 | this.StackTraceStart, 94 | false, 95 | DateTime.UtcNow, 96 | captureStackTrace ? RateDebug.GetCurrentStackTrace(skipStackTraceFrames + 1) : null 97 | ); 98 | } 99 | 100 | public bool HasStartTime() { 101 | return this.StartedTime > DateTime.MinValue && this.StartedTime != default; 102 | } 103 | 104 | public string GetStatusFormatted() { 105 | return this.IsActive ? "Active" : "Finished"; 106 | } 107 | 108 | public string GetStartedTimeFormatted() { 109 | return this.HasStartTime() ? this.StartedTime.ToLocalTime().ToString("HH:mm:ss.fff") : ""; 110 | } 111 | 112 | public string GetFinishedTimeFormatted() { 113 | return this.IsActive ? "" : this.FinishedTime.ToLocalTime().ToString("HH:mm:ss.fff"); 114 | } 115 | 116 | #endregion <<---------- General ---------->> 117 | } 118 | } -------------------------------------------------------------------------------- /Runtime/Debug/RateRequestTrackInfo.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: b22b4137040304c669e28a054b03af03 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Runtime/Debug/RateRequestTracker.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Diagnostics; 4 | 5 | namespace UniRate.Debug { 6 | 7 | public static class RateRequestTracker { 8 | 9 | #if UNITY_EDITOR 10 | #region <<---------- Properties and Fields ---------->> 11 | 12 | public static bool IsEnabled { 13 | get => _isEnabled; 14 | set { 15 | if (_isEnabled == value) return; 16 | _isEnabled = value; 17 | OnIsEnabledChanged(_isEnabled); 18 | } 19 | } 20 | private static bool _isEnabled; 21 | 22 | public static bool IsStackTraceEnabled { get; set; } 23 | 24 | private static readonly Dictionary _infos = new Dictionary(); 25 | 26 | public static event Action InfosChanged { 27 | add { 28 | _infosChanged -= value; 29 | _infosChanged += value; 30 | } 31 | remove { 32 | _infosChanged -= value; 33 | } 34 | } 35 | private static Action _infosChanged; 36 | 37 | #endregion <<---------- Properties and Fields ---------->> 38 | #endif 39 | 40 | 41 | 42 | 43 | #if UNITY_EDITOR 44 | #region <<---------- Callbacks ---------->> 45 | 46 | private static void OnIsEnabledChanged(bool isEnabled) { 47 | if (RateDebug.IsLogLevelActive(RateLogLevel.Info)) { 48 | RateDebug.Log(RateLogLevel.Info, $"requests tracker is {(isEnabled ? "enabled" : "disabled")}"); 49 | } 50 | } 51 | 52 | private static void OnInfosChanged() { 53 | var e = _infosChanged; 54 | if (e == null) return; 55 | e(); 56 | } 57 | 58 | #endregion <<---------- Callbacks ---------->> 59 | #endif 60 | 61 | 62 | 63 | 64 | #if UNITY_EDITOR 65 | #region <<---------- General ---------->> 66 | 67 | public static void GetInfos(List list) { 68 | list.Clear(); 69 | list.AddRange(_infos.Values); 70 | } 71 | 72 | #endregion <<---------- General ---------->> 73 | #endif 74 | 75 | 76 | 77 | 78 | #region <<---------- Requests Report ---------->> 79 | 80 | [Conditional("UNITY_EDITOR")] 81 | internal static void ReportStarted(RateRequest request, int skipStackTraceFrames) { 82 | #if UNITY_EDITOR 83 | if (!_isEnabled) return; 84 | var trackInfo = RateRequestTrackInfo.ForRequestDidStarted(request, IsStackTraceEnabled, skipStackTraceFrames + 1); 85 | _infos[trackInfo.Identifier] = trackInfo; 86 | OnInfosChanged(); 87 | #endif 88 | } 89 | 90 | [Conditional("UNITY_EDITOR")] 91 | internal static void ReportFinished(RateRequest request, int skipStackTraceFrames) { 92 | #if UNITY_EDITOR 93 | int identifier = request.GetHashCode(); 94 | if (!_infos.TryGetValue(identifier, out var trackInfo)) { 95 | if (!_isEnabled) return; 96 | trackInfo = RateRequestTrackInfo.ForRequestUnknownStarted(request); 97 | } 98 | trackInfo = trackInfo.ForRequestDidFinished(IsStackTraceEnabled, skipStackTraceFrames + 1); 99 | _infos[trackInfo.Identifier] = trackInfo; 100 | OnInfosChanged(); 101 | #endif 102 | } 103 | 104 | #endregion <<---------- Requests Report ---------->> 105 | } 106 | } -------------------------------------------------------------------------------- /Runtime/Debug/RateRequestTracker.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 28e791413a6444d99904728d9a7f5dff 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Runtime/RateManager.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 3651433f9c0c5443d82db69bebd179da 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Runtime/RatePreset.cs: -------------------------------------------------------------------------------- 1 | namespace UniRate { 2 | 3 | public struct RatePreset { 4 | 5 | #region <<---------- Initializers ---------->> 6 | 7 | public RatePreset(int updateRate, int fixedUpdateRate, int renderInterval) { 8 | this.UpdateRate = updateRate; 9 | this.FixedUpdateRate = fixedUpdateRate; 10 | this.RenderInterval = renderInterval; 11 | } 12 | 13 | #endregion <<---------- Initializers ---------->> 14 | 15 | 16 | 17 | 18 | #region <<---------- Properties and Fields ---------->> 19 | 20 | /// 21 | /// Update rate. 22 | /// 23 | public int UpdateRate { get; set; } 24 | 25 | /// 26 | /// Fixed Update rate. 27 | /// 28 | public int FixedUpdateRate { get; set; } 29 | 30 | /// 31 | /// Render Interval. 32 | /// 33 | public int RenderInterval { get; set; } 34 | 35 | #endregion <<---------- Properties and Fields ---------->> 36 | 37 | 38 | 39 | 40 | #region <<---------- Default Presets ---------->> 41 | 42 | /// 43 | /// Ultra preset with update rate of 120, fixed update rate of 100 and render interval of 1. 44 | /// 45 | public static readonly RatePreset Ultra = new RatePreset(120, 100, 1); 46 | 47 | /// 48 | /// Very high preset with update rate of 90, fixed update rate of 75 and render interval of 1. 49 | /// 50 | public static readonly RatePreset VeryHigh = new RatePreset(90, 75, 1); 51 | 52 | /// 53 | /// High preset with update rate of 60, fixed update rate of 50 and render interval of 1. 54 | /// 55 | public static readonly RatePreset High = new RatePreset(60, 50, 1); 56 | 57 | /// 58 | /// Medium preset with update rate of 30, fixed update rate of 40 and render interval of 2. 59 | /// 60 | public static readonly RatePreset Medium = new RatePreset(30, 40, 2); 61 | 62 | /// 63 | /// Low preset with update rate of 24, fixed update rate of 30 and render interval of 3. 64 | /// 65 | public static readonly RatePreset Low = new RatePreset(24, 30, 3); 66 | 67 | /// 68 | /// Very low preset with update rate of 20, fixed update rate of 20 and render interval of 4. 69 | /// 70 | public static readonly RatePreset VeryLow = new RatePreset(20, 20, 4); 71 | 72 | #endregion <<---------- Default Presets ---------->> 73 | } 74 | } -------------------------------------------------------------------------------- /Runtime/RatePreset.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: b122278e723444828ba9c4d54e8aa7d4 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Runtime/Requests.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: dc6bd20118c0d44a0b8d9b50f1554cc1 3 | folderAsset: yes 4 | DefaultImporter: 5 | externalObjects: {} 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Runtime/Requests/FixedUpdateRateRequest.cs: -------------------------------------------------------------------------------- 1 | using UniRate.Internals; 2 | 3 | namespace UniRate { 4 | 5 | public class FixedUpdateRateRequest : RateRequest { 6 | 7 | #region <<---------- Initializers ---------->> 8 | 9 | internal FixedUpdateRateRequest(RateManagerValueController controller, int fixedUpdateRate) : base(RateRequestType.FixedUpdateRate, controller) { 10 | this._fixedUpdateRate = fixedUpdateRate; 11 | } 12 | 13 | #endregion <<---------- Initializers ---------->> 14 | 15 | 16 | 17 | 18 | #region <<---------- Properties and Fields ---------->> 19 | 20 | /// 21 | /// Requested fixed update rate. 22 | /// 23 | public int FixedUpdateRate => this._fixedUpdateRate; 24 | private readonly int _fixedUpdateRate; 25 | 26 | protected internal override int Value => this._fixedUpdateRate; 27 | 28 | #endregion <<---------- Properties and Fields ---------->> 29 | } 30 | } -------------------------------------------------------------------------------- /Runtime/Requests/FixedUpdateRateRequest.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 06e0116e5843748cdb995487e087ec52 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Runtime/Requests/RateRequest.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using UniRate.Internals; 3 | 4 | namespace UniRate { 5 | 6 | public abstract class RateRequest : IDisposable { 7 | 8 | #region <<---------- Initializers ---------->> 9 | 10 | protected RateRequest(RateRequestType type, RateManagerValueController controller) { 11 | this._type = type; 12 | this._controller = controller ?? throw new ArgumentNullException(nameof(controller)); 13 | } 14 | 15 | #endregion <<---------- Initializers ---------->> 16 | 17 | 18 | 19 | 20 | #region <<---------- Properties and Fields ---------->> 21 | 22 | public RateRequestType Type => this._type; 23 | private readonly RateRequestType _type; 24 | 25 | protected RateManagerValueController Controller => this._controller; 26 | private readonly RateManagerValueController _controller; 27 | 28 | protected internal abstract int Value { get; } 29 | 30 | #endregion <<---------- Properties and Fields ---------->> 31 | 32 | 33 | 34 | 35 | #region <<---------- IDisposable ---------->> 36 | 37 | /// 38 | /// Is request canceled? 39 | /// 40 | public bool IsDisposed { get; protected set; } 41 | 42 | /// 43 | /// Cancel request. 44 | /// 45 | public void Dispose() { 46 | this.Dispose(true); 47 | GC.SuppressFinalize(this); 48 | } 49 | 50 | protected void Dispose(bool disposingManagedResources) { 51 | if (this.IsDisposed) return; 52 | this.IsDisposed = true; 53 | this.Controller?.CancelRequest(this, 2); 54 | } 55 | 56 | #endregion <<---------- IDisposable ---------->> 57 | } 58 | } -------------------------------------------------------------------------------- /Runtime/Requests/RateRequest.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 18a6c1be2593644ff8be4004947ee81b 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Runtime/Requests/RateRequestType.cs: -------------------------------------------------------------------------------- 1 | namespace UniRate { 2 | 3 | public enum RateRequestType { 4 | UpdateRate, 5 | FixedUpdateRate, 6 | RenderInterval 7 | } 8 | } -------------------------------------------------------------------------------- /Runtime/Requests/RateRequestType.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 8b14c964ca0c64cacb86c22e914dd81c 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Runtime/Requests/RenderIntervalRequest.cs: -------------------------------------------------------------------------------- 1 | using UniRate.Internals; 2 | 3 | namespace UniRate { 4 | 5 | public class RenderIntervalRequest : RateRequest { 6 | 7 | #region <<---------- Initializers ---------->> 8 | 9 | internal RenderIntervalRequest(RateManagerValueController controller, int renderInterval) : base(RateRequestType.RenderInterval, controller) { 10 | this._renderInterval = renderInterval; 11 | } 12 | 13 | #endregion <<---------- Initializers ---------->> 14 | 15 | 16 | 17 | 18 | #region <<---------- Properties and Fields ---------->> 19 | 20 | /// 21 | /// Requested render interval. 22 | /// 23 | public int RenderInterval => this._renderInterval; 24 | private readonly int _renderInterval; 25 | 26 | protected internal override int Value => this._renderInterval; 27 | 28 | #endregion <<---------- Properties and Fields ---------->> 29 | } 30 | } -------------------------------------------------------------------------------- /Runtime/Requests/RenderIntervalRequest.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: deac5bf48533648cc87c0f33350dbc41 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Runtime/Requests/UpdateRateRequest.cs: -------------------------------------------------------------------------------- 1 | using UniRate.Internals; 2 | 3 | namespace UniRate { 4 | 5 | public class UpdateRateRequest : RateRequest { 6 | 7 | #region <<---------- Initializers ---------->> 8 | 9 | internal UpdateRateRequest(RateManagerValueController controller, int updateRate) : base(RateRequestType.UpdateRate, controller) { 10 | this._updateRate = updateRate; 11 | } 12 | 13 | #endregion <<---------- Initializers ---------->> 14 | 15 | 16 | 17 | 18 | #region <<---------- Properties and Fields ---------->> 19 | 20 | /// 21 | /// Requested update rate. 22 | /// 23 | public int UpdateRate => this._updateRate; 24 | private readonly int _updateRate; 25 | 26 | protected internal override int Value => this._updateRate; 27 | 28 | #endregion <<---------- Properties and Fields ---------->> 29 | } 30 | } -------------------------------------------------------------------------------- /Runtime/Requests/UpdateRateRequest.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 8d8139a6de28447d0b2d7b5bb695fca7 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Runtime/UniRate.asmdef: -------------------------------------------------------------------------------- 1 | { 2 | "name": "UniRate", 3 | "references": [ 4 | "Unity.TextMeshPro" 5 | ], 6 | "includePlatforms": [], 7 | "excludePlatforms": [], 8 | "allowUnsafeCode": false, 9 | "overrideReferences": false, 10 | "precompiledReferences": [], 11 | "autoReferenced": true, 12 | "defineConstraints": [], 13 | "versionDefines": [], 14 | "noEngineReferences": false 15 | } -------------------------------------------------------------------------------- /Runtime/UniRate.asmdef.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: aa10f792792dc4ba08f3b3e353ef3e1a 3 | AssemblyDefinitionImporter: 4 | externalObjects: {} 5 | userData: 6 | assetBundleName: 7 | assetBundleVariant: 8 | -------------------------------------------------------------------------------- /Runtime/UpdateRateMode.cs: -------------------------------------------------------------------------------- 1 | using UnityEngine; 2 | 3 | namespace UniRate { 4 | 5 | public enum UpdateRateMode { 6 | 7 | /// 8 | /// Uses the to manage the update rate. 9 | /// 10 | ApplicationTargetFrameRate, 11 | 12 | /// 13 | /// Uses the to manage the update rate. 14 | /// 15 | VSyncCount 16 | } 17 | } -------------------------------------------------------------------------------- /Runtime/UpdateRateMode.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 79dd2811637e2403a8cb4a82d58f8192 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /TestsEditMode.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: ee085796b3c554db9a1b38bef25bbe93 3 | folderAsset: yes 4 | DefaultImporter: 5 | externalObjects: {} 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /TestsEditMode/RateManagerValueController_TargetTests_EditMode.cs: -------------------------------------------------------------------------------- 1 | using NUnit.Framework; 2 | using UniRate.Internals; 3 | 4 | namespace UniRate.TestsEditMode { 5 | 6 | public class RateManagerValueController_TargetTests_EditMode { 7 | 8 | private class RequestMock : RateRequest { 9 | 10 | public RequestMock(RateManagerValueController controller, int value) : base(RateRequestType.UpdateRate, controller) { 11 | this._value = value; 12 | } 13 | 14 | protected override int Value => this._value; 15 | private readonly int _value; 16 | } 17 | 18 | private class ControllerMock : RateManagerValueController { 19 | 20 | public ControllerMock(int limitValue, bool limitByMax, string valueName = "mock rate") : base(null, limitValue, limitByMax, valueName) { 21 | 22 | } 23 | 24 | protected override void ApplyTargetValueToUnitySettings() { 25 | // do nothing 26 | } 27 | 28 | public RequestMock RequestMock(int mockValue) { 29 | return this.BaseRequest(new RequestMock(this, mockValue), 1); 30 | } 31 | } 32 | 33 | [Test] 34 | public void LimitByMax_NoRequests_TargetIsLimitValue() { 35 | // given 36 | bool limitByMax = true; 37 | int limitValue = 10; 38 | 39 | // when 40 | var controller = new ControllerMock(limitValue, limitByMax); 41 | 42 | // then 43 | Assert.AreEqual(limitValue, controller.Target); 44 | } 45 | 46 | [Test] 47 | public void LimitByMin_NoRequests_TargetIsLimitValue() { 48 | // given 49 | bool limitByMax = false; 50 | int limitValue = 10; 51 | 52 | // when 53 | var controller = new ControllerMock(limitValue, limitByMax); 54 | 55 | // then 56 | Assert.AreEqual(limitValue, controller.Target); 57 | } 58 | 59 | 60 | [Test] 61 | public void LimitByMax_RequestAboveLimit_RequestBelowLimit_DisposeRequests_TargetIsLimitValue() { 62 | // given 63 | bool limitByMax = true; 64 | int limitValue = 10; 65 | int requestValueAbove = limitValue + 2; 66 | int requestValueBelow = limitValue - 2; 67 | 68 | // when 69 | var controller = new ControllerMock(limitValue, limitByMax); 70 | using (var requestAbove = controller.RequestMock(requestValueAbove)) { 71 | using (var requestBelow = controller.RequestMock(requestValueBelow)) { 72 | 73 | } 74 | } 75 | 76 | // then 77 | Assert.AreEqual(limitValue, controller.Target); 78 | } 79 | 80 | [Test] 81 | public void LimitByMin_RequestAboveLimit_RequestBelowLimit_DisposeRequests_TargetIsLimitValue() { 82 | // given 83 | bool limitByMax = false; 84 | int limitValue = 10; 85 | int requestValueAbove = limitValue + 2; 86 | int requestValueBelow = limitValue - 2; 87 | 88 | // when 89 | var controller = new ControllerMock(limitValue, limitByMax); 90 | using (var requestAbove = controller.RequestMock(requestValueAbove)) { 91 | using (var requestBelow = controller.RequestMock(requestValueBelow)) { 92 | 93 | } 94 | } 95 | 96 | // then 97 | Assert.AreEqual(limitValue, controller.Target); 98 | } 99 | 100 | 101 | [Test] 102 | public void LimitByMax_RequestAboveLimit_TargetIsLimitValue() { 103 | // given 104 | bool limitByMax = true; 105 | int limitValue = 10; 106 | int requestValue = limitValue + 2; 107 | 108 | // when 109 | var controller = new ControllerMock(limitValue, limitByMax); 110 | using (var request = controller.RequestMock(requestValue)) { 111 | 112 | // then 113 | Assert.AreEqual(limitValue, controller.Target); 114 | } 115 | } 116 | 117 | [Test] 118 | public void LimitByMin_RequestAboveLimit_TargetIsRequestValue() { 119 | // given 120 | bool limitByMax = false; 121 | int limitValue = 10; 122 | int requestValue = limitValue + 2; 123 | 124 | // when 125 | var controller = new ControllerMock(limitValue, limitByMax); 126 | using (var request = controller.RequestMock(requestValue)) { 127 | 128 | // then 129 | Assert.AreEqual(requestValue, controller.Target); 130 | } 131 | } 132 | 133 | 134 | [Test] 135 | public void LimitByMax_RequestBelowLimit_TargetIsRequestValue() { 136 | // given 137 | bool limitByMax = true; 138 | int limitValue = 10; 139 | int requestValue = limitValue - 2; 140 | 141 | // when 142 | var controller = new ControllerMock(limitValue, limitByMax); 143 | using (var requestAbove = controller.RequestMock(requestValue)) { 144 | 145 | // then 146 | Assert.AreEqual(requestValue, controller.Target); 147 | } 148 | } 149 | 150 | [Test] 151 | public void LimitByMin_RequestBelowLimit_TargetIsLimitValue() { 152 | // given 153 | bool limitByMax = false; 154 | int limitValue = 10; 155 | int requestValue = limitValue - 2; 156 | 157 | // when 158 | var controller = new ControllerMock(limitValue, limitByMax); 159 | using (var requestAbove = controller.RequestMock(requestValue)) { 160 | 161 | // then 162 | Assert.AreEqual(limitValue, controller.Target); 163 | } 164 | } 165 | 166 | 167 | [Test] 168 | public void LimitByMax_RequestLow_RequestHigh_TargetIsRequestLow() { 169 | // given 170 | bool limitByMax = true; 171 | int limitValue = 10; 172 | int requestLowValue = limitValue - 2; 173 | int requestHighValue = requestLowValue + 1; 174 | 175 | // when 176 | var controller = new ControllerMock(limitValue, limitByMax); 177 | using (var requestLow = controller.RequestMock(requestLowValue)) { 178 | using (var requestHigh = controller.RequestMock(requestHighValue)) { 179 | 180 | // then 181 | Assert.AreEqual(requestLowValue, controller.Target); 182 | } 183 | } 184 | } 185 | 186 | [Test] 187 | public void LimitByMin_RequestLow_RequestHigh_TargetIsRequestHigh() { 188 | // given 189 | bool limitByMax = false; 190 | int limitValue = 10; 191 | int requestLowValue = limitValue + 2; 192 | int requestHighValue = requestLowValue + 1; 193 | 194 | // when 195 | var controller = new ControllerMock(limitValue, limitByMax); 196 | using (var requestLow = controller.RequestMock(requestLowValue)) { 197 | using (var requestHigh = controller.RequestMock(requestHighValue)) { 198 | 199 | // then 200 | Assert.AreEqual(requestHighValue, controller.Target); 201 | } 202 | } 203 | } 204 | } 205 | } -------------------------------------------------------------------------------- /TestsEditMode/RateManagerValueController_TargetTests_EditMode.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 2212bf9e42d0142d5af759e78d77f350 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /TestsEditMode/UniRate.TestsEditMode.asmdef: -------------------------------------------------------------------------------- 1 | { 2 | "name": "UniRate.TestsEditMode", 3 | "rootNamespace": "", 4 | "references": [ 5 | "UnityEngine.TestRunner", 6 | "UnityEditor.TestRunner", 7 | "UniRate" 8 | ], 9 | "includePlatforms": [ 10 | "Editor" 11 | ], 12 | "excludePlatforms": [], 13 | "allowUnsafeCode": false, 14 | "overrideReferences": true, 15 | "precompiledReferences": [ 16 | "nunit.framework.dll" 17 | ], 18 | "autoReferenced": false, 19 | "defineConstraints": [ 20 | "UNITY_INCLUDE_TESTS" 21 | ], 22 | "versionDefines": [], 23 | "noEngineReferences": false 24 | } -------------------------------------------------------------------------------- /TestsEditMode/UniRate.TestsEditMode.asmdef.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: d59a7fc02249c44f4a6241368ef140ed 3 | AssemblyDefinitionImporter: 4 | externalObjects: {} 5 | userData: 6 | assetBundleName: 7 | assetBundleVariant: 8 | -------------------------------------------------------------------------------- /TestsPlayMode.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: ae1f13d7268d1434b9e1b0219faad0dd 3 | folderAsset: yes 4 | DefaultImporter: 5 | externalObjects: {} 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /TestsPlayMode/RateManager_CheckRuntimeUpdateRate_PlayMode.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections; 3 | using NUnit.Framework; 4 | using UnityEngine.TestTools; 5 | 6 | namespace UniRate.TestsPlayMode { 7 | 8 | public class RateManager_CheckRuntimeUpdateRate_PlayMode { 9 | 10 | private IEnumerator AssertAreEqualInMaxFrames(int expected, Func actualProvider, int maxFrames) { 11 | int frames = 0; 12 | int actual; 13 | do { 14 | yield return null; 15 | frames += 1; 16 | actual = actualProvider(); 17 | } while (frames < maxFrames && actual != expected); 18 | Assert.AreEqual(expected, actual, $"assert occured in {frames.ToString()} frames"); 19 | } 20 | 21 | 22 | [UnityTest] 23 | public IEnumerator VSyncCount_Min15_NoRequests_CurrentIsMin_In5FramesMax() { 24 | // given 25 | var rateManager = RateManager.Instance; 26 | rateManager.UpdateRate.Mode = UpdateRateMode.VSyncCount; 27 | rateManager.UpdateRate.Minimum = 15; 28 | 29 | // when 30 | rateManager.ApplyTargetsIfDirty(); 31 | 32 | // then 33 | yield return this.AssertAreEqualInMaxFrames(rateManager.UpdateRate.Minimum, () => rateManager.UpdateRate.Current, 5); 34 | } 35 | 36 | [UnityTest] 37 | public IEnumerator ApplicationTargetFrameRate_Min15_NoRequests_CurrentIsMin_In5FramesMax() { 38 | // given 39 | var rateManager = RateManager.Instance; 40 | rateManager.UpdateRate.Mode = UpdateRateMode.ApplicationTargetFrameRate; 41 | rateManager.UpdateRate.Minimum = 15; 42 | 43 | // when 44 | rateManager.ApplyTargetsIfDirty(); 45 | 46 | // then 47 | yield return this.AssertAreEqualInMaxFrames(rateManager.UpdateRate.Minimum, () => rateManager.UpdateRate.Current, 5); 48 | } 49 | 50 | 51 | [UnityTest] 52 | public IEnumerator VSyncCount_Min15_Request2_CurrentIsMin_In5FramesMax() { 53 | // given 54 | var rateManager = RateManager.Instance; 55 | rateManager.UpdateRate.Mode = UpdateRateMode.VSyncCount; 56 | rateManager.UpdateRate.Minimum = 15; 57 | int requestValue = 2; 58 | 59 | // when 60 | using (var request = rateManager.UpdateRate.Request(requestValue)) { 61 | rateManager.ApplyTargetsIfDirty(); 62 | 63 | // then 64 | yield return this.AssertAreEqualInMaxFrames(rateManager.UpdateRate.Minimum, () => rateManager.UpdateRate.Current, 5); 65 | } 66 | } 67 | 68 | [UnityTest] 69 | public IEnumerator ApplicationTargetFrameRate_Min15_Request2_CurrentIsMin_In5FramesMax() { 70 | // given 71 | var rateManager = RateManager.Instance; 72 | rateManager.UpdateRate.Mode = UpdateRateMode.ApplicationTargetFrameRate; 73 | rateManager.UpdateRate.Minimum = 15; 74 | int requestValue = 2; 75 | 76 | // when 77 | using (var request = rateManager.UpdateRate.Request(requestValue)) { 78 | rateManager.ApplyTargetsIfDirty(); 79 | 80 | // then 81 | yield return this.AssertAreEqualInMaxFrames(rateManager.UpdateRate.Minimum, () => rateManager.UpdateRate.Current, 5); 82 | } 83 | } 84 | 85 | 86 | [UnityTest] 87 | public IEnumerator VSyncCount_Min5_Request15_CurrentIsRequest_In5FramesMax() { 88 | // given 89 | var rateManager = RateManager.Instance; 90 | rateManager.UpdateRate.Mode = UpdateRateMode.VSyncCount; 91 | rateManager.UpdateRate.Minimum = 5; 92 | int requestValue = 15; 93 | 94 | // when 95 | using (var request = rateManager.UpdateRate.Request(requestValue)) { 96 | rateManager.ApplyTargetsIfDirty(); 97 | 98 | // then 99 | yield return this.AssertAreEqualInMaxFrames(requestValue, () => rateManager.UpdateRate.Current, 5); 100 | } 101 | } 102 | 103 | [UnityTest] 104 | public IEnumerator ApplicationTargetFrameRate_Min5_Request15_CurrentIsRequest_In5FramesMax() { 105 | // given 106 | var rateManager = RateManager.Instance; 107 | rateManager.UpdateRate.Mode = UpdateRateMode.ApplicationTargetFrameRate; 108 | rateManager.UpdateRate.Minimum = 5; 109 | int requestValue = 15; 110 | 111 | // when 112 | using (var request = rateManager.UpdateRate.Request(requestValue)) { 113 | rateManager.ApplyTargetsIfDirty(); 114 | 115 | // then 116 | yield return this.AssertAreEqualInMaxFrames(requestValue, () => rateManager.UpdateRate.Current, 5); 117 | } 118 | } 119 | 120 | 121 | [UnityTest] 122 | public IEnumerator VSyncCount_Min5_Request15_Wait3Frames_DisposeRequest_CurrentIsMin_In5FramesMax() { 123 | // given 124 | var rateManager = RateManager.Instance; 125 | rateManager.UpdateRate.Mode = UpdateRateMode.VSyncCount; 126 | rateManager.UpdateRate.Minimum = 5; 127 | int requestValue = 15; 128 | int waitFrames = 3; 129 | 130 | // when 131 | using (var request = rateManager.UpdateRate.Request(requestValue)) { 132 | rateManager.ApplyTargetsIfDirty(); 133 | for (int i = 0; i < waitFrames; i++) { 134 | yield return null; 135 | } 136 | } 137 | rateManager.ApplyTargetsIfDirty(); 138 | 139 | // then 140 | yield return this.AssertAreEqualInMaxFrames(rateManager.UpdateRate.Minimum, () => rateManager.UpdateRate.Current, 5); 141 | } 142 | 143 | [UnityTest] 144 | public IEnumerator ApplicationTargetFrameRate_Min5_Request15_Wait3Frames_DisposeRequest_CurrentIsMin_In5FramesMax() { 145 | // given 146 | var rateManager = RateManager.Instance; 147 | rateManager.UpdateRate.Mode = UpdateRateMode.ApplicationTargetFrameRate; 148 | rateManager.UpdateRate.Minimum = 5; 149 | int requestValue = 15; 150 | int waitFrames = 3; 151 | 152 | // when 153 | using (var request = rateManager.UpdateRate.Request(requestValue)) { 154 | rateManager.ApplyTargetsIfDirty(); 155 | for (int i = 0; i < waitFrames; i++) { 156 | yield return null; 157 | } 158 | } 159 | rateManager.ApplyTargetsIfDirty(); 160 | 161 | // then 162 | yield return this.AssertAreEqualInMaxFrames(rateManager.UpdateRate.Minimum, () => rateManager.UpdateRate.Current, 5); 163 | } 164 | } 165 | } -------------------------------------------------------------------------------- /TestsPlayMode/RateManager_CheckRuntimeUpdateRate_PlayMode.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 0be6f1565b60346ca90848891a952a31 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /TestsPlayMode/UniRate.TestsPlayMode.asmdef: -------------------------------------------------------------------------------- 1 | { 2 | "name": "UniRate.TestsPlayMode", 3 | "rootNamespace": "", 4 | "references": [ 5 | "UnityEngine.TestRunner", 6 | "UnityEditor.TestRunner", 7 | "UniRate" 8 | ], 9 | "includePlatforms": [], 10 | "excludePlatforms": [], 11 | "allowUnsafeCode": false, 12 | "overrideReferences": true, 13 | "precompiledReferences": [ 14 | "nunit.framework.dll" 15 | ], 16 | "autoReferenced": false, 17 | "defineConstraints": [ 18 | "UNITY_INCLUDE_TESTS" 19 | ], 20 | "versionDefines": [], 21 | "noEngineReferences": false 22 | } -------------------------------------------------------------------------------- /TestsPlayMode/UniRate.TestsPlayMode.asmdef.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 0425a88e2c7934b369301dfc3b0eba68 3 | AssemblyDefinitionImporter: 4 | externalObjects: {} 5 | userData: 6 | assetBundleName: 7 | assetBundleVariant: 8 | -------------------------------------------------------------------------------- /UniRate_v3.0.1.unitypackage: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/renanwolf/UniRate/f89445be8bf93c9a13698e09d7cbe2d5e532fdab/UniRate_v3.0.1.unitypackage -------------------------------------------------------------------------------- /UniRate_v3.0.1.unitypackage.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 43dd9bcb716bc4f718149ed30d3d5150 3 | DefaultImporter: 4 | externalObjects: {} 5 | userData: 6 | assetBundleName: 7 | assetBundleVariant: 8 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "com.pflowr.unirate", 3 | "displayName": "UniRate", 4 | "version": "3.0.1", 5 | "unity": "2018.3", 6 | "description": "A great solution to manage frame rate and rendering interval to save device power, especially on mobile platforms.\nYou can control the update rate, fixed update rate and render interval (Unity 2019.3 or newer) from everywhere in your code without worrying about multiple requests, UniRate will take care of all of them for you.", 7 | "author": { 8 | "name": "Renan Wolf Pace", 9 | "url": "https://github.com/renanwolf" 10 | }, 11 | "keywords": [ 12 | "unirate", 13 | "fps", 14 | "framerate", 15 | "frame", 16 | "rate", 17 | "render", 18 | "interval", 19 | "renderinterval", 20 | "battery" 21 | ] 22 | } -------------------------------------------------------------------------------- /package.json.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: d9f7f6eaaec8e42a9b5a73545d58652c 3 | TextScriptImporter: 4 | externalObjects: {} 5 | userData: 6 | assetBundleName: 7 | assetBundleVariant: 8 | --------------------------------------------------------------------------------