├── Unity Project ├── ProjectSettings │ ├── ProjectVersion.txt │ ├── ClusterInputManager.asset │ ├── NetworkManager.asset │ ├── TimeManager.asset │ ├── EditorBuildSettings.asset │ ├── PresetManager.asset │ ├── AudioManager.asset │ ├── TagManager.asset │ ├── EditorSettings.asset │ ├── UnityConnectSettings.asset │ ├── DynamicsManager.asset │ ├── NavMeshAreas.asset │ ├── Physics2DSettings.asset │ ├── GraphicsSettings.asset │ ├── QualitySettings.asset │ ├── InputManager.asset │ └── ProjectSettings.asset ├── Assets │ ├── Examples │ │ ├── spritesheet.png │ │ ├── Audio │ │ │ ├── footstep_0.wav │ │ │ ├── footstep_1.wav │ │ │ ├── footstep_2.wav │ │ │ ├── footstep_0.wav.meta │ │ │ ├── footstep_1.wav.meta │ │ │ └── footstep_2.wav.meta │ │ ├── ImageAnimator.unity.meta │ │ ├── SpriteAnimator.unity.meta │ │ ├── Audio.meta │ │ ├── AnimationController.cs.meta │ │ ├── AnimationController.cs │ │ ├── spritesheet.png.meta │ │ └── ImageAnimator.unity │ ├── Tests │ │ ├── Editor │ │ │ ├── NSubstitute │ │ │ │ ├── NSubstitute.dll │ │ │ │ ├── NSubstitute.XML.meta │ │ │ │ └── NSubstitute.dll.meta │ │ │ ├── NSubstitute.meta │ │ │ ├── FrameAnimatorTests.cs.meta │ │ │ └── FrameAnimatorTests.cs │ │ └── Editor.meta │ ├── Examples.meta │ ├── Plugins.meta │ ├── Tests.meta │ └── Plugins │ │ ├── Farrokh Games.meta │ │ └── Farrokh Games │ │ ├── SpriteAnimation │ │ ├── LICENSE.txt.meta │ │ ├── Frame.meta │ │ ├── Image.meta │ │ ├── Editor.meta │ │ ├── Particle.meta │ │ ├── Shared.meta │ │ ├── Sprite.meta │ │ ├── Transform.meta │ │ ├── Shared │ │ │ ├── AnimatorChildMode.cs │ │ │ ├── IAnimator.cs.meta │ │ │ ├── AnimatorChildMode.cs.meta │ │ │ ├── AbstractSpriteAnimator.cs.meta │ │ │ ├── IAnimator.cs │ │ │ └── AbstractSpriteAnimator.cs │ │ ├── Frame │ │ │ ├── FrameAnimator.cs.meta │ │ │ ├── IFrameAnimator.cs.meta │ │ │ ├── IFrameAnimator.cs │ │ │ └── FrameAnimator.cs │ │ ├── Image │ │ │ ├── IImageAnimator.cs.meta │ │ │ ├── ImageAnimator.cs.meta │ │ │ ├── IImageAnimator.cs │ │ │ └── ImageAnimator.cs │ │ ├── Sprite │ │ │ ├── ISpriteAnimator.cs.meta │ │ │ ├── SpriteAnimator.cs.meta │ │ │ ├── ISpriteAnimator.cs │ │ │ └── SpriteAnimator.cs │ │ ├── Editor │ │ │ ├── FramePropertDrawer.cs.meta │ │ │ ├── SpriteAnimatorEditor.cs.meta │ │ │ ├── FramePropertDrawer.cs │ │ │ └── SpriteAnimatorEditor.cs │ │ ├── Transform │ │ │ ├── TransformAnimator.cs.meta │ │ │ └── TransformAnimator.cs │ │ ├── Particle │ │ │ ├── ParticleSystemAnimator.cs.meta │ │ │ └── ParticleSystemAnimator.cs │ │ └── LICENSE.txt │ │ └── SpriteAnimation.meta ├── Packages │ └── manifest.json └── .vscode │ └── settings.json ├── Documentation ├── animation.gif ├── hierarchy.png ├── inspector-clip.png ├── inspector-frames.png ├── inspector-sprites.png └── inspector-animatorsettings.png ├── .gitignore ├── LICENSE └── README.md /Unity Project/ProjectSettings/ProjectVersion.txt: -------------------------------------------------------------------------------- 1 | m_EditorVersion: 2018.2.18f1 2 | -------------------------------------------------------------------------------- /Documentation/animation.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/FarrokhGames/SpriteAnimation/HEAD/Documentation/animation.gif -------------------------------------------------------------------------------- /Documentation/hierarchy.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/FarrokhGames/SpriteAnimation/HEAD/Documentation/hierarchy.png -------------------------------------------------------------------------------- /Documentation/inspector-clip.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/FarrokhGames/SpriteAnimation/HEAD/Documentation/inspector-clip.png -------------------------------------------------------------------------------- /Documentation/inspector-frames.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/FarrokhGames/SpriteAnimation/HEAD/Documentation/inspector-frames.png -------------------------------------------------------------------------------- /Documentation/inspector-sprites.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/FarrokhGames/SpriteAnimation/HEAD/Documentation/inspector-sprites.png -------------------------------------------------------------------------------- /Documentation/inspector-animatorsettings.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/FarrokhGames/SpriteAnimation/HEAD/Documentation/inspector-animatorsettings.png -------------------------------------------------------------------------------- /Unity Project/Assets/Examples/spritesheet.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/FarrokhGames/SpriteAnimation/HEAD/Unity Project/Assets/Examples/spritesheet.png -------------------------------------------------------------------------------- /Unity Project/Assets/Examples/Audio/footstep_0.wav: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/FarrokhGames/SpriteAnimation/HEAD/Unity Project/Assets/Examples/Audio/footstep_0.wav -------------------------------------------------------------------------------- /Unity Project/Assets/Examples/Audio/footstep_1.wav: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/FarrokhGames/SpriteAnimation/HEAD/Unity Project/Assets/Examples/Audio/footstep_1.wav -------------------------------------------------------------------------------- /Unity Project/Assets/Examples/Audio/footstep_2.wav: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/FarrokhGames/SpriteAnimation/HEAD/Unity Project/Assets/Examples/Audio/footstep_2.wav -------------------------------------------------------------------------------- /Unity Project/Assets/Tests/Editor/NSubstitute/NSubstitute.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/FarrokhGames/SpriteAnimation/HEAD/Unity Project/Assets/Tests/Editor/NSubstitute/NSubstitute.dll -------------------------------------------------------------------------------- /Unity Project/ProjectSettings/ClusterInputManager.asset: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | %TAG !u! tag:unity3d.com,2011: 3 | --- !u!236 &1 4 | ClusterInputManager: 5 | m_ObjectHideFlags: 0 6 | m_Inputs: [] 7 | -------------------------------------------------------------------------------- /Unity Project/Assets/Examples.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: deb477364bb884bfb8bc31601efcfe05 3 | folderAsset: yes 4 | DefaultImporter: 5 | externalObjects: {} 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Unity Project/Assets/Examples/ImageAnimator.unity.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 7b83c17c3ab6fde45a9b867fe5c5191e 3 | DefaultImporter: 4 | externalObjects: {} 5 | userData: 6 | assetBundleName: 7 | assetBundleVariant: 8 | -------------------------------------------------------------------------------- /Unity Project/Assets/Examples/SpriteAnimator.unity.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: bbd075abb150b44469de9b93af943e4e 3 | DefaultImporter: 4 | externalObjects: {} 5 | userData: 6 | assetBundleName: 7 | assetBundleVariant: 8 | -------------------------------------------------------------------------------- /Unity Project/Assets/Plugins.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: e154e6d8baaff4f238ab29e26c56558c 3 | folderAsset: yes 4 | DefaultImporter: 5 | externalObjects: {} 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Unity Project/Assets/Tests.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 651fe567780a24fe2b48f3b326cd1745 3 | folderAsset: yes 4 | DefaultImporter: 5 | externalObjects: {} 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Unity Project/Assets/Tests/Editor.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 6b59a96d41a244d82a5babf9d5e5f093 3 | folderAsset: yes 4 | DefaultImporter: 5 | externalObjects: {} 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Unity Project/ProjectSettings/NetworkManager.asset: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | %TAG !u! tag:unity3d.com,2011: 3 | --- !u!149 &1 4 | NetworkManager: 5 | m_ObjectHideFlags: 0 6 | m_DebugLevel: 0 7 | m_Sendrate: 15 8 | m_AssetToPrefab: {} 9 | -------------------------------------------------------------------------------- /Unity Project/Assets/Examples/Audio.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: f2eee7862b7624fd58b34757219d84c2 3 | folderAsset: yes 4 | DefaultImporter: 5 | externalObjects: {} 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Unity Project/Assets/Plugins/Farrokh Games.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: c86618d687654415e986a4c15887aacd 3 | folderAsset: yes 4 | DefaultImporter: 5 | externalObjects: {} 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Unity Project/Assets/Tests/Editor/NSubstitute.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 0025e4b4ba90541e090dd8f7e6621804 3 | folderAsset: yes 4 | DefaultImporter: 5 | externalObjects: {} 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Unity Project/Assets/Plugins/Farrokh Games/SpriteAnimation/LICENSE.txt.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 7fb0b45bc1cb644ca96db3aa66b0faff 3 | TextScriptImporter: 4 | externalObjects: {} 5 | userData: 6 | assetBundleName: 7 | assetBundleVariant: 8 | -------------------------------------------------------------------------------- /Unity Project/Assets/Plugins/Farrokh Games/SpriteAnimation.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 7ca8999b12e5b6e4ca821ca15b7a47a1 3 | folderAsset: yes 4 | DefaultImporter: 5 | externalObjects: {} 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Unity Project/Assets/Plugins/Farrokh Games/SpriteAnimation/Frame.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 49e4042640be7374f9d2df095e02ac12 3 | folderAsset: yes 4 | DefaultImporter: 5 | externalObjects: {} 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Unity Project/Assets/Plugins/Farrokh Games/SpriteAnimation/Image.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 9919e4b9fd7623243bff129b38332e61 3 | folderAsset: yes 4 | DefaultImporter: 5 | externalObjects: {} 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Unity Project/Assets/Plugins/Farrokh Games/SpriteAnimation/Editor.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 73f5aab193e3546199bc66dc6a2c4840 3 | folderAsset: yes 4 | DefaultImporter: 5 | externalObjects: {} 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Unity Project/Assets/Plugins/Farrokh Games/SpriteAnimation/Particle.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 04d8217681f853f4fb6200c83583a3f2 3 | folderAsset: yes 4 | DefaultImporter: 5 | externalObjects: {} 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Unity Project/Assets/Plugins/Farrokh Games/SpriteAnimation/Shared.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 913fc87f346574e41bbcba142ecca3d3 3 | folderAsset: yes 4 | DefaultImporter: 5 | externalObjects: {} 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Unity Project/Assets/Plugins/Farrokh Games/SpriteAnimation/Sprite.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: def4227fd6df1a44c9789b0e3ba36354 3 | folderAsset: yes 4 | DefaultImporter: 5 | externalObjects: {} 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Unity Project/Assets/Plugins/Farrokh Games/SpriteAnimation/Transform.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 3b2668e1953067e4889b924f83543140 3 | folderAsset: yes 4 | DefaultImporter: 5 | externalObjects: {} 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Unity Project/Assets/Tests/Editor/NSubstitute/NSubstitute.XML.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 9626a3d1b240041ed90ddfe75e9593e4 3 | timeCreated: 1487583763 4 | licenseType: Free 5 | TextScriptImporter: 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Unity Project/ProjectSettings/TimeManager.asset: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | %TAG !u! tag:unity3d.com,2011: 3 | --- !u!5 &1 4 | TimeManager: 5 | m_ObjectHideFlags: 0 6 | Fixed Timestep: 0.02 7 | Maximum Allowed Timestep: 0.1 8 | m_TimeScale: 1 9 | Maximum Particle Timestep: 0.03 10 | -------------------------------------------------------------------------------- /Unity Project/Assets/Plugins/Farrokh Games/SpriteAnimation/Shared/AnimatorChildMode.cs: -------------------------------------------------------------------------------- 1 | namespace FarrokhGames.SpriteAnimation.Shared 2 | { 3 | public enum AnimatorChildMode 4 | { 5 | PlayWithParent, 6 | ShareClipsWithParent, 7 | IgnoreParent, 8 | } 9 | } -------------------------------------------------------------------------------- /Unity Project/Assets/Examples/AnimationController.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: b35ce0cc94f284ff6b0b71208da13129 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Unity Project/Assets/Tests/Editor/FrameAnimatorTests.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 376e03d29936d4560ab9127d4d5d8b16 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Unity Project/Assets/Plugins/Farrokh Games/SpriteAnimation/Shared/IAnimator.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 3805f73e9fa6540ab85f9d4cfc4405d5 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Unity Project/ProjectSettings/EditorBuildSettings.asset: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | %TAG !u! tag:unity3d.com,2011: 3 | --- !u!1045 &1 4 | EditorBuildSettings: 5 | m_ObjectHideFlags: 0 6 | serializedVersion: 2 7 | m_Scenes: 8 | - enabled: 1 9 | path: Assets/Scenes/SampleScene.unity 10 | guid: 2cda990e2423bbf4892e6590ba056729 11 | m_configObjects: {} 12 | -------------------------------------------------------------------------------- /Unity Project/Assets/Plugins/Farrokh Games/SpriteAnimation/Frame/FrameAnimator.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: cdeaff58df8dd4f7c9d9cbb499b2c327 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Unity Project/Assets/Plugins/Farrokh Games/SpriteAnimation/Frame/IFrameAnimator.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: c191b38a3a99d489d80ba1c015ac960e 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Unity Project/Assets/Plugins/Farrokh Games/SpriteAnimation/Image/IImageAnimator.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 48b316baa8434448ca92be73e9bb2d8a 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Unity Project/Assets/Plugins/Farrokh Games/SpriteAnimation/Image/ImageAnimator.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 00541194b655648298f2e4e1150cfc8a 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Unity Project/Assets/Plugins/Farrokh Games/SpriteAnimation/Sprite/ISpriteAnimator.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 308b88915477448e0bb1d274d2810379 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Unity Project/Assets/Plugins/Farrokh Games/SpriteAnimation/Sprite/SpriteAnimator.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 01abf617a76f740e7a816d4451e842ef 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Unity Project/Assets/Plugins/Farrokh Games/SpriteAnimation/Editor/FramePropertDrawer.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 21190caaf050e4f99a08c19778c8cddf 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Unity Project/Assets/Plugins/Farrokh Games/SpriteAnimation/Editor/SpriteAnimatorEditor.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 4b5c22b5f87e3435c9d9d3662d0d9eea 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Unity Project/Assets/Plugins/Farrokh Games/SpriteAnimation/Shared/AnimatorChildMode.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: ac0de5318036b5242a7312b0c6fb76b4 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Unity Project/Assets/Plugins/Farrokh Games/SpriteAnimation/Transform/TransformAnimator.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 389eeb5cffe4a454990fb18abd5b35d3 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Unity Project/Assets/Plugins/Farrokh Games/SpriteAnimation/Particle/ParticleSystemAnimator.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: bb26022dfaa78b94b8d5d4a34da77b4c 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Unity Project/Assets/Plugins/Farrokh Games/SpriteAnimation/Shared/AbstractSpriteAnimator.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 16f2b036f675b47ee8f7639d43fe9a45 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Unity Project/Packages/manifest.json: -------------------------------------------------------------------------------- 1 | { 2 | "dependencies": { 3 | "com.unity.package-manager-ui": "1.9.11", 4 | "com.unity.modules.audio": "1.0.0", 5 | "com.unity.modules.imgui": "1.0.0", 6 | "com.unity.modules.particlesystem": "1.0.0", 7 | "com.unity.modules.ui": "1.0.0", 8 | "com.unity.modules.uielements": "1.0.0", 9 | "com.unity.modules.wind": "1.0.0" 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /Unity Project/ProjectSettings/PresetManager.asset: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | %TAG !u! tag:unity3d.com,2011: 3 | --- !u!1386491679 &1 4 | PresetManager: 5 | m_ObjectHideFlags: 0 6 | m_DefaultList: 7 | - type: 8 | m_NativeTypeID: 20 9 | m_ManagedTypePPtr: {fileID: 0} 10 | m_ManagedTypeFallback: 11 | defaultPresets: 12 | - m_Preset: {fileID: 2655988077585873504, guid: bfcfc320427f8224bbb7a96f3d3aebad, 13 | type: 2} 14 | -------------------------------------------------------------------------------- /Unity Project/Assets/Plugins/Farrokh Games/SpriteAnimation/Image/IImageAnimator.cs: -------------------------------------------------------------------------------- 1 | using UnityEngine; 2 | 3 | namespace FarrokhGames.SpriteAnimation 4 | { 5 | /// 6 | /// UI-Image-based animator 7 | /// 8 | public interface IImageAnimator : IAnimator 9 | { 10 | /// 11 | /// Gets or sets wether this animator is visible or not 12 | /// 13 | bool Visible { get; set; } 14 | } 15 | } -------------------------------------------------------------------------------- /Unity Project/ProjectSettings/AudioManager.asset: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | %TAG !u! tag:unity3d.com,2011: 3 | --- !u!11 &1 4 | AudioManager: 5 | m_ObjectHideFlags: 0 6 | m_Volume: 1 7 | Rolloff Scale: 1 8 | Doppler Factor: 1 9 | Default Speaker Mode: 2 10 | m_SampleRate: 0 11 | m_DSPBufferSize: 1024 12 | m_VirtualVoiceCount: 512 13 | m_RealVoiceCount: 32 14 | m_SpatializerPlugin: 15 | m_AmbisonicDecoderPlugin: 16 | m_DisableAudio: 0 17 | m_VirtualizeEffects: 1 18 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | [Ll]ibrary/ 2 | [Tt]emp/ 3 | [Oo]bj/ 4 | [Bb]uild/ 5 | [Bb]uilds/ 6 | Assets/AssetStoreTools* 7 | 8 | # Visual Studio cache directory 9 | .vs/ 10 | 11 | # Autogenerated VS/MD/Consulo solution and project files 12 | ExportedObj/ 13 | .consulo/ 14 | *.csproj 15 | *.unityproj 16 | *.sln 17 | *.suo 18 | *.tmp 19 | *.user 20 | *.userprefs 21 | *.pidb 22 | *.booproj 23 | *.svd 24 | *.pdb 25 | *.opendb 26 | 27 | # Unity3D generated meta files 28 | *.pidb.meta 29 | *.pdb.meta 30 | 31 | # Unity3D Generated File On Crash Reports 32 | sysinfo.txt 33 | 34 | # Builds 35 | *.apk 36 | *.unitypackage 37 | -------------------------------------------------------------------------------- /Unity Project/Assets/Examples/Audio/footstep_0.wav.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 71f78841c163f42e2b42090c6e993626 3 | AudioImporter: 4 | externalObjects: {} 5 | serializedVersion: 6 6 | defaultSettings: 7 | loadType: 0 8 | sampleRateSetting: 1 9 | sampleRateOverride: 44100 10 | compressionFormat: 1 11 | quality: 1 12 | conversionMode: 0 13 | platformSettingOverrides: {} 14 | forceToMono: 1 15 | normalize: 1 16 | preloadAudioData: 1 17 | loadInBackground: 0 18 | ambisonic: 0 19 | 3D: 1 20 | userData: 21 | assetBundleName: 22 | assetBundleVariant: 23 | -------------------------------------------------------------------------------- /Unity Project/Assets/Examples/Audio/footstep_1.wav.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 1aca8e812818143c5bb8007797d9c56a 3 | AudioImporter: 4 | externalObjects: {} 5 | serializedVersion: 6 6 | defaultSettings: 7 | loadType: 0 8 | sampleRateSetting: 1 9 | sampleRateOverride: 44100 10 | compressionFormat: 1 11 | quality: 1 12 | conversionMode: 0 13 | platformSettingOverrides: {} 14 | forceToMono: 1 15 | normalize: 1 16 | preloadAudioData: 1 17 | loadInBackground: 0 18 | ambisonic: 0 19 | 3D: 1 20 | userData: 21 | assetBundleName: 22 | assetBundleVariant: 23 | -------------------------------------------------------------------------------- /Unity Project/Assets/Examples/Audio/footstep_2.wav.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 0f81fffe9d0a44501b4992404f6886cb 3 | AudioImporter: 4 | externalObjects: {} 5 | serializedVersion: 6 6 | defaultSettings: 7 | loadType: 0 8 | sampleRateSetting: 1 9 | sampleRateOverride: 44100 10 | compressionFormat: 1 11 | quality: 1 12 | conversionMode: 0 13 | platformSettingOverrides: {} 14 | forceToMono: 1 15 | normalize: 1 16 | preloadAudioData: 1 17 | loadInBackground: 0 18 | ambisonic: 0 19 | 3D: 1 20 | userData: 21 | assetBundleName: 22 | assetBundleVariant: 23 | -------------------------------------------------------------------------------- /Unity Project/Assets/Tests/Editor/NSubstitute/NSubstitute.dll.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 63a0eec46efb64f87a018cef0655949f 3 | timeCreated: 1487583758 4 | licenseType: Free 5 | PluginImporter: 6 | serializedVersion: 1 7 | iconMap: {} 8 | executionOrder: {} 9 | isPreloaded: 0 10 | isOverridable: 0 11 | platformData: 12 | Any: 13 | enabled: 0 14 | settings: {} 15 | Editor: 16 | enabled: 1 17 | settings: 18 | DefaultValueInitialized: true 19 | WindowsStoreApps: 20 | enabled: 0 21 | settings: 22 | CPU: AnyCPU 23 | userData: 24 | assetBundleName: 25 | assetBundleVariant: 26 | -------------------------------------------------------------------------------- /Unity Project/ProjectSettings/TagManager.asset: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | %TAG !u! tag:unity3d.com,2011: 3 | --- !u!78 &1 4 | TagManager: 5 | serializedVersion: 2 6 | tags: [] 7 | layers: 8 | - Default 9 | - TransparentFX 10 | - Ignore Raycast 11 | - 12 | - Water 13 | - UI 14 | - 15 | - 16 | - 17 | - 18 | - 19 | - 20 | - 21 | - 22 | - 23 | - 24 | - 25 | - 26 | - 27 | - 28 | - 29 | - 30 | - 31 | - 32 | - 33 | - 34 | - 35 | - 36 | - 37 | - 38 | - 39 | - 40 | m_SortingLayers: 41 | - name: Default 42 | uniqueID: 0 43 | locked: 0 44 | -------------------------------------------------------------------------------- /Unity Project/Assets/Plugins/Farrokh Games/SpriteAnimation/Sprite/ISpriteAnimator.cs: -------------------------------------------------------------------------------- 1 | namespace FarrokhGames.SpriteAnimation 2 | { 3 | /// 4 | /// SpriteRenderer-based animator 5 | /// 6 | public interface ISpriteAnimator : IAnimator 7 | { 8 | /// 9 | /// Gets or sets wether this animator is visible or not 10 | /// 11 | bool Visible { get; set; } 12 | 13 | /// 14 | /// Gets or sets the sorting order of this animator while keeping its offset 15 | /// 16 | /// 17 | int SortingOrder { get; set; } 18 | } 19 | } -------------------------------------------------------------------------------- /Unity Project/ProjectSettings/EditorSettings.asset: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | %TAG !u! tag:unity3d.com,2011: 3 | --- !u!159 &1 4 | EditorSettings: 5 | m_ObjectHideFlags: 0 6 | serializedVersion: 7 7 | m_ExternalVersionControlSupport: Visible Meta Files 8 | m_SerializationMode: 2 9 | m_LineEndingsForNewScripts: 2 10 | m_DefaultBehaviorMode: 1 11 | m_SpritePackerMode: 4 12 | m_SpritePackerPaddingPower: 1 13 | m_EtcTextureCompressorBehavior: 1 14 | m_EtcTextureFastCompressor: 1 15 | m_EtcTextureNormalCompressor: 2 16 | m_EtcTextureBestCompressor: 4 17 | m_ProjectGenerationIncludedExtensions: txt;xml;fnt;cd 18 | m_ProjectGenerationRootNamespace: 19 | m_UserGeneratedProjectSuffix: 20 | m_CollabEditorSettings: 21 | inProgressEnabled: 1 22 | -------------------------------------------------------------------------------- /Unity Project/ProjectSettings/UnityConnectSettings.asset: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | %TAG !u! tag:unity3d.com,2011: 3 | --- !u!310 &1 4 | UnityConnectSettings: 5 | m_ObjectHideFlags: 0 6 | m_Enabled: 0 7 | m_TestMode: 0 8 | m_TestEventUrl: 9 | m_TestConfigUrl: 10 | m_TestInitMode: 0 11 | CrashReportingSettings: 12 | m_EventUrl: https://perf-events.cloud.unity3d.com/api/events/crashes 13 | m_NativeEventUrl: https://perf-events.cloud.unity3d.com/symbolicate 14 | m_Enabled: 0 15 | m_CaptureEditorExceptions: 1 16 | UnityPurchasingSettings: 17 | m_Enabled: 0 18 | m_TestMode: 0 19 | UnityAnalyticsSettings: 20 | m_Enabled: 0 21 | m_InitializeOnStartup: 1 22 | m_TestMode: 0 23 | m_TestEventUrl: 24 | m_TestConfigUrl: 25 | UnityAdsSettings: 26 | m_Enabled: 0 27 | m_InitializeOnStartup: 1 28 | m_TestMode: 0 29 | m_IosGameId: 30 | m_AndroidGameId: 31 | m_GameIds: {} 32 | m_GameId: 33 | PerformanceReportingSettings: 34 | m_Enabled: 0 35 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2018 Farrokh Games 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. 22 | -------------------------------------------------------------------------------- /Unity Project/ProjectSettings/DynamicsManager.asset: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | %TAG !u! tag:unity3d.com,2011: 3 | --- !u!55 &1 4 | PhysicsManager: 5 | m_ObjectHideFlags: 0 6 | serializedVersion: 7 7 | m_Gravity: {x: 0, y: -9.81, z: 0} 8 | m_DefaultMaterial: {fileID: 0} 9 | m_BounceThreshold: 2 10 | m_SleepThreshold: 0.005 11 | m_DefaultContactOffset: 0.01 12 | m_DefaultSolverIterations: 6 13 | m_DefaultSolverVelocityIterations: 1 14 | m_QueriesHitBackfaces: 0 15 | m_QueriesHitTriggers: 1 16 | m_EnableAdaptiveForce: 0 17 | m_ClothInterCollisionDistance: 0 18 | m_ClothInterCollisionStiffness: 0 19 | m_ContactsGeneration: 1 20 | m_LayerCollisionMatrix: ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff 21 | m_AutoSimulation: 1 22 | m_AutoSyncTransforms: 1 23 | m_ClothInterCollisionSettingsToggle: 0 24 | m_ContactPairsMode: 0 25 | m_BroadphaseType: 0 26 | m_WorldBounds: 27 | m_Center: {x: 0, y: 0, z: 0} 28 | m_Extent: {x: 250, y: 250, z: 250} 29 | m_WorldSubdivisions: 8 30 | -------------------------------------------------------------------------------- /Unity Project/Assets/Plugins/Farrokh Games/SpriteAnimation/LICENSE.txt: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2018 Farrokh Games 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. 22 | -------------------------------------------------------------------------------- /Unity Project/Assets/Examples/AnimationController.cs: -------------------------------------------------------------------------------- 1 | using FarrokhGames.SpriteAnimation; 2 | using UnityEngine; 3 | 4 | /// 5 | /// Example class for playing animations, flipping artwork, and playing sounds on triggers 6 | /// 7 | public class AnimationController : MonoBehaviour 8 | { 9 | [SerializeField] AudioClip[] _footsteps; 10 | 11 | IAnimator _animator; 12 | AudioSource _audioSource; 13 | ISpriteAnimator _spriteAnimator; 14 | IImageAnimator _imageAnimator; 15 | 16 | void Awake() 17 | { 18 | _animator = GetComponent(); 19 | _animator.OnTrigger += HandleTrigger; 20 | _audioSource = GetComponent(); 21 | _spriteAnimator = _animator as ISpriteAnimator; 22 | _imageAnimator = _animator as IImageAnimator; 23 | } 24 | 25 | void Update() 26 | { 27 | var walkAxis = Input.GetAxis("Horizontal"); 28 | 29 | if (walkAxis == 0) 30 | { 31 | _animator.Play("Idle"); 32 | } 33 | else 34 | { 35 | _animator.Play("Walk"); 36 | if (_spriteAnimator != null) { _spriteAnimator.Flip = walkAxis < 0; } 37 | if (_imageAnimator != null) { _imageAnimator.Flip = walkAxis < 0; } 38 | } 39 | } 40 | 41 | void HandleTrigger(string trigger) 42 | { 43 | if (trigger == "footstep") 44 | { 45 | if (_footsteps.Length > 0) 46 | { 47 | var clip = _footsteps[UnityEngine.Random.Range(0, _footsteps.Length - 1)]; 48 | _audioSource.PlayOneShot(clip); 49 | } 50 | } 51 | } 52 | } -------------------------------------------------------------------------------- /Unity Project/.vscode/settings.json: -------------------------------------------------------------------------------- 1 | { 2 | "files.exclude": 3 | { 4 | "**/.DS_Store":true, 5 | "**/.git":true, 6 | "**/.gitignore":true, 7 | "**/.gitmodules":true, 8 | "**/*.booproj":true, 9 | "**/*.pidb":true, 10 | "**/*.suo":true, 11 | "**/*.user":true, 12 | "**/*.userprefs":true, 13 | "**/*.unityproj":true, 14 | "**/*.dll":true, 15 | "**/*.exe":true, 16 | "**/*.pdf":true, 17 | "**/*.mid":true, 18 | "**/*.midi":true, 19 | "**/*.wav":true, 20 | "**/*.gif":true, 21 | "**/*.ico":true, 22 | "**/*.jpg":true, 23 | "**/*.jpeg":true, 24 | "**/*.png":true, 25 | "**/*.psd":true, 26 | "**/*.tga":true, 27 | "**/*.tif":true, 28 | "**/*.tiff":true, 29 | "**/*.3ds":true, 30 | "**/*.3DS":true, 31 | "**/*.fbx":true, 32 | "**/*.FBX":true, 33 | "**/*.lxo":true, 34 | "**/*.LXO":true, 35 | "**/*.ma":true, 36 | "**/*.MA":true, 37 | "**/*.obj":true, 38 | "**/*.OBJ":true, 39 | "**/*.asset":true, 40 | "**/*.cubemap":true, 41 | "**/*.flare":true, 42 | "**/*.mat":true, 43 | "**/*.meta":true, 44 | "**/*.prefab":true, 45 | "**/*.unity":true, 46 | "build/":true, 47 | "Build/":true, 48 | "Library/":true, 49 | "library/":true, 50 | "obj/":true, 51 | "Obj/":true, 52 | "ProjectSettings/":true, 53 | "temp/":true, 54 | "Temp/":true 55 | } 56 | } -------------------------------------------------------------------------------- /Unity Project/ProjectSettings/NavMeshAreas.asset: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | %TAG !u! tag:unity3d.com,2011: 3 | --- !u!126 &1 4 | NavMeshProjectSettings: 5 | m_ObjectHideFlags: 0 6 | serializedVersion: 2 7 | areas: 8 | - name: Walkable 9 | cost: 1 10 | - name: Not Walkable 11 | cost: 1 12 | - name: Jump 13 | cost: 2 14 | - name: 15 | cost: 1 16 | - name: 17 | cost: 1 18 | - name: 19 | cost: 1 20 | - name: 21 | cost: 1 22 | - name: 23 | cost: 1 24 | - name: 25 | cost: 1 26 | - name: 27 | cost: 1 28 | - name: 29 | cost: 1 30 | - name: 31 | cost: 1 32 | - name: 33 | cost: 1 34 | - name: 35 | cost: 1 36 | - name: 37 | cost: 1 38 | - name: 39 | cost: 1 40 | - name: 41 | cost: 1 42 | - name: 43 | cost: 1 44 | - name: 45 | cost: 1 46 | - name: 47 | cost: 1 48 | - name: 49 | cost: 1 50 | - name: 51 | cost: 1 52 | - name: 53 | cost: 1 54 | - name: 55 | cost: 1 56 | - name: 57 | cost: 1 58 | - name: 59 | cost: 1 60 | - name: 61 | cost: 1 62 | - name: 63 | cost: 1 64 | - name: 65 | cost: 1 66 | - name: 67 | cost: 1 68 | - name: 69 | cost: 1 70 | - name: 71 | cost: 1 72 | m_LastAgentTypeID: -887442657 73 | m_Settings: 74 | - serializedVersion: 2 75 | agentTypeID: 0 76 | agentRadius: 0.5 77 | agentHeight: 2 78 | agentSlope: 45 79 | agentClimb: 0.75 80 | ledgeDropHeight: 0 81 | maxJumpAcrossDistance: 0 82 | minRegionArea: 2 83 | manualCellSize: 0 84 | cellSize: 0.16666667 85 | manualTileSize: 0 86 | tileSize: 256 87 | accuratePlacement: 0 88 | debug: 89 | m_Flags: 0 90 | m_SettingNames: 91 | - Humanoid 92 | -------------------------------------------------------------------------------- /Unity Project/Assets/Plugins/Farrokh Games/SpriteAnimation/Shared/IAnimator.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using FarrokhGames.SpriteAnimation.Shared; 3 | 4 | namespace FarrokhGames.SpriteAnimation 5 | { 6 | /// 7 | /// Shared interface for all animators 8 | /// 9 | public interface IAnimator : IDisposable 10 | { 11 | /// 12 | /// Invoked when the current clip has completed its animation 13 | /// 14 | Action OnClipComplete { get; set; } 15 | 16 | /// 17 | /// Invoked when playing a frame with a trigger on it 18 | /// 19 | Action OnTrigger { get; set; } 20 | 21 | /// 22 | /// Returns true if an animation is currently playing 23 | /// 24 | bool IsPlaying { get; } 25 | 26 | /// 27 | /// Returns the current clip 28 | /// 29 | IClip CurrentClip { get; } 30 | 31 | /// 32 | /// Plays the given clip 33 | /// 34 | /// The clip to play 35 | void Play(IClip clip); 36 | 37 | /// 38 | /// Tries to find and play a clip of given name 39 | /// 40 | /// The name of the clip to play 41 | bool Play(string clipName); 42 | 43 | /// 44 | /// Pauses the current animation 45 | /// 46 | void Pause(); 47 | 48 | /// 49 | /// Resumes the current animation 50 | /// 51 | void Resume(); 52 | 53 | /// 54 | /// Gets or sets wether to flip this animator or not 55 | /// 56 | bool Flip { get; set; } 57 | 58 | /// 59 | /// How to handle the relationship with a parent animator 60 | /// 61 | AnimatorChildMode ChildMode { get; } 62 | } 63 | } -------------------------------------------------------------------------------- /Unity Project/Assets/Plugins/Farrokh Games/SpriteAnimation/Image/ImageAnimator.cs: -------------------------------------------------------------------------------- 1 | using System.Linq; 2 | using FarrokhGames.SpriteAnimation.Shared; 3 | using UnityEngine; 4 | 5 | namespace FarrokhGames.SpriteAnimation.Image 6 | { 7 | /// 8 | [RequireComponent(typeof(UnityEngine.UI.Image))] 9 | public class ImageAnimator : AbstractSpriteAnimator, IImageAnimator 10 | { 11 | [SerializeField, Tooltip("If true, the image will update to its native size whenever it changes")] bool _forceNativeSize = true; 12 | 13 | UnityEngine.UI.Image _image; 14 | IAnimator[] _children; 15 | Vector3 _startScale; 16 | 17 | /// 18 | protected override void Init() 19 | { 20 | _image = GetComponent(); 21 | _startScale = _image.rectTransform.localScale; 22 | _children = GetComponentsInChildren().Where(x => !x.Equals(this)).ToArray(); 23 | } 24 | 25 | /// 26 | protected override void HandleFrameChanged(int index) 27 | { 28 | _image.sprite = _sprites[index]; 29 | if (_forceNativeSize) { _image.SetNativeSize(); } 30 | } 31 | 32 | /// 33 | public bool Visible 34 | { 35 | get { return gameObject.activeSelf; } 36 | set { gameObject.SetActive(value); } 37 | } 38 | 39 | /// 40 | public override bool Flip 41 | { 42 | get { return _image.rectTransform.localScale.x < 0; } 43 | set 44 | { 45 | // Flip children 46 | if (_animateChildren && _children != null && _children.Length > 0) 47 | { 48 | for (var i = 0; i < _children.Length; i++) 49 | { 50 | var child = _children[i]; 51 | if (child != null) { child.Flip = value; } 52 | } 53 | } 54 | 55 | if (_allowFlipping) { _image.rectTransform.localScale = new Vector3(value ? -_startScale.x : _startScale.x, _startScale.y, _startScale.z); } 56 | } 57 | } 58 | } 59 | } -------------------------------------------------------------------------------- /Unity Project/ProjectSettings/Physics2DSettings.asset: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | %TAG !u! tag:unity3d.com,2011: 3 | --- !u!19 &1 4 | Physics2DSettings: 5 | m_ObjectHideFlags: 0 6 | serializedVersion: 3 7 | m_Gravity: {x: 0, y: -9.81} 8 | m_DefaultMaterial: {fileID: 0} 9 | m_VelocityIterations: 8 10 | m_PositionIterations: 3 11 | m_VelocityThreshold: 1 12 | m_MaxLinearCorrection: 0.2 13 | m_MaxAngularCorrection: 8 14 | m_MaxTranslationSpeed: 100 15 | m_MaxRotationSpeed: 360 16 | m_BaumgarteScale: 0.2 17 | m_BaumgarteTimeOfImpactScale: 0.75 18 | m_TimeToSleep: 0.5 19 | m_LinearSleepTolerance: 0.01 20 | m_AngularSleepTolerance: 2 21 | m_DefaultContactOffset: 0.01 22 | m_JobOptions: 23 | serializedVersion: 2 24 | useMultithreading: 0 25 | useConsistencySorting: 0 26 | m_InterpolationPosesPerJob: 100 27 | m_NewContactsPerJob: 30 28 | m_CollideContactsPerJob: 100 29 | m_ClearFlagsPerJob: 200 30 | m_ClearBodyForcesPerJob: 200 31 | m_SyncDiscreteFixturesPerJob: 50 32 | m_SyncContinuousFixturesPerJob: 50 33 | m_FindNearestContactsPerJob: 100 34 | m_UpdateTriggerContactsPerJob: 100 35 | m_IslandSolverCostThreshold: 100 36 | m_IslandSolverBodyCostScale: 1 37 | m_IslandSolverContactCostScale: 10 38 | m_IslandSolverJointCostScale: 10 39 | m_IslandSolverBodiesPerJob: 50 40 | m_IslandSolverContactsPerJob: 50 41 | m_AutoSimulation: 1 42 | m_QueriesHitTriggers: 1 43 | m_QueriesStartInColliders: 1 44 | m_CallbacksOnDisable: 1 45 | m_AutoSyncTransforms: 1 46 | m_AlwaysShowColliders: 0 47 | m_ShowColliderSleep: 1 48 | m_ShowColliderContacts: 0 49 | m_ShowColliderAABB: 0 50 | m_ContactArrowScale: 0.2 51 | m_ColliderAwakeColor: {r: 0.5686275, g: 0.95686275, b: 0.54509807, a: 0.7529412} 52 | m_ColliderAsleepColor: {r: 0.5686275, g: 0.95686275, b: 0.54509807, a: 0.36078432} 53 | m_ColliderContactColor: {r: 1, g: 0, b: 1, a: 0.6862745} 54 | m_ColliderAABBColor: {r: 1, g: 1, b: 0, a: 0.2509804} 55 | m_LayerCollisionMatrix: ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff 56 | -------------------------------------------------------------------------------- /Unity Project/ProjectSettings/GraphicsSettings.asset: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | %TAG !u! tag:unity3d.com,2011: 3 | --- !u!30 &1 4 | GraphicsSettings: 5 | m_ObjectHideFlags: 0 6 | serializedVersion: 12 7 | m_Deferred: 8 | m_Mode: 1 9 | m_Shader: {fileID: 69, guid: 0000000000000000f000000000000000, type: 0} 10 | m_DeferredReflections: 11 | m_Mode: 1 12 | m_Shader: {fileID: 74, guid: 0000000000000000f000000000000000, type: 0} 13 | m_ScreenSpaceShadows: 14 | m_Mode: 1 15 | m_Shader: {fileID: 64, guid: 0000000000000000f000000000000000, type: 0} 16 | m_LegacyDeferred: 17 | m_Mode: 1 18 | m_Shader: {fileID: 63, guid: 0000000000000000f000000000000000, type: 0} 19 | m_DepthNormals: 20 | m_Mode: 1 21 | m_Shader: {fileID: 62, guid: 0000000000000000f000000000000000, type: 0} 22 | m_MotionVectors: 23 | m_Mode: 1 24 | m_Shader: {fileID: 75, guid: 0000000000000000f000000000000000, type: 0} 25 | m_LightHalo: 26 | m_Mode: 1 27 | m_Shader: {fileID: 105, guid: 0000000000000000f000000000000000, type: 0} 28 | m_LensFlare: 29 | m_Mode: 1 30 | m_Shader: {fileID: 102, guid: 0000000000000000f000000000000000, type: 0} 31 | m_AlwaysIncludedShaders: 32 | - {fileID: 10753, guid: 0000000000000000f000000000000000, type: 0} 33 | - {fileID: 10770, guid: 0000000000000000f000000000000000, type: 0} 34 | - {fileID: 10783, guid: 0000000000000000f000000000000000, type: 0} 35 | m_PreloadedShaders: [] 36 | m_SpritesDefaultMaterial: {fileID: 10754, guid: 0000000000000000f000000000000000, 37 | type: 0} 38 | m_CustomRenderPipeline: {fileID: 0} 39 | m_TransparencySortMode: 0 40 | m_TransparencySortAxis: {x: 0, y: 0, z: 1} 41 | m_DefaultRenderingPath: 1 42 | m_DefaultMobileRenderingPath: 1 43 | m_TierSettings: [] 44 | m_LightmapStripping: 0 45 | m_FogStripping: 0 46 | m_InstancingStripping: 0 47 | m_LightmapKeepPlain: 1 48 | m_LightmapKeepDirCombined: 1 49 | m_LightmapKeepDynamicPlain: 1 50 | m_LightmapKeepDynamicDirCombined: 1 51 | m_LightmapKeepShadowMask: 1 52 | m_LightmapKeepSubtractive: 1 53 | m_FogKeepLinear: 1 54 | m_FogKeepExp: 1 55 | m_FogKeepExp2: 1 56 | m_AlbedoSwatchInfos: [] 57 | m_LightsUseLinearIntensity: 0 58 | m_LightsUseColorTemperature: 0 59 | -------------------------------------------------------------------------------- /Unity Project/Assets/Plugins/Farrokh Games/SpriteAnimation/Editor/FramePropertDrawer.cs: -------------------------------------------------------------------------------- 1 | using UnityEditor; 2 | using UnityEngine; 3 | 4 | namespace FarrokhGames.SpriteAnimation.Frame 5 | { 6 | [CustomPropertyDrawer(typeof(Frame))] 7 | class IngredientDrawer : PropertyDrawer 8 | { 9 | public override void OnGUI(Rect position, SerializedProperty property, GUIContent label) 10 | { 11 | 12 | EditorGUI.LabelField(position, ""); //label.text.Replace("Element", "")); 13 | 14 | // Using BeginProperty / EndProperty on the parent property means that 15 | // prefab override logic works on the entire property. 16 | EditorGUI.BeginProperty(position, label, property); 17 | 18 | // Draw label 19 | position = EditorGUI.PrefixLabel(position, GUIUtility.GetControlID(FocusType.Passive), label); 20 | 21 | // Don't make child fields be indented 22 | var indent = EditorGUI.indentLevel; 23 | EditorGUI.indentLevel = 0; 24 | 25 | // Calculate rects 26 | Rect indexLabelRect = new Rect(position.x, position.y, 40, position.height); 27 | Rect indexRect = new Rect(position.x + 40, position.y, 30, position.height); 28 | 29 | Rect speedLabelRect = new Rect(position.x + 70, position.y, 40, position.height); 30 | Rect speedRect = new Rect(position.x + 110, position.y, 30, position.height); 31 | 32 | Rect triggerLabelRect = new Rect(position.x + 140, position.y, 45, position.height); 33 | Rect triggerRect = new Rect(position.x + 185, position.y, position.width - 185, position.height); 34 | 35 | // Draw fields - passs GUIContent.none to each so they are drawn without labels 36 | EditorGUI.PrefixLabel(indexLabelRect, new GUIContent("index")); 37 | EditorGUI.PropertyField(indexRect, property.FindPropertyRelative("_index"), GUIContent.none); 38 | EditorGUI.PrefixLabel(speedLabelRect, new GUIContent("speed")); 39 | EditorGUI.PropertyField(speedRect, property.FindPropertyRelative("_speed"), GUIContent.none); 40 | EditorGUI.PrefixLabel(triggerLabelRect, new GUIContent("trigger")); 41 | EditorGUI.PropertyField(triggerRect, property.FindPropertyRelative("_triggerName"), GUIContent.none); 42 | 43 | // Set indent back to what it was 44 | EditorGUI.indentLevel = indent; 45 | 46 | EditorGUI.EndProperty(); 47 | } 48 | } 49 | } -------------------------------------------------------------------------------- /Unity Project/Assets/Plugins/Farrokh Games/SpriteAnimation/Sprite/SpriteAnimator.cs: -------------------------------------------------------------------------------- 1 | using System.Linq; 2 | using FarrokhGames.SpriteAnimation.Shared; 3 | using UnityEngine; 4 | 5 | namespace FarrokhGames.SpriteAnimation.Sprite 6 | { 7 | /// 8 | [RequireComponent(typeof(SpriteRenderer))] 9 | public class SpriteAnimator : AbstractSpriteAnimator, ISpriteAnimator 10 | { 11 | SpriteRenderer _spriteRenderer; 12 | IAnimator[] _children; 13 | int _originalSortingOrder; 14 | 15 | /// 16 | protected override void Init() 17 | { 18 | _spriteRenderer = GetComponent(); 19 | _originalSortingOrder = _spriteRenderer.sortingOrder; 20 | _children = GetComponentsInChildren().Where(x => !x.Equals(this)).ToArray(); 21 | } 22 | 23 | /// 24 | protected override void HandleFrameChanged(int index) 25 | { 26 | _spriteRenderer.sprite = _sprites[index]; 27 | } 28 | 29 | /// 30 | public bool Visible 31 | { 32 | get { return gameObject.activeSelf; } 33 | set { gameObject.SetActive(value); } 34 | } 35 | 36 | /// 37 | public int SortingOrder 38 | { 39 | get { return _spriteRenderer.sortingOrder; } 40 | set 41 | { 42 | // Set sorting order of children 43 | if (_animateChildren && _children != null && _children.Length > 0) 44 | { 45 | for (var i = 0; i < _children.Length; i++) 46 | { 47 | var child = _children[i]; 48 | if (child != null && child is ISpriteAnimator) 49 | { 50 | (child as ISpriteAnimator).SortingOrder = value; 51 | } 52 | } 53 | } 54 | 55 | _spriteRenderer.sortingOrder = value + _originalSortingOrder; 56 | } 57 | } 58 | 59 | /// 60 | public override bool Flip 61 | { 62 | get { return _spriteRenderer.flipX; } 63 | set 64 | { 65 | // Flip children 66 | if (_animateChildren && _children != null && _children.Length > 0) 67 | { 68 | for (var i = 0; i < _children.Length; i++) 69 | { 70 | var child = _children[i]; 71 | if (child != null) { child.Flip = value; } 72 | } 73 | } 74 | 75 | if (_allowFlipping) { _spriteRenderer.flipX = value; } 76 | } 77 | } 78 | } 79 | } -------------------------------------------------------------------------------- /Unity Project/Assets/Plugins/Farrokh Games/SpriteAnimation/Frame/IFrameAnimator.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace FarrokhGames.SpriteAnimation 4 | { 5 | /// 6 | /// Returns frame changes when playing given clips. Used as a base for other, more concerete, animators. 7 | /// 8 | public interface IFrameAnimator : IDisposable, IAnimator 9 | { 10 | /// 11 | /// Invoked when the current frame was changed. 12 | /// int - The index of the new frame 13 | /// 14 | /// 15 | Action OnFrameChanged { get; set; } 16 | 17 | /// 18 | /// Ticks the animator using given delta time 19 | /// This must be done in order to run the animations 20 | /// 21 | /// The time delta 22 | void Tick(float deltaTime); 23 | 24 | /// 25 | /// Sets the children of this animator 26 | /// 27 | void SetChildren(IAnimator[] children); 28 | } 29 | 30 | /// 31 | /// Contains information about a single animation clip 32 | /// 33 | public interface IClip 34 | { 35 | /// 36 | /// Returns the name of the clip 37 | /// 38 | string Name { get; } 39 | 40 | /// 41 | /// Returns wether this clip loops or not. 42 | /// Note that looping clips never actually completes 43 | /// 44 | bool Loop { get; } 45 | 46 | /// 47 | /// Returns true if this clip should start on a random frame or the first 48 | /// 49 | bool RandomStart { get; } 50 | 51 | /// 52 | /// Returns the framerate (in frames per seconds) of this clip 53 | /// 54 | float FrameRate { get; } 55 | 56 | /// 57 | /// Returns the number of frames in this clip 58 | /// 59 | int FrameCount { get; } 60 | 61 | /// 62 | /// Returns the frame at given index 63 | /// 64 | IFrame this [int index] { get; } 65 | } 66 | 67 | /// 68 | /// Contains information about a single frame 69 | /// 70 | public interface IFrame 71 | { 72 | /// 73 | /// Returns the index of this frame 74 | /// 75 | int Index { get; } 76 | 77 | /// 78 | /// Returns the speed modifier of this frame (usually 1.0) 79 | /// Use this to speed up or slow down a single frame 80 | /// 81 | float Speed { get; } 82 | 83 | /// 84 | /// Returns true if this frame contains a trigger 85 | /// 86 | bool HasTrigger { get; } 87 | 88 | /// 89 | /// Returns the name of the trigger associated with this frame. 90 | /// 91 | string TriggerName { get; } 92 | } 93 | } -------------------------------------------------------------------------------- /Unity Project/Assets/Plugins/Farrokh Games/SpriteAnimation/Editor/SpriteAnimatorEditor.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using FarrokhGames.SpriteAnimation.Frame; 5 | using UnityEditor; 6 | using UnityEditorInternal; 7 | using UnityEngine; 8 | 9 | namespace FarrokhGames.SpriteAnimation.Sprite 10 | { 11 | [CustomEditor(typeof(SpriteAnimator))] 12 | public class SpriteAnimatorEditor : Editor 13 | { 14 | SerializedProperty _sprites; 15 | SerializedProperty _clips; 16 | ReorderableList _clipList; 17 | 18 | float Height { get { return EditorGUIUtility.singleLineHeight * 1.1f; } } 19 | 20 | public void OnEnable() 21 | { 22 | _sprites = serializedObject.FindProperty("_sprites"); 23 | _clips = serializedObject.FindProperty("_clips"); 24 | _clipList = new ReorderableList(serializedObject, _clips); 25 | _clipList.drawHeaderCallback += DrawClipHeader; 26 | _clipList.drawElementCallback += DrawClipElement; 27 | _clipList.elementHeight = 12 + (Height * 4f); 28 | 29 | } 30 | 31 | void DrawClipHeader(Rect rect) 32 | { 33 | GUI.Label(rect, "Clips"); 34 | } 35 | 36 | void DrawClipElement(Rect rect, int index, bool isActive, bool isFocused) 37 | { 38 | var item = _clips.GetArrayElementAtIndex(index); // as IClip; 39 | 40 | EditorGUI.BeginChangeCheck(); 41 | 42 | rect.y += 4; 43 | EditorGUI.PropertyField(new Rect(rect.x, rect.y, rect.width, Height), item.FindPropertyRelative("_name"), new GUIContent("Name")); 44 | rect.y += Height; 45 | EditorGUI.PropertyField(new Rect(rect.x, rect.y, rect.width, Height), item.FindPropertyRelative("_loop"), new GUIContent("Loop")); 46 | rect.y += Height; 47 | EditorGUI.PropertyField(new Rect(rect.x, rect.y, rect.width, Height), item.FindPropertyRelative("_randomStart"), new GUIContent("Random Start")); 48 | rect.y += Height; 49 | EditorGUI.PropertyField(new Rect(rect.x, rect.y, rect.width, Height), item.FindPropertyRelative("_frameRate"), new GUIContent("Frame Rate")); 50 | rect.y += Height; 51 | 52 | // End line 53 | rect.y += 4; 54 | EditorGUI.DrawRect(new Rect(rect.x, rect.y, rect.width, 1), Color.gray); 55 | 56 | if (EditorGUI.EndChangeCheck()) 57 | { 58 | EditorUtility.SetDirty(target); 59 | } 60 | } 61 | 62 | public override void OnInspectorGUI() 63 | { 64 | base.DrawDefaultInspector(); 65 | 66 | return; 67 | EditorGUILayout.Space(); 68 | 69 | serializedObject.Update(); 70 | EditorGUI.BeginChangeCheck(); 71 | EditorGUILayout.PropertyField(_sprites, true); 72 | _clipList.DoLayoutList(); 73 | 74 | if (EditorGUI.EndChangeCheck()) 75 | { 76 | serializedObject.ApplyModifiedProperties(); 77 | } 78 | } 79 | } 80 | } -------------------------------------------------------------------------------- /Unity Project/Assets/Plugins/Farrokh Games/SpriteAnimation/Transform/TransformAnimator.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Linq; 3 | using FarrokhGames.SpriteAnimation.Shared; 4 | using UnityEngine; 5 | 6 | namespace FarrokhGames.SpriteAnimation.Transform 7 | { 8 | /// 9 | /// IAnimatorBase-implementation for Unity's Transforms 10 | /// 11 | [RequireComponent(typeof(UnityEngine.Transform))] 12 | public class TransformAnimator : MonoBehaviour, IAnimator 13 | { 14 | [SerializeField, Tooltip("The clip names that will enable this transform")] string[] _clips; 15 | [SerializeField, Tooltip("How to handle the relationship with a parent animator")] AnimatorChildMode _childMode; 16 | [SerializeField, Tooltip("If false, any attempts to flip this image is suppressed")] bool _allowFlipping = true; 17 | 18 | Vector3 _startScale; 19 | 20 | /// 21 | public Action OnClipComplete 22 | { 23 | get { throw new NotImplementedException(); } 24 | set { throw new NotImplementedException(); } 25 | } 26 | 27 | /// 28 | public Action OnTrigger 29 | { 30 | get { throw new NotImplementedException(); } 31 | set { throw new NotImplementedException(); } 32 | } 33 | 34 | /// 35 | public bool IsPlaying { get { return gameObject.activeSelf; } } 36 | 37 | /// 38 | public IClip CurrentClip { get { return null; } } 39 | 40 | /// 41 | public AnimatorChildMode ChildMode { get { return _childMode; } } 42 | 43 | /// 44 | public bool Flip 45 | { 46 | get { return transform.localScale.x < 0; } 47 | set 48 | { 49 | if (_allowFlipping && Flip != value) 50 | { 51 | transform.localScale = new Vector3(value ? -_startScale.x : _startScale.x, _startScale.y, _startScale.z); 52 | } 53 | } 54 | } 55 | 56 | /// 57 | public void Play(IClip clip) 58 | { 59 | if (clip != null) 60 | { 61 | Play(clip.Name); 62 | } 63 | } 64 | 65 | /// 66 | public bool Play(string clipName) 67 | { 68 | var shouldBeActive = _clips.Contains(clipName); 69 | gameObject.SetActive(shouldBeActive); 70 | return shouldBeActive; 71 | } 72 | 73 | /// 74 | public void Pause() 75 | { 76 | // Do nothing 77 | } 78 | 79 | /// 80 | public void Resume() 81 | { 82 | // Do nothing 83 | } 84 | 85 | /// 86 | public void Dispose() 87 | { 88 | // Do nothing 89 | } 90 | 91 | #region MonoBehavior (Unity) 92 | 93 | void Awake() 94 | { 95 | _startScale = transform.localScale; 96 | } 97 | 98 | #endregion 99 | } 100 | } -------------------------------------------------------------------------------- /Unity Project/Assets/Plugins/Farrokh Games/SpriteAnimation/Particle/ParticleSystemAnimator.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Linq; 3 | using FarrokhGames.SpriteAnimation.Shared; 4 | using UnityEngine; 5 | 6 | namespace FarrokhGames.SpriteAnimation.Particle 7 | { 8 | /// 9 | /// IAnimatorBase-implementation for Unity's ParticleSystem 10 | /// 11 | [RequireComponent(typeof(ParticleSystem))] 12 | public class ParticleSystemAnimator : MonoBehaviour, IAnimator 13 | { 14 | [SerializeField, Tooltip("The clip names that will trigger this particle system")] string[] _clips; 15 | [SerializeField, Tooltip("Wether the particle system should operate together with its children")] bool _withChildren; 16 | [SerializeField, Tooltip("How should the particle system behave when stopping an animation")] StopMode _stopMode; 17 | [SerializeField, Tooltip("How to handle the relationship with a parent animator")] AnimatorChildMode _childMode; 18 | [SerializeField, Tooltip("If false, any attempts to flip this image is suppressed")] bool _allowFlipping = true; 19 | 20 | ParticleSystem _particleSystem; 21 | bool _isPaused = false; 22 | Vector3 _startScale; 23 | 24 | public enum StopMode 25 | { 26 | Stop, 27 | Clear, 28 | } 29 | 30 | /// 31 | public Action OnClipComplete 32 | { 33 | get { throw new NotImplementedException(); } 34 | set { throw new NotImplementedException(); } 35 | } 36 | 37 | /// 38 | public Action OnTrigger 39 | { 40 | get { throw new NotImplementedException(); } 41 | set { throw new NotImplementedException(); } 42 | } 43 | 44 | /// 45 | public bool IsPlaying { get { return _particleSystem.isPlaying; } } 46 | 47 | /// 48 | public IClip CurrentClip { get { return null; } } 49 | 50 | /// 51 | public AnimatorChildMode ChildMode { get { return _childMode; } } 52 | 53 | /// 54 | public bool Flip 55 | { 56 | get { return transform.localScale.x < 0; } 57 | set 58 | { 59 | if (_allowFlipping && Flip != value) 60 | { 61 | if (_particleSystem.isPlaying) 62 | { 63 | _particleSystem.Clear(); 64 | Play(); 65 | } 66 | transform.localScale = new Vector3(value ? -_startScale.x : _startScale.x, _startScale.y, _startScale.z); 67 | } 68 | } 69 | } 70 | 71 | /// 72 | public void Play(IClip clip) 73 | { 74 | if (clip != null) 75 | { 76 | Play(clip.Name); 77 | } 78 | } 79 | 80 | /// 81 | public bool Play(string clipName) 82 | { 83 | if (_clips.Contains(clipName)) 84 | { 85 | Play(); 86 | return true; 87 | } 88 | else 89 | { 90 | _isPaused = false; 91 | _particleSystem.Stop(_withChildren, _stopMode == StopMode.Clear ? ParticleSystemStopBehavior.StopEmittingAndClear : ParticleSystemStopBehavior.StopEmitting); 92 | return false; 93 | } 94 | } 95 | 96 | void Play() 97 | { 98 | if (!IsPlaying) 99 | { 100 | _particleSystem.Play(_withChildren); 101 | _isPaused = false; 102 | } 103 | } 104 | 105 | /// 106 | public void Pause() 107 | { 108 | _particleSystem.Pause(_withChildren); 109 | _isPaused = true; 110 | } 111 | 112 | /// 113 | public void Resume() 114 | { 115 | if (_isPaused) 116 | { 117 | Play(); 118 | } 119 | } 120 | 121 | public void Dispose() 122 | { 123 | // Do nothing 124 | } 125 | 126 | #region MonoBehavior (Unity) 127 | 128 | void Awake() 129 | { 130 | _particleSystem = GetComponent(); 131 | _startScale = gameObject.transform.localScale; 132 | } 133 | 134 | #endregion 135 | } 136 | } -------------------------------------------------------------------------------- /Unity Project/Assets/Plugins/Farrokh Games/SpriteAnimation/Shared/AbstractSpriteAnimator.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Linq; 3 | using FarrokhGames.SpriteAnimation.Frame; 4 | using UnityEngine; 5 | 6 | namespace FarrokhGames.SpriteAnimation.Shared 7 | { 8 | public abstract class AbstractSpriteAnimator : MonoBehaviour, IAnimator 9 | { 10 | [SerializeField, Tooltip("A list of sprites to use with this animator. A frames index directly corresponds to an index in this list.")] protected UnityEngine.Sprite[] _sprites; 11 | [SerializeField, Tooltip("The clips that can be used by this animator")] protected Clip[] _clips; 12 | [SerializeField, Tooltip("If true, any children under this animator will be played, paused and resumed together with this parent")] protected bool _animateChildren = true; 13 | [SerializeField, Tooltip("How to handle the relationship with a parent animator")] AnimatorChildMode _childMode; 14 | [SerializeField, Tooltip("If false, any attempts to flip this image is suppressed")] protected bool _allowFlipping = true; 15 | 16 | internal IFrameAnimator _frameAnimator; 17 | 18 | /// 19 | public Action OnClipComplete { get; set; } 20 | 21 | /// 22 | public Action OnTrigger { get; set; } 23 | 24 | /// 25 | public bool IsPlaying { get { return _frameAnimator.IsPlaying; } } 26 | 27 | /// 28 | public IClip CurrentClip { get { return _frameAnimator.CurrentClip; } } 29 | 30 | /// 31 | public AnimatorChildMode ChildMode { get { return _childMode; } } 32 | 33 | /// 34 | public abstract bool Flip { get; set; } 35 | 36 | /// 37 | /// Invoked when this animator is created 38 | /// 39 | protected abstract void Init(); 40 | 41 | /// 42 | /// Invoked when the frame of the animation changes 43 | /// 44 | protected abstract void HandleFrameChanged(int index); 45 | 46 | void HandleClipComplete() 47 | { 48 | if (OnClipComplete != null) { OnClipComplete(); } 49 | } 50 | 51 | void HandleTrigger(string triggerName) 52 | { 53 | if (OnTrigger != null) { OnTrigger(triggerName); } 54 | } 55 | 56 | /// 57 | public void Play(IClip clip) 58 | { 59 | _frameAnimator.Play(clip); 60 | } 61 | 62 | /// 63 | public bool Play(string clipName) 64 | { 65 | return _frameAnimator.Play(clipName); 66 | } 67 | 68 | /// 69 | public void Pause() 70 | { 71 | _frameAnimator.Pause(); 72 | } 73 | 74 | /// 75 | public void Resume() 76 | { 77 | _frameAnimator.Resume(); 78 | } 79 | 80 | /// 81 | public void Dispose() 82 | { 83 | OnClipComplete = null; 84 | OnTrigger = null; 85 | _frameAnimator.Dispose(); 86 | _frameAnimator = null; 87 | } 88 | 89 | #region MonoBehavior (Unity) 90 | 91 | void Awake() 92 | { 93 | _frameAnimator = new FrameAnimator(_clips, _childMode); 94 | Init(); 95 | } 96 | 97 | void Start() 98 | { 99 | if (_animateChildren) 100 | { 101 | var childAnimators = GetComponentsInChildren().Where(x => !x.Equals(this)).ToArray(); 102 | _frameAnimator.SetChildren(childAnimators); 103 | } 104 | 105 | // Start first animation 106 | if (!_frameAnimator.IsPlaying && _clips != null && _clips.Length > 0) 107 | { 108 | _frameAnimator.Play(_clips[0]); 109 | } 110 | } 111 | 112 | void OnEnable() 113 | { 114 | _frameAnimator.OnClipComplete += HandleClipComplete; 115 | _frameAnimator.OnFrameChanged += HandleFrameChanged; 116 | _frameAnimator.OnTrigger += HandleTrigger; 117 | } 118 | 119 | void OnDisable() 120 | { 121 | _frameAnimator.OnClipComplete -= HandleClipComplete; 122 | _frameAnimator.OnFrameChanged -= HandleFrameChanged; 123 | _frameAnimator.OnTrigger -= HandleTrigger; 124 | } 125 | 126 | void Update() 127 | { 128 | _frameAnimator.Tick(Time.deltaTime); 129 | } 130 | 131 | void OnDestroyed() 132 | { 133 | Dispose(); 134 | } 135 | 136 | #endregion 137 | } 138 | } -------------------------------------------------------------------------------- /Unity Project/ProjectSettings/QualitySettings.asset: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | %TAG !u! tag:unity3d.com,2011: 3 | --- !u!47 &1 4 | QualitySettings: 5 | m_ObjectHideFlags: 0 6 | serializedVersion: 5 7 | m_CurrentQuality: 3 8 | m_QualitySettings: 9 | - serializedVersion: 2 10 | name: Very Low 11 | pixelLightCount: 0 12 | shadows: 0 13 | shadowResolution: 0 14 | shadowProjection: 1 15 | shadowCascades: 1 16 | shadowDistance: 15 17 | shadowNearPlaneOffset: 3 18 | shadowCascade2Split: 0.33333334 19 | shadowCascade4Split: {x: 0.06666667, y: 0.2, z: 0.46666667} 20 | shadowmaskMode: 0 21 | blendWeights: 1 22 | textureQuality: 1 23 | anisotropicTextures: 0 24 | antiAliasing: 0 25 | softParticles: 0 26 | softVegetation: 0 27 | realtimeReflectionProbes: 0 28 | billboardsFaceCameraPosition: 0 29 | vSyncCount: 0 30 | lodBias: 0.3 31 | maximumLODLevel: 0 32 | particleRaycastBudget: 4 33 | asyncUploadTimeSlice: 2 34 | asyncUploadBufferSize: 4 35 | resolutionScalingFixedDPIFactor: 1 36 | excludedTargetPlatforms: [] 37 | - serializedVersion: 2 38 | name: Low 39 | pixelLightCount: 0 40 | shadows: 0 41 | shadowResolution: 0 42 | shadowProjection: 1 43 | shadowCascades: 1 44 | shadowDistance: 20 45 | shadowNearPlaneOffset: 3 46 | shadowCascade2Split: 0.33333334 47 | shadowCascade4Split: {x: 0.06666667, y: 0.2, z: 0.46666667} 48 | shadowmaskMode: 0 49 | blendWeights: 2 50 | textureQuality: 0 51 | anisotropicTextures: 0 52 | antiAliasing: 0 53 | softParticles: 0 54 | softVegetation: 0 55 | realtimeReflectionProbes: 0 56 | billboardsFaceCameraPosition: 0 57 | vSyncCount: 0 58 | lodBias: 0.4 59 | maximumLODLevel: 0 60 | particleRaycastBudget: 16 61 | asyncUploadTimeSlice: 2 62 | asyncUploadBufferSize: 4 63 | resolutionScalingFixedDPIFactor: 1 64 | excludedTargetPlatforms: [] 65 | - serializedVersion: 2 66 | name: Medium 67 | pixelLightCount: 1 68 | shadows: 0 69 | shadowResolution: 0 70 | shadowProjection: 1 71 | shadowCascades: 1 72 | shadowDistance: 20 73 | shadowNearPlaneOffset: 3 74 | shadowCascade2Split: 0.33333334 75 | shadowCascade4Split: {x: 0.06666667, y: 0.2, z: 0.46666667} 76 | shadowmaskMode: 0 77 | blendWeights: 2 78 | textureQuality: 0 79 | anisotropicTextures: 0 80 | antiAliasing: 0 81 | softParticles: 0 82 | softVegetation: 0 83 | realtimeReflectionProbes: 0 84 | billboardsFaceCameraPosition: 0 85 | vSyncCount: 1 86 | lodBias: 0.7 87 | maximumLODLevel: 0 88 | particleRaycastBudget: 64 89 | asyncUploadTimeSlice: 2 90 | asyncUploadBufferSize: 4 91 | resolutionScalingFixedDPIFactor: 1 92 | excludedTargetPlatforms: [] 93 | - serializedVersion: 2 94 | name: High 95 | pixelLightCount: 2 96 | shadows: 0 97 | shadowResolution: 1 98 | shadowProjection: 1 99 | shadowCascades: 2 100 | shadowDistance: 40 101 | shadowNearPlaneOffset: 3 102 | shadowCascade2Split: 0.33333334 103 | shadowCascade4Split: {x: 0.06666667, y: 0.2, z: 0.46666667} 104 | shadowmaskMode: 1 105 | blendWeights: 2 106 | textureQuality: 0 107 | anisotropicTextures: 0 108 | antiAliasing: 0 109 | softParticles: 0 110 | softVegetation: 1 111 | realtimeReflectionProbes: 0 112 | billboardsFaceCameraPosition: 0 113 | vSyncCount: 1 114 | lodBias: 1 115 | maximumLODLevel: 0 116 | particleRaycastBudget: 256 117 | asyncUploadTimeSlice: 2 118 | asyncUploadBufferSize: 4 119 | resolutionScalingFixedDPIFactor: 1 120 | excludedTargetPlatforms: [] 121 | - serializedVersion: 2 122 | name: Very High 123 | pixelLightCount: 3 124 | shadows: 0 125 | shadowResolution: 2 126 | shadowProjection: 1 127 | shadowCascades: 2 128 | shadowDistance: 70 129 | shadowNearPlaneOffset: 3 130 | shadowCascade2Split: 0.33333334 131 | shadowCascade4Split: {x: 0.06666667, y: 0.2, z: 0.46666667} 132 | shadowmaskMode: 1 133 | blendWeights: 4 134 | textureQuality: 0 135 | anisotropicTextures: 0 136 | antiAliasing: 0 137 | softParticles: 0 138 | softVegetation: 1 139 | realtimeReflectionProbes: 0 140 | billboardsFaceCameraPosition: 0 141 | vSyncCount: 1 142 | lodBias: 1.5 143 | maximumLODLevel: 0 144 | particleRaycastBudget: 1024 145 | asyncUploadTimeSlice: 2 146 | asyncUploadBufferSize: 4 147 | resolutionScalingFixedDPIFactor: 1 148 | excludedTargetPlatforms: [] 149 | - serializedVersion: 2 150 | name: Ultra 151 | pixelLightCount: 4 152 | shadows: 0 153 | shadowResolution: 0 154 | shadowProjection: 1 155 | shadowCascades: 4 156 | shadowDistance: 150 157 | shadowNearPlaneOffset: 3 158 | shadowCascade2Split: 0.33333334 159 | shadowCascade4Split: {x: 0.06666667, y: 0.2, z: 0.46666667} 160 | shadowmaskMode: 1 161 | blendWeights: 4 162 | textureQuality: 0 163 | anisotropicTextures: 0 164 | antiAliasing: 0 165 | softParticles: 0 166 | softVegetation: 1 167 | realtimeReflectionProbes: 0 168 | billboardsFaceCameraPosition: 0 169 | vSyncCount: 1 170 | lodBias: 2 171 | maximumLODLevel: 0 172 | particleRaycastBudget: 4096 173 | asyncUploadTimeSlice: 2 174 | asyncUploadBufferSize: 4 175 | resolutionScalingFixedDPIFactor: 1 176 | excludedTargetPlatforms: [] 177 | m_PerPlatformDefaultQuality: 178 | Android: 2 179 | Nintendo 3DS: 5 180 | Nintendo Switch: 5 181 | PS4: 5 182 | PSM: 5 183 | PSP2: 2 184 | Standalone: 5 185 | Tizen: 2 186 | WebGL: 3 187 | WiiU: 5 188 | Windows Store Apps: 5 189 | XboxOne: 5 190 | iPhone: 2 191 | tvOS: 2 192 | -------------------------------------------------------------------------------- /Unity Project/ProjectSettings/InputManager.asset: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | %TAG !u! tag:unity3d.com,2011: 3 | --- !u!13 &1 4 | InputManager: 5 | m_ObjectHideFlags: 0 6 | serializedVersion: 2 7 | m_Axes: 8 | - serializedVersion: 3 9 | m_Name: Horizontal 10 | descriptiveName: 11 | descriptiveNegativeName: 12 | negativeButton: left 13 | positiveButton: right 14 | altNegativeButton: a 15 | altPositiveButton: d 16 | gravity: 3 17 | dead: 0.001 18 | sensitivity: 3 19 | snap: 1 20 | invert: 0 21 | type: 0 22 | axis: 0 23 | joyNum: 0 24 | - serializedVersion: 3 25 | m_Name: Vertical 26 | descriptiveName: 27 | descriptiveNegativeName: 28 | negativeButton: down 29 | positiveButton: up 30 | altNegativeButton: s 31 | altPositiveButton: w 32 | gravity: 3 33 | dead: 0.001 34 | sensitivity: 3 35 | snap: 1 36 | invert: 0 37 | type: 0 38 | axis: 0 39 | joyNum: 0 40 | - serializedVersion: 3 41 | m_Name: Fire1 42 | descriptiveName: 43 | descriptiveNegativeName: 44 | negativeButton: 45 | positiveButton: left ctrl 46 | altNegativeButton: 47 | altPositiveButton: mouse 0 48 | gravity: 1000 49 | dead: 0.001 50 | sensitivity: 1000 51 | snap: 0 52 | invert: 0 53 | type: 0 54 | axis: 0 55 | joyNum: 0 56 | - serializedVersion: 3 57 | m_Name: Fire2 58 | descriptiveName: 59 | descriptiveNegativeName: 60 | negativeButton: 61 | positiveButton: left alt 62 | altNegativeButton: 63 | altPositiveButton: mouse 1 64 | gravity: 1000 65 | dead: 0.001 66 | sensitivity: 1000 67 | snap: 0 68 | invert: 0 69 | type: 0 70 | axis: 0 71 | joyNum: 0 72 | - serializedVersion: 3 73 | m_Name: Fire3 74 | descriptiveName: 75 | descriptiveNegativeName: 76 | negativeButton: 77 | positiveButton: left shift 78 | altNegativeButton: 79 | altPositiveButton: mouse 2 80 | gravity: 1000 81 | dead: 0.001 82 | sensitivity: 1000 83 | snap: 0 84 | invert: 0 85 | type: 0 86 | axis: 0 87 | joyNum: 0 88 | - serializedVersion: 3 89 | m_Name: Jump 90 | descriptiveName: 91 | descriptiveNegativeName: 92 | negativeButton: 93 | positiveButton: space 94 | altNegativeButton: 95 | altPositiveButton: 96 | gravity: 1000 97 | dead: 0.001 98 | sensitivity: 1000 99 | snap: 0 100 | invert: 0 101 | type: 0 102 | axis: 0 103 | joyNum: 0 104 | - serializedVersion: 3 105 | m_Name: Mouse X 106 | descriptiveName: 107 | descriptiveNegativeName: 108 | negativeButton: 109 | positiveButton: 110 | altNegativeButton: 111 | altPositiveButton: 112 | gravity: 0 113 | dead: 0 114 | sensitivity: 0.1 115 | snap: 0 116 | invert: 0 117 | type: 1 118 | axis: 0 119 | joyNum: 0 120 | - serializedVersion: 3 121 | m_Name: Mouse Y 122 | descriptiveName: 123 | descriptiveNegativeName: 124 | negativeButton: 125 | positiveButton: 126 | altNegativeButton: 127 | altPositiveButton: 128 | gravity: 0 129 | dead: 0 130 | sensitivity: 0.1 131 | snap: 0 132 | invert: 0 133 | type: 1 134 | axis: 1 135 | joyNum: 0 136 | - serializedVersion: 3 137 | m_Name: Mouse ScrollWheel 138 | descriptiveName: 139 | descriptiveNegativeName: 140 | negativeButton: 141 | positiveButton: 142 | altNegativeButton: 143 | altPositiveButton: 144 | gravity: 0 145 | dead: 0 146 | sensitivity: 0.1 147 | snap: 0 148 | invert: 0 149 | type: 1 150 | axis: 2 151 | joyNum: 0 152 | - serializedVersion: 3 153 | m_Name: Horizontal 154 | descriptiveName: 155 | descriptiveNegativeName: 156 | negativeButton: 157 | positiveButton: 158 | altNegativeButton: 159 | altPositiveButton: 160 | gravity: 0 161 | dead: 0.19 162 | sensitivity: 1 163 | snap: 0 164 | invert: 0 165 | type: 2 166 | axis: 0 167 | joyNum: 0 168 | - serializedVersion: 3 169 | m_Name: Vertical 170 | descriptiveName: 171 | descriptiveNegativeName: 172 | negativeButton: 173 | positiveButton: 174 | altNegativeButton: 175 | altPositiveButton: 176 | gravity: 0 177 | dead: 0.19 178 | sensitivity: 1 179 | snap: 0 180 | invert: 1 181 | type: 2 182 | axis: 1 183 | joyNum: 0 184 | - serializedVersion: 3 185 | m_Name: Fire1 186 | descriptiveName: 187 | descriptiveNegativeName: 188 | negativeButton: 189 | positiveButton: joystick button 0 190 | altNegativeButton: 191 | altPositiveButton: 192 | gravity: 1000 193 | dead: 0.001 194 | sensitivity: 1000 195 | snap: 0 196 | invert: 0 197 | type: 0 198 | axis: 0 199 | joyNum: 0 200 | - serializedVersion: 3 201 | m_Name: Fire2 202 | descriptiveName: 203 | descriptiveNegativeName: 204 | negativeButton: 205 | positiveButton: joystick button 1 206 | altNegativeButton: 207 | altPositiveButton: 208 | gravity: 1000 209 | dead: 0.001 210 | sensitivity: 1000 211 | snap: 0 212 | invert: 0 213 | type: 0 214 | axis: 0 215 | joyNum: 0 216 | - serializedVersion: 3 217 | m_Name: Fire3 218 | descriptiveName: 219 | descriptiveNegativeName: 220 | negativeButton: 221 | positiveButton: joystick button 2 222 | altNegativeButton: 223 | altPositiveButton: 224 | gravity: 1000 225 | dead: 0.001 226 | sensitivity: 1000 227 | snap: 0 228 | invert: 0 229 | type: 0 230 | axis: 0 231 | joyNum: 0 232 | - serializedVersion: 3 233 | m_Name: Jump 234 | descriptiveName: 235 | descriptiveNegativeName: 236 | negativeButton: 237 | positiveButton: joystick button 3 238 | altNegativeButton: 239 | altPositiveButton: 240 | gravity: 1000 241 | dead: 0.001 242 | sensitivity: 1000 243 | snap: 0 244 | invert: 0 245 | type: 0 246 | axis: 0 247 | joyNum: 0 248 | - serializedVersion: 3 249 | m_Name: Submit 250 | descriptiveName: 251 | descriptiveNegativeName: 252 | negativeButton: 253 | positiveButton: return 254 | altNegativeButton: 255 | altPositiveButton: joystick button 0 256 | gravity: 1000 257 | dead: 0.001 258 | sensitivity: 1000 259 | snap: 0 260 | invert: 0 261 | type: 0 262 | axis: 0 263 | joyNum: 0 264 | - serializedVersion: 3 265 | m_Name: Submit 266 | descriptiveName: 267 | descriptiveNegativeName: 268 | negativeButton: 269 | positiveButton: enter 270 | altNegativeButton: 271 | altPositiveButton: space 272 | gravity: 1000 273 | dead: 0.001 274 | sensitivity: 1000 275 | snap: 0 276 | invert: 0 277 | type: 0 278 | axis: 0 279 | joyNum: 0 280 | - serializedVersion: 3 281 | m_Name: Cancel 282 | descriptiveName: 283 | descriptiveNegativeName: 284 | negativeButton: 285 | positiveButton: escape 286 | altNegativeButton: 287 | altPositiveButton: joystick button 1 288 | gravity: 1000 289 | dead: 0.001 290 | sensitivity: 1000 291 | snap: 0 292 | invert: 0 293 | type: 0 294 | axis: 0 295 | joyNum: 0 296 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | ## A Unity3D-based sprite animator system for simple and advanced animation setups 2 | 3 | Animation Example 4 | 5 | ## Table of Contents 6 | 7 | - Features 8 | - Installation 9 | - Example 10 | - Documentation 11 | - Getting Started 12 | - The Animators 13 | - Settings, Clips & Frames 14 | - Other files included 15 | - License 16 | 17 | --- 18 | 19 | ## Features 20 | 21 | - ```Create sprite based animations``` 22 | - ```Share animation clips``` between different animators 23 | - Easily ```flip``` your sprites or group of sprites 24 | - Add ```triggers``` that can be listened to, for things like playing footstep sounds 25 | - Control the ```frame rate``` of each clip and its individual frames 26 | - Create ```advanced setups``` of co-dependent animators, particle effects and containers. Where parent animators can control their children. 27 | 28 | --- 29 | 30 | ## Installation 31 | 32 | Simply copy the folder "```Assets/Plugins```" into your project and you're good to go. Optionally, you can add the folder "```Assets/Examples```" to get started right away. 33 | Unit Tests are located in the "```Assets/Editor/Tests```"-folder. 34 | 35 | --- 36 | 37 | ## Examples 38 | 39 | A fully functional example is included with this reposetory and can be found in the folder "```Assets/Examples```". 40 | Use the ```left and right arrow keys``` to toggle between an idle and walk animation. 41 | 42 | - ```ImageAnimator.scene``` - the Unity Scene that contains an example using the Image Animator (UI). 43 | - ```SpriteAnimator.scene``` - the Unity Scene that contains an example using the Sprite Animator (2D). 44 | - ```AnimationController.cs``` - a ```MonoBehaviour``` that plays animations. 45 | - ```spritesheet.png``` - Contains the artwork and animations used. 46 | - ```Audio-folder``` - Contains footstep audio used in the example. 47 | 48 | --- 49 | 50 | ## Documentation 51 | 52 | Below you can find documentation of various parts of the system. You are encouraged to look through the code, where more in-depth code docs can be found. 53 | 54 | --- 55 | 56 | ### Getting Started 57 | 58 | **For 2D SpriteRenderers**, simply create a new gameobject and add ```SpriteAnimator.cs``` as a component.
59 | **For UI-Canvas Images**, simply create a new gameobject in your canvas and add ```ImageAnimator.cs``` as a component. 60 | 61 | --- 62 | 63 | ### The Animators 64 | 65 | There are several animator behaviors included with this plugin. 66 | 67 | | Script | Description | 68 | | ----------------------------- |---------------------------------------------------------------| 69 | |```SpriteAnimator.cs``` | For animating sprites in 2D using a SpriteRenderer | 70 | |```ImageAnimator.cs``` | For animating sprites using in the UI-Canvas using an Image | 71 | |```ParticleSystemAnimator.cs```| For connecting a Particle System to other animators, making it play and stop depending on what animation is being played by its parent | 72 | |```TransformAnimator.cs``` | For connecting a Transform to other animators, making it show and hide depending on what animation is being played by its parent | 73 |
74 | Hierarchy
75 | Here is the hiearchy-setup of the example, where all animators are in use. 76 | 77 | --- 78 | 79 | Below is a list of actions methods and getters within ```IAnimator```-interface. 80 | ```cs 81 | /// 82 | /// Invoked when the current clip has completed its animation 83 | /// 84 | Action OnClipComplete { get; set; } 85 | 86 | /// 87 | /// Invoked when playing a frame with a trigger on it 88 | /// 89 | Action OnTrigger { get; set; } 90 | 91 | /// 92 | /// Returns true if an animation is currently playing 93 | /// 94 | bool IsPlaying { get; } 95 | 96 | /// 97 | /// Returns the current clip 98 | /// 99 | IClip CurrentClip { get; } 100 | 101 | /// 102 | /// Plays the given clip 103 | /// 104 | /// The clip to play 105 | void Play(IClip clip); 106 | 107 | /// 108 | /// Tries to find and play a clip of given name 109 | /// 110 | /// The name of the clip to play 111 | bool Play(string clipName); 112 | 113 | /// 114 | /// Pauses the current animation 115 | /// 116 | void Pause(); 117 | 118 | /// 119 | /// Resumes the current animation 120 | /// 121 | void Resume(); 122 | 123 | /// 124 | /// Gets or sets wether to flip this animator or not 125 | /// 126 | bool Flip { get; set; } 127 | 128 | /// 129 | /// How to handle the relationship with a parent animator 130 | /// 131 | AnimatorChildMode ChildMode { get; } 132 | ``` 133 | --- 134 | 135 | ### Settings, Clips & Frames 136 | 137 | Below is a run down of the general elements, and their settings, of the animator-behaviors. 138 | 139 | #### Sprites 140 | 141 | Sprites 142 | 143 | The sprites-list stores all sprites accosiated with this animator, and decouple the frame-reference from the actual animations. Adding multple sprites at once can be done by first locking the inspector, and then dragging multiple sprites inot the sprites-list. 144 | 145 | #### Clips 146 | 147 | Clips 148 | 149 | - ```Name:``` The name of the clip. 150 | - ```Loop:``` Wether this clip should loop or not *(please note that looping clipts do not invoke OnClipComplete)*. 151 | - ```Random Start:``` Wether this clip should start on a random frame when played. 152 | - ```Frame Rate:``` The frame rate *(in frames per second)* of this animation clip. 153 | 154 | #### Frames 155 | 156 | Frames 157 | 158 | - ```Index:``` The index of the sprite to use with this frame *(should correspond to the sprite in the sprite-list)*. 159 | - ```Speed:``` The speed-mod of this individual frame *(0 = 0%, 1 = 100%, 2 = 200%, etc)*. 160 | - ```Trigger:``` The trigger-name of this frame. Leave empty if no trigger is desired. 161 | 162 | #### Settings 163 | 164 | Animator Settings 165 | 166 | These are the general settings of the animator itself. 167 | - ```Animate Children:``` Wether this animator should pass its animation down to its children. This also affects things like flip and sorting order. 168 | - ```Child Mode:``` Indicates how parents should handle this animator as a child. 169 | - ```PlayWithParent:``` Parents will play animations on this child using the animations name *(The child will play its own animation with the same name)*. 170 | - ```ShareClipsWithParent:``` Parents will share their clips with this child. This is useful for things like character bodyparts and shadow. 171 | - ```IgnoreParent:``` The parent will not play animations on this child. 172 | - ```Allow Flipping:``` Wether this animator can be flipped or will keep its direction 173 | 174 | --- 175 | 176 | ### Other files included 177 | 178 | NSubstitute is used for mocking within the unit tests. More info about NSubstitute can be found here. 179 | 180 | --- 181 | 182 | ## License 183 | MIT License 184 | 185 | Copyright (c) 2018 Farrokh Games 186 | 187 | Permission is hereby granted, free of charge, to any person obtaining a copy 188 | of this software and associated documentation files (the "Software"), to deal 189 | in the Software without restriction, including without limitation the rights 190 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 191 | copies of the Software, and to permit persons to whom the Software is 192 | furnished to do so, subject to the following conditions: 193 | 194 | The above copyright notice and this permission notice shall be included in all 195 | copies or substantial portions of the Software. 196 | 197 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 198 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 199 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 200 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 201 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 202 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 203 | SOFTWARE. 204 | -------------------------------------------------------------------------------- /Unity Project/Assets/Plugins/Farrokh Games/SpriteAnimation/Frame/FrameAnimator.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using FarrokhGames.SpriteAnimation.Shared; 5 | using UnityEngine; 6 | 7 | namespace FarrokhGames.SpriteAnimation.Frame 8 | { 9 | /// 10 | public class FrameAnimator : IFrameAnimator 11 | { 12 | /// 13 | public Action OnClipComplete { get; set; } 14 | 15 | /// 16 | public Action OnFrameChanged { get; set; } 17 | 18 | /// 19 | public Action OnTrigger { get; set; } 20 | 21 | /// 22 | public IClip CurrentClip { get { return _currentClip; } } 23 | 24 | /// 25 | public bool IsPlaying { get { return _isPlaying; } } 26 | 27 | /// 28 | public AnimatorChildMode ChildMode { get { return _childMode; } } 29 | 30 | IClip[] _clips = null; 31 | IClip _currentClip = null; 32 | IAnimator[] _children; 33 | Dictionary _nameToClip = new Dictionary(); 34 | bool _isPlaying; 35 | AnimatorChildMode _childMode; 36 | float _currentTime; 37 | int _currentFrameIndex; 38 | 39 | /// 40 | /// CTOR 41 | /// 42 | /// (Optional) The clips associated with this animator 43 | /// (Optional) How to handle the relationship with a parent animator 44 | public FrameAnimator(IClip[] clips = null, AnimatorChildMode childMode = AnimatorChildMode.PlayWithParent) 45 | { 46 | _clips = clips; 47 | _childMode = childMode; 48 | 49 | if (clips != null) 50 | { 51 | for (var i = 0; i < clips.Length; i++) 52 | { 53 | var clip = clips[i]; 54 | _nameToClip.Add(clip.Name, clip); 55 | } 56 | } 57 | } 58 | 59 | /// 60 | public void SetChildren(IAnimator[] children) 61 | { 62 | if (children != null && children.Contains(this)) 63 | { 64 | throw new System.InvalidOperationException("The list of children cannot contain the parent animator. This would cause an infinite loop"); 65 | } 66 | 67 | _children = children; 68 | } 69 | 70 | /// 71 | public bool Flip 72 | { 73 | get { throw new NotImplementedException(); } 74 | set { throw new NotImplementedException(); } 75 | } 76 | 77 | /// 78 | public void Play(IClip clip) 79 | { 80 | if (clip != null && _currentClip != clip) 81 | { 82 | _currentClip = clip; 83 | _currentTime = 0f; 84 | _currentFrameIndex = _currentClip.RandomStart ? UnityEngine.Random.Range(0, _currentClip.FrameCount) : 0; 85 | HandleFrame(_currentFrameIndex); 86 | _isPlaying = true; 87 | 88 | // Play Children 89 | if (_children != null && _children.Length > 0) 90 | { 91 | for (var i = 0; i < _children.Length; i++) 92 | { 93 | var animator = _children[i]; 94 | if (animator != null && animator.ChildMode != AnimatorChildMode.IgnoreParent) 95 | { 96 | if (animator.ChildMode == AnimatorChildMode.PlayWithParent) 97 | { 98 | animator.Play(clip.Name); 99 | } 100 | else if (animator.ChildMode == AnimatorChildMode.ShareClipsWithParent) 101 | { 102 | animator.Play(clip); 103 | } 104 | } 105 | } 106 | } 107 | } 108 | } 109 | 110 | /// 111 | public bool Play(string name) 112 | { 113 | if (_nameToClip.ContainsKey(name)) 114 | { 115 | Play(_nameToClip[name]); 116 | return true; 117 | } 118 | return false; 119 | } 120 | 121 | /// 122 | public void Pause() 123 | { 124 | _isPlaying = false; 125 | 126 | // Pause Children 127 | if (_children != null && _children.Length > 0) 128 | { 129 | for (var i = 0; i < _children.Length; i++) 130 | { 131 | var animator = _children[i]; 132 | if (animator != null && animator.ChildMode != AnimatorChildMode.IgnoreParent) 133 | { 134 | animator.Pause(); 135 | } 136 | } 137 | } 138 | } 139 | 140 | /// 141 | public void Resume() 142 | { 143 | _isPlaying = true; 144 | 145 | // Resume Children 146 | if (_children != null && _children.Length > 0) 147 | { 148 | for (var i = 0; i < _children.Length; i++) 149 | { 150 | var animator = _children[i]; 151 | if (animator != null && animator.ChildMode != AnimatorChildMode.IgnoreParent) 152 | { 153 | animator.Resume(); 154 | } 155 | } 156 | } 157 | } 158 | 159 | /// 160 | public void Tick(float deltaTime) 161 | { 162 | if (_isPlaying && _currentClip != null) 163 | { 164 | var currentFrame = _currentClip[_currentFrameIndex]; 165 | _currentTime += deltaTime * _currentClip.FrameRate * currentFrame.Speed; 166 | if (_currentTime >= 1f) 167 | { 168 | _currentTime -= 1f; 169 | _currentFrameIndex++; 170 | if (_currentFrameIndex >= _currentClip.FrameCount) 171 | { 172 | if (!_currentClip.Loop) 173 | { 174 | if (OnClipComplete != null) { OnClipComplete(); } 175 | Pause(); 176 | return; 177 | } 178 | _currentFrameIndex = 0; // Loop 179 | } 180 | HandleFrame(_currentFrameIndex); 181 | } 182 | } 183 | } 184 | 185 | /* 186 | Invokes the appropriate actions of a given frame 187 | */ 188 | void HandleFrame(int frame) 189 | { 190 | var currentFrame = _currentClip[frame]; 191 | if (OnFrameChanged != null) { OnFrameChanged(currentFrame.Index); } 192 | if (currentFrame.HasTrigger) 193 | { 194 | if (OnTrigger != null) { OnTrigger(currentFrame.TriggerName); } 195 | } 196 | } 197 | 198 | /// 199 | public void Dispose() 200 | { 201 | OnClipComplete = null; 202 | OnFrameChanged = null; 203 | OnTrigger = null; 204 | _currentClip = null; 205 | } 206 | } 207 | 208 | /// 209 | [Serializable] 210 | public class Clip : IClip 211 | { 212 | [SerializeField, Tooltip("The name of the clip")] string _name; 213 | [SerializeField, Tooltip("Wether this clip loops or not")] bool _loop = true; 214 | [SerializeField, Tooltip("Wether this clip starts on a random frame")] bool _randomStart = false; 215 | [SerializeField, Tooltip("The frame rate of this clip in frames per second")] float _frameRate = 8f; 216 | [SerializeField, Tooltip("The frames of this clip")] Frame[] _frames; 217 | 218 | /// 219 | public string Name { get { return _name; } } 220 | 221 | /// 222 | public bool Loop { get { return _loop; } } 223 | 224 | /// 225 | public bool RandomStart { get { return _randomStart; } } 226 | 227 | /// 228 | public float FrameRate { get { return _frameRate; } } 229 | 230 | /// 231 | public int FrameCount { get { return _frames.Length; } } 232 | 233 | /// 234 | public IFrame this [int index] { get { return _frames[index]; } } 235 | } 236 | 237 | /// 238 | [Serializable] 239 | public class Frame : IFrame 240 | { 241 | [SerializeField, Tooltip("The index of this clip")] int _index = 0; 242 | [SerializeField, Tooltip("The speed of this clip. Use this to slow down or speed up individual frames")] float _speed = 1f; 243 | [SerializeField, Tooltip("The name of the trigger. Leave empty if you don't want a trigger")] string _triggerName; 244 | 245 | /// 246 | public int Index { get { return _index; } } 247 | 248 | /// 249 | public float Speed { get { return _speed; } } 250 | 251 | /// 252 | public bool HasTrigger { get { return !string.IsNullOrEmpty(_triggerName); } } 253 | 254 | /// 255 | public string TriggerName { get { return _triggerName; } } 256 | } 257 | } -------------------------------------------------------------------------------- /Unity Project/Assets/Tests/Editor/FrameAnimatorTests.cs: -------------------------------------------------------------------------------- 1 | using System.Collections.Generic; 2 | using System.Linq; 3 | using FarrokhGames.SpriteAnimation.Frame; 4 | using FarrokhGames.SpriteAnimation.Shared; 5 | using NSubstitute; 6 | using NUnit.Framework; 7 | 8 | namespace FarrokhGames.SpriteAnimation 9 | { 10 | [TestFixture, Category("Animation")] 11 | public class FrameAnimatorTests 12 | { 13 | IFrameAnimator _animator; 14 | IClip _clip; 15 | 16 | int _lastIndex = -1; 17 | int _onFrameChangedCount = 0; 18 | int _onCompleteCount = 0; 19 | string _lastTrigger; 20 | int _onTriggerCount = 0; 21 | 22 | [SetUp] 23 | public void SetupTests() 24 | { 25 | _clip = Substitute.For(); 26 | _clip.FrameRate.Returns(1f); 27 | _clip.Name.Returns("clip"); 28 | _clip.FrameCount.Returns(3); 29 | var frame0 = CreateFrame(1, 1f); 30 | _clip[0].Returns(frame0); 31 | var frame1 = CreateFrame(2, 0.5f, "trigger"); 32 | _clip[1].Returns(frame1); 33 | var frame2 = CreateFrame(3, 1f); 34 | _clip[2].Returns(frame2); 35 | 36 | _animator = new FrameAnimator(new IClip[] { _clip }); 37 | 38 | _lastIndex = -1; 39 | _onFrameChangedCount = 0; 40 | _animator.OnFrameChanged += (frame) => 41 | { 42 | _lastIndex = frame; 43 | _onFrameChangedCount++; 44 | }; 45 | 46 | _onCompleteCount = 0; 47 | _animator.OnClipComplete += () => _onCompleteCount++; 48 | 49 | _onTriggerCount = 0; 50 | _lastTrigger = string.Empty; 51 | _animator.OnTrigger += triggerName => 52 | { 53 | _lastTrigger = triggerName; 54 | _onTriggerCount++; 55 | }; 56 | } 57 | 58 | IFrame CreateFrame(int index, float speed = 1f, string trigger = "") 59 | { 60 | var frame = Substitute.For