├── .gitignore ├── Demo.meta ├── Demo ├── DemoMove.unity └── DemoMove.unity.meta ├── LICENSE ├── LICENSE.meta ├── README.md ├── README.md.meta ├── Scripts.meta ├── Scripts ├── Runtime.meta ├── Runtime │ ├── Components.meta │ ├── Components │ │ ├── Rotator.cs │ │ ├── Rotator.cs.meta │ │ ├── Scaler.cs │ │ ├── Scaler.cs.meta │ │ ├── SimpleAnimator.cs │ │ └── SimpleAnimator.cs.meta │ ├── Types.meta │ ├── Types │ │ ├── AnimationData.cs │ │ ├── AnimationData.cs.meta │ │ ├── AnimationType.cs │ │ └── AnimationType.cs.meta │ ├── UnityAnimation.Runtime.asmdef │ ├── UnityAnimation.Runtime.asmdef.meta │ ├── UnityAnimationConstants.cs │ ├── UnityAnimationConstants.cs.meta │ ├── Utils.meta │ └── Utils │ │ ├── AnimationBuilder.Runner.cs │ │ ├── AnimationBuilder.Runner.cs.meta │ │ ├── AnimationBuilder.Step.cs │ │ ├── AnimationBuilder.Step.cs.meta │ │ ├── AnimationBuilder.cs │ │ ├── AnimationBuilder.cs.meta │ │ ├── AnimationRunner.cs │ │ ├── AnimationRunner.cs.meta │ │ ├── AnimationUtils.cs │ │ └── AnimationUtils.cs.meta ├── Test.meta └── Test │ ├── AnimationTest.cs │ ├── AnimationTest.cs.meta │ ├── UnityAnimation.Test.asmdef │ └── UnityAnimation.Test.asmdef.meta ├── package.json └── package.json.meta /.gitignore: -------------------------------------------------------------------------------- 1 | # This .gitignore file should be placed at the root of your Unity project directory 2 | # 3 | # Get latest from https://github.com/github/gitignore/blob/master/Unity.gitignore 4 | # 5 | /[Ll]ibrary/ 6 | /[Tt]emp/ 7 | /[Oo]bj/ 8 | /[Bb]uild/ 9 | /[Bb]uilds/ 10 | /[Ll]ogs/ 11 | /[Mm]emoryCaptures/ 12 | 13 | # Asset meta data should only be ignored when the corresponding asset is also ignored 14 | !/[Aa]ssets/**/*.meta 15 | 16 | # Uncomment this line if you wish to ignore the asset store tools plugin 17 | # /[Aa]ssets/AssetStoreTools* 18 | 19 | # Autogenerated Jetbrains Rider plugin 20 | [Aa]ssets/Plugins/Editor/JetBrains* 21 | 22 | # Visual Studio cache directory 23 | .vs/ 24 | 25 | # Rider 26 | .idea/ 27 | 28 | # Gradle cache directory 29 | .gradle/ 30 | 31 | # Autogenerated VS/MD/Consulo solution and project files 32 | ExportedObj/ 33 | .consulo/ 34 | *.csproj 35 | *.unityproj 36 | *.sln 37 | *.suo 38 | *.tmp 39 | *.user 40 | *.userprefs 41 | *.pidb 42 | *.booproj 43 | *.svd 44 | *.pdb 45 | *.mdb 46 | *.opendb 47 | *.VC.db 48 | 49 | # Unity3D generated meta files 50 | *.pidb.meta 51 | *.pdb.meta 52 | *.mdb.meta 53 | 54 | # Unity3D generated file on crash reports 55 | sysinfo.txt 56 | 57 | # Builds 58 | *.apk 59 | *.unitypackage 60 | 61 | # Crashlytics generated file 62 | crashlytics-build.properties 63 | 64 | Assets/PcSoft/DynamicAssets/90 Scripts/.DS_Store 65 | -------------------------------------------------------------------------------- /Demo.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 02d3281c16172c445819b23e90cb58a2 3 | folderAsset: yes 4 | DefaultImporter: 5 | externalObjects: {} 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Demo/DemoMove.unity: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | %TAG !u! tag:unity3d.com,2011: 3 | --- !u!29 &1 4 | OcclusionCullingSettings: 5 | m_ObjectHideFlags: 0 6 | serializedVersion: 2 7 | m_OcclusionBakeSettings: 8 | smallestOccluder: 5 9 | smallestHole: 0.25 10 | backfaceThreshold: 100 11 | m_SceneGUID: 00000000000000000000000000000000 12 | m_OcclusionCullingData: {fileID: 0} 13 | --- !u!104 &2 14 | RenderSettings: 15 | m_ObjectHideFlags: 0 16 | serializedVersion: 10 17 | m_Fog: 0 18 | m_FogColor: {r: 0.5, g: 0.5, b: 0.5, a: 1} 19 | m_FogMode: 3 20 | m_FogDensity: 0.01 21 | m_LinearFogStart: 0 22 | m_LinearFogEnd: 300 23 | m_AmbientSkyColor: {r: 0.212, g: 0.227, b: 0.259, a: 1} 24 | m_AmbientEquatorColor: {r: 0.114, g: 0.125, b: 0.133, a: 1} 25 | m_AmbientGroundColor: {r: 0.047, g: 0.043, b: 0.035, a: 1} 26 | m_AmbientIntensity: 1 27 | m_AmbientMode: 0 28 | m_SubtractiveShadowColor: {r: 0.42, g: 0.478, b: 0.627, a: 1} 29 | m_SkyboxMaterial: {fileID: 10304, guid: 0000000000000000f000000000000000, type: 0} 30 | m_HaloStrength: 0.5 31 | m_FlareStrength: 1 32 | m_FlareFadeSpeed: 3 33 | m_HaloTexture: {fileID: 0} 34 | m_SpotCookie: {fileID: 10001, guid: 0000000000000000e000000000000000, type: 0} 35 | m_DefaultReflectionMode: 0 36 | m_DefaultReflectionResolution: 128 37 | m_ReflectionBounces: 1 38 | m_ReflectionIntensity: 1 39 | m_CustomReflection: {fileID: 0} 40 | m_Sun: {fileID: 0} 41 | m_UseRadianceAmbientProbe: 0 42 | --- !u!157 &3 43 | LightmapSettings: 44 | m_ObjectHideFlags: 0 45 | serializedVersion: 12 46 | m_GISettings: 47 | serializedVersion: 2 48 | m_BounceScale: 1 49 | m_IndirectOutputScale: 1 50 | m_AlbedoBoost: 1 51 | m_EnvironmentLightingMode: 0 52 | m_EnableBakedLightmaps: 1 53 | m_EnableRealtimeLightmaps: 0 54 | m_LightmapEditorSettings: 55 | serializedVersion: 12 56 | m_Resolution: 2 57 | m_BakeResolution: 40 58 | m_AtlasSize: 1024 59 | m_AO: 0 60 | m_AOMaxDistance: 1 61 | m_CompAOExponent: 1 62 | m_CompAOExponentDirect: 0 63 | m_ExtractAmbientOcclusion: 0 64 | m_Padding: 2 65 | m_LightmapParameters: {fileID: 0} 66 | m_LightmapsBakeMode: 1 67 | m_TextureCompression: 1 68 | m_ReflectionCompression: 2 69 | m_MixedBakeMode: 2 70 | m_BakeBackend: 1 71 | m_PVRSampling: 1 72 | m_PVRDirectSampleCount: 32 73 | m_PVRSampleCount: 512 74 | m_PVRBounces: 2 75 | m_PVREnvironmentSampleCount: 256 76 | m_PVREnvironmentReferencePointCount: 2048 77 | m_PVRFilteringMode: 1 78 | m_PVRDenoiserTypeDirect: 1 79 | m_PVRDenoiserTypeIndirect: 1 80 | m_PVRDenoiserTypeAO: 1 81 | m_PVRFilterTypeDirect: 0 82 | m_PVRFilterTypeIndirect: 0 83 | m_PVRFilterTypeAO: 0 84 | m_PVREnvironmentMIS: 1 85 | m_PVRCulling: 1 86 | m_PVRFilteringGaussRadiusDirect: 1 87 | m_PVRFilteringGaussRadiusIndirect: 5 88 | m_PVRFilteringGaussRadiusAO: 2 89 | m_PVRFilteringAtrousPositionSigmaDirect: 0.5 90 | m_PVRFilteringAtrousPositionSigmaIndirect: 2 91 | m_PVRFilteringAtrousPositionSigmaAO: 1 92 | m_ExportTrainingData: 0 93 | m_TrainingDataDestination: TrainingData 94 | m_LightProbeSampleCountMultiplier: 4 95 | m_LightingDataAsset: {fileID: 20201, guid: 0000000000000000f000000000000000, type: 0} 96 | m_LightingSettings: {fileID: 0} 97 | --- !u!196 &4 98 | NavMeshSettings: 99 | serializedVersion: 2 100 | m_ObjectHideFlags: 0 101 | m_BuildSettings: 102 | serializedVersion: 3 103 | agentTypeID: 0 104 | agentRadius: 0.5 105 | agentHeight: 2 106 | agentSlope: 45 107 | agentClimb: 0.4 108 | ledgeDropHeight: 0 109 | maxJumpAcrossDistance: 0 110 | minRegionArea: 2 111 | manualCellSize: 0 112 | cellSize: 0.16666667 113 | manualTileSize: 0 114 | tileSize: 256 115 | buildHeightMesh: 0 116 | maxJobWorkers: 0 117 | preserveTilesOutsideBounds: 0 118 | debug: 119 | m_Flags: 0 120 | m_NavMeshData: {fileID: 0} 121 | --- !u!1 &51833944 122 | GameObject: 123 | m_ObjectHideFlags: 0 124 | m_CorrespondingSourceObject: {fileID: 0} 125 | m_PrefabInstance: {fileID: 0} 126 | m_PrefabAsset: {fileID: 0} 127 | serializedVersion: 6 128 | m_Component: 129 | - component: {fileID: 51833948} 130 | - component: {fileID: 51833947} 131 | - component: {fileID: 51833946} 132 | - component: {fileID: 51833945} 133 | m_Layer: 5 134 | m_Name: Canvas 135 | m_TagString: Untagged 136 | m_Icon: {fileID: 0} 137 | m_NavMeshLayer: 0 138 | m_StaticEditorFlags: 0 139 | m_IsActive: 1 140 | --- !u!114 &51833945 141 | MonoBehaviour: 142 | m_ObjectHideFlags: 0 143 | m_CorrespondingSourceObject: {fileID: 0} 144 | m_PrefabInstance: {fileID: 0} 145 | m_PrefabAsset: {fileID: 0} 146 | m_GameObject: {fileID: 51833944} 147 | m_Enabled: 1 148 | m_EditorHideFlags: 0 149 | m_Script: {fileID: 11500000, guid: dc42784cf147c0c48a680349fa168899, type: 3} 150 | m_Name: 151 | m_EditorClassIdentifier: 152 | m_IgnoreReversedGraphics: 1 153 | m_BlockingObjects: 0 154 | m_BlockingMask: 155 | serializedVersion: 2 156 | m_Bits: 4294967295 157 | --- !u!114 &51833946 158 | MonoBehaviour: 159 | m_ObjectHideFlags: 0 160 | m_CorrespondingSourceObject: {fileID: 0} 161 | m_PrefabInstance: {fileID: 0} 162 | m_PrefabAsset: {fileID: 0} 163 | m_GameObject: {fileID: 51833944} 164 | m_Enabled: 1 165 | m_EditorHideFlags: 0 166 | m_Script: {fileID: 11500000, guid: 0cd44c1031e13a943bb63640046fad76, type: 3} 167 | m_Name: 168 | m_EditorClassIdentifier: 169 | m_UiScaleMode: 0 170 | m_ReferencePixelsPerUnit: 100 171 | m_ScaleFactor: 1 172 | m_ReferenceResolution: {x: 800, y: 600} 173 | m_ScreenMatchMode: 0 174 | m_MatchWidthOrHeight: 0 175 | m_PhysicalUnit: 3 176 | m_FallbackScreenDPI: 96 177 | m_DefaultSpriteDPI: 96 178 | m_DynamicPixelsPerUnit: 1 179 | m_PresetInfoIsWorld: 0 180 | --- !u!223 &51833947 181 | Canvas: 182 | m_ObjectHideFlags: 0 183 | m_CorrespondingSourceObject: {fileID: 0} 184 | m_PrefabInstance: {fileID: 0} 185 | m_PrefabAsset: {fileID: 0} 186 | m_GameObject: {fileID: 51833944} 187 | m_Enabled: 1 188 | serializedVersion: 3 189 | m_RenderMode: 0 190 | m_Camera: {fileID: 0} 191 | m_PlaneDistance: 100 192 | m_PixelPerfect: 0 193 | m_ReceivesEvents: 1 194 | m_OverrideSorting: 0 195 | m_OverridePixelPerfect: 0 196 | m_SortingBucketNormalizedSize: 0 197 | m_VertexColorAlwaysGammaSpace: 0 198 | m_AdditionalShaderChannelsFlag: 25 199 | m_UpdateRectTransformForStandalone: 0 200 | m_SortingLayerID: 0 201 | m_SortingOrder: 0 202 | m_TargetDisplay: 0 203 | --- !u!224 &51833948 204 | RectTransform: 205 | m_ObjectHideFlags: 0 206 | m_CorrespondingSourceObject: {fileID: 0} 207 | m_PrefabInstance: {fileID: 0} 208 | m_PrefabAsset: {fileID: 0} 209 | m_GameObject: {fileID: 51833944} 210 | m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} 211 | m_LocalPosition: {x: 0, y: 0, z: 0} 212 | m_LocalScale: {x: 0, y: 0, z: 0} 213 | m_ConstrainProportionsScale: 0 214 | m_Children: 215 | - {fileID: 999662945} 216 | m_Father: {fileID: 0} 217 | m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} 218 | m_AnchorMin: {x: 0, y: 0} 219 | m_AnchorMax: {x: 0, y: 0} 220 | m_AnchoredPosition: {x: 0, y: 0} 221 | m_SizeDelta: {x: 0, y: 0} 222 | m_Pivot: {x: 0, y: 0} 223 | --- !u!1 &684810855 224 | GameObject: 225 | m_ObjectHideFlags: 0 226 | m_CorrespondingSourceObject: {fileID: 0} 227 | m_PrefabInstance: {fileID: 0} 228 | m_PrefabAsset: {fileID: 0} 229 | serializedVersion: 6 230 | m_Component: 231 | - component: {fileID: 684810860} 232 | - component: {fileID: 684810859} 233 | - component: {fileID: 684810858} 234 | - component: {fileID: 684810857} 235 | - component: {fileID: 684810856} 236 | m_Layer: 0 237 | m_Name: Cube 238 | m_TagString: Untagged 239 | m_Icon: {fileID: 0} 240 | m_NavMeshLayer: 0 241 | m_StaticEditorFlags: 0 242 | m_IsActive: 1 243 | --- !u!114 &684810856 244 | MonoBehaviour: 245 | m_ObjectHideFlags: 0 246 | m_CorrespondingSourceObject: {fileID: 0} 247 | m_PrefabInstance: {fileID: 0} 248 | m_PrefabAsset: {fileID: 0} 249 | m_GameObject: {fileID: 684810855} 250 | m_Enabled: 1 251 | m_EditorHideFlags: 0 252 | m_Script: {fileID: 11500000, guid: a1f8e3335efe4313b993c56f8b82506f, type: 3} 253 | m_Name: 254 | m_EditorClassIdentifier: 255 | animationType: 0 256 | rotationCurve: 257 | serializedVersion: 2 258 | m_Curve: 259 | - serializedVersion: 3 260 | time: 0 261 | value: 0 262 | inSlope: 0 263 | outSlope: 0 264 | tangentMode: 0 265 | weightedMode: 0 266 | inWeight: 0 267 | outWeight: 0 268 | - serializedVersion: 3 269 | time: 1 270 | value: 1 271 | inSlope: 0 272 | outSlope: 0 273 | tangentMode: 0 274 | weightedMode: 0 275 | inWeight: 0 276 | outWeight: 0 277 | m_PreInfinity: 0 278 | m_PostInfinity: 0 279 | m_RotationOrder: 4 280 | eulerRotation: {x: 0.2, y: 0.1, z: 0.3} 281 | --- !u!65 &684810857 282 | BoxCollider: 283 | m_ObjectHideFlags: 0 284 | m_CorrespondingSourceObject: {fileID: 0} 285 | m_PrefabInstance: {fileID: 0} 286 | m_PrefabAsset: {fileID: 0} 287 | m_GameObject: {fileID: 684810855} 288 | m_Material: {fileID: 0} 289 | m_IncludeLayers: 290 | serializedVersion: 2 291 | m_Bits: 0 292 | m_ExcludeLayers: 293 | serializedVersion: 2 294 | m_Bits: 0 295 | m_LayerOverridePriority: 0 296 | m_IsTrigger: 0 297 | m_ProvidesContacts: 0 298 | m_Enabled: 1 299 | serializedVersion: 3 300 | m_Size: {x: 1, y: 1, z: 1} 301 | m_Center: {x: 0, y: 0, z: 0} 302 | --- !u!23 &684810858 303 | MeshRenderer: 304 | m_ObjectHideFlags: 0 305 | m_CorrespondingSourceObject: {fileID: 0} 306 | m_PrefabInstance: {fileID: 0} 307 | m_PrefabAsset: {fileID: 0} 308 | m_GameObject: {fileID: 684810855} 309 | m_Enabled: 1 310 | m_CastShadows: 1 311 | m_ReceiveShadows: 1 312 | m_DynamicOccludee: 1 313 | m_StaticShadowCaster: 0 314 | m_MotionVectors: 1 315 | m_LightProbeUsage: 1 316 | m_ReflectionProbeUsage: 1 317 | m_RayTracingMode: 2 318 | m_RayTraceProcedural: 0 319 | m_RayTracingAccelStructBuildFlagsOverride: 0 320 | m_RayTracingAccelStructBuildFlags: 1 321 | m_SmallMeshCulling: 1 322 | m_RenderingLayerMask: 1 323 | m_RendererPriority: 0 324 | m_Materials: 325 | - {fileID: 2100000, guid: 31321ba15b8f8eb4c954353edc038b1d, type: 2} 326 | m_StaticBatchInfo: 327 | firstSubMesh: 0 328 | subMeshCount: 0 329 | m_StaticBatchRoot: {fileID: 0} 330 | m_ProbeAnchor: {fileID: 0} 331 | m_LightProbeVolumeOverride: {fileID: 0} 332 | m_ScaleInLightmap: 1 333 | m_ReceiveGI: 1 334 | m_PreserveUVs: 0 335 | m_IgnoreNormalsForChartDetection: 0 336 | m_ImportantGI: 0 337 | m_StitchLightmapSeams: 1 338 | m_SelectedEditorRenderState: 3 339 | m_MinimumChartSize: 4 340 | m_AutoUVMaxDistance: 0.5 341 | m_AutoUVMaxAngle: 89 342 | m_LightmapParameters: {fileID: 0} 343 | m_SortingLayerID: 0 344 | m_SortingLayer: 0 345 | m_SortingOrder: 0 346 | m_AdditionalVertexStreams: {fileID: 0} 347 | --- !u!33 &684810859 348 | MeshFilter: 349 | m_ObjectHideFlags: 0 350 | m_CorrespondingSourceObject: {fileID: 0} 351 | m_PrefabInstance: {fileID: 0} 352 | m_PrefabAsset: {fileID: 0} 353 | m_GameObject: {fileID: 684810855} 354 | m_Mesh: {fileID: 10202, guid: 0000000000000000e000000000000000, type: 0} 355 | --- !u!4 &684810860 356 | Transform: 357 | m_ObjectHideFlags: 0 358 | m_CorrespondingSourceObject: {fileID: 0} 359 | m_PrefabInstance: {fileID: 0} 360 | m_PrefabAsset: {fileID: 0} 361 | m_GameObject: {fileID: 684810855} 362 | serializedVersion: 2 363 | m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} 364 | m_LocalPosition: {x: -3.16, y: 0, z: 0} 365 | m_LocalScale: {x: 1, y: 1, z: 1} 366 | m_ConstrainProportionsScale: 0 367 | m_Children: [] 368 | m_Father: {fileID: 0} 369 | m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} 370 | --- !u!1 &999662944 371 | GameObject: 372 | m_ObjectHideFlags: 0 373 | m_CorrespondingSourceObject: {fileID: 0} 374 | m_PrefabInstance: {fileID: 0} 375 | m_PrefabAsset: {fileID: 0} 376 | serializedVersion: 6 377 | m_Component: 378 | - component: {fileID: 999662945} 379 | - component: {fileID: 999662947} 380 | - component: {fileID: 999662946} 381 | m_Layer: 5 382 | m_Name: Text (TMP) 383 | m_TagString: Untagged 384 | m_Icon: {fileID: 0} 385 | m_NavMeshLayer: 0 386 | m_StaticEditorFlags: 0 387 | m_IsActive: 1 388 | --- !u!224 &999662945 389 | RectTransform: 390 | m_ObjectHideFlags: 0 391 | m_CorrespondingSourceObject: {fileID: 0} 392 | m_PrefabInstance: {fileID: 0} 393 | m_PrefabAsset: {fileID: 0} 394 | m_GameObject: {fileID: 999662944} 395 | m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} 396 | m_LocalPosition: {x: 0, y: 0, z: 0} 397 | m_LocalScale: {x: 1, y: 1, z: 1} 398 | m_ConstrainProportionsScale: 0 399 | m_Children: [] 400 | m_Father: {fileID: 51833948} 401 | m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} 402 | m_AnchorMin: {x: 0, y: 0} 403 | m_AnchorMax: {x: 1, y: 0} 404 | m_AnchoredPosition: {x: 0, y: 0} 405 | m_SizeDelta: {x: -50, y: 50} 406 | m_Pivot: {x: 0.5, y: 0} 407 | --- !u!114 &999662946 408 | MonoBehaviour: 409 | m_ObjectHideFlags: 0 410 | m_CorrespondingSourceObject: {fileID: 0} 411 | m_PrefabInstance: {fileID: 0} 412 | m_PrefabAsset: {fileID: 0} 413 | m_GameObject: {fileID: 999662944} 414 | m_Enabled: 1 415 | m_EditorHideFlags: 0 416 | m_Script: {fileID: 11500000, guid: f4688fdb7df04437aeb418b961361dc5, type: 3} 417 | m_Name: 418 | m_EditorClassIdentifier: 419 | m_Material: {fileID: 0} 420 | m_Color: {r: 1, g: 1, b: 1, a: 1} 421 | m_RaycastTarget: 1 422 | m_RaycastPadding: {x: 0, y: 0, z: 0, w: 0} 423 | m_Maskable: 1 424 | m_OnCullStateChanged: 425 | m_PersistentCalls: 426 | m_Calls: [] 427 | m_text: Demonstrate animation builder 428 | m_isRightToLeft: 0 429 | m_fontAsset: {fileID: 11400000, guid: 8f586378b4e144a9851e7b34d9b748ee, type: 2} 430 | m_sharedMaterial: {fileID: 2180264, guid: 8f586378b4e144a9851e7b34d9b748ee, type: 2} 431 | m_fontSharedMaterials: [] 432 | m_fontMaterial: {fileID: 0} 433 | m_fontMaterials: [] 434 | m_fontColor32: 435 | serializedVersion: 2 436 | rgba: 4294967295 437 | m_fontColor: {r: 1, g: 1, b: 1, a: 1} 438 | m_enableVertexGradient: 0 439 | m_colorMode: 3 440 | m_fontColorGradient: 441 | topLeft: {r: 1, g: 1, b: 1, a: 1} 442 | topRight: {r: 1, g: 1, b: 1, a: 1} 443 | bottomLeft: {r: 1, g: 1, b: 1, a: 1} 444 | bottomRight: {r: 1, g: 1, b: 1, a: 1} 445 | m_fontColorGradientPreset: {fileID: 0} 446 | m_spriteAsset: {fileID: 0} 447 | m_tintAllSprites: 0 448 | m_StyleSheet: {fileID: 0} 449 | m_TextStyleHashCode: -1183493901 450 | m_overrideHtmlColors: 0 451 | m_faceColor: 452 | serializedVersion: 2 453 | rgba: 4294967295 454 | m_fontSize: 36 455 | m_fontSizeBase: 36 456 | m_fontWeight: 400 457 | m_enableAutoSizing: 0 458 | m_fontSizeMin: 18 459 | m_fontSizeMax: 72 460 | m_fontStyle: 0 461 | m_HorizontalAlignment: 2 462 | m_VerticalAlignment: 256 463 | m_textAlignment: 65535 464 | m_characterSpacing: 0 465 | m_wordSpacing: 0 466 | m_lineSpacing: 0 467 | m_lineSpacingMax: 0 468 | m_paragraphSpacing: 0 469 | m_charWidthMaxAdj: 0 470 | m_TextWrappingMode: 1 471 | m_wordWrappingRatios: 0.4 472 | m_overflowMode: 0 473 | m_linkedTextComponent: {fileID: 0} 474 | parentLinkedComponent: {fileID: 0} 475 | m_enableKerning: 0 476 | m_ActiveFontFeatures: 6e72656b 477 | m_enableExtraPadding: 0 478 | checkPaddingRequired: 0 479 | m_isRichText: 1 480 | m_EmojiFallbackSupport: 1 481 | m_parseCtrlCharacters: 1 482 | m_isOrthographic: 1 483 | m_isCullingEnabled: 0 484 | m_horizontalMapping: 0 485 | m_verticalMapping: 0 486 | m_uvLineOffset: 0 487 | m_geometrySortingOrder: 0 488 | m_IsTextObjectScaleStatic: 0 489 | m_VertexBufferAutoSizeReduction: 0 490 | m_useMaxVisibleDescender: 1 491 | m_pageToDisplay: 1 492 | m_margin: {x: 0, y: 0, z: 0, w: 0} 493 | m_isUsingLegacyAnimationComponent: 0 494 | m_isVolumetricText: 0 495 | m_hasFontAssetChanged: 0 496 | m_baseMaterial: {fileID: 0} 497 | m_maskOffset: {x: 0, y: 0, z: 0, w: 0} 498 | --- !u!222 &999662947 499 | CanvasRenderer: 500 | m_ObjectHideFlags: 0 501 | m_CorrespondingSourceObject: {fileID: 0} 502 | m_PrefabInstance: {fileID: 0} 503 | m_PrefabAsset: {fileID: 0} 504 | m_GameObject: {fileID: 999662944} 505 | m_CullTransparentMesh: 1 506 | --- !u!1 &1273727351 507 | GameObject: 508 | m_ObjectHideFlags: 0 509 | m_CorrespondingSourceObject: {fileID: 0} 510 | m_PrefabInstance: {fileID: 0} 511 | m_PrefabAsset: {fileID: 0} 512 | serializedVersion: 6 513 | m_Component: 514 | - component: {fileID: 1273727354} 515 | - component: {fileID: 1273727353} 516 | - component: {fileID: 1273727352} 517 | m_Layer: 0 518 | m_Name: EventSystem 519 | m_TagString: Untagged 520 | m_Icon: {fileID: 0} 521 | m_NavMeshLayer: 0 522 | m_StaticEditorFlags: 0 523 | m_IsActive: 1 524 | --- !u!114 &1273727352 525 | MonoBehaviour: 526 | m_ObjectHideFlags: 0 527 | m_CorrespondingSourceObject: {fileID: 0} 528 | m_PrefabInstance: {fileID: 0} 529 | m_PrefabAsset: {fileID: 0} 530 | m_GameObject: {fileID: 1273727351} 531 | m_Enabled: 1 532 | m_EditorHideFlags: 0 533 | m_Script: {fileID: 11500000, guid: 01614664b831546d2ae94a42149d80ac, type: 3} 534 | m_Name: 535 | m_EditorClassIdentifier: 536 | m_SendPointerHoverToParent: 1 537 | m_MoveRepeatDelay: 0.5 538 | m_MoveRepeatRate: 0.1 539 | m_XRTrackingOrigin: {fileID: 0} 540 | m_ActionsAsset: {fileID: -944628639613478452, guid: ca9f5fa95ffab41fb9a615ab714db018, type: 3} 541 | m_PointAction: {fileID: -1654692200621890270, guid: ca9f5fa95ffab41fb9a615ab714db018, type: 3} 542 | m_MoveAction: {fileID: -8784545083839296357, guid: ca9f5fa95ffab41fb9a615ab714db018, type: 3} 543 | m_SubmitAction: {fileID: 392368643174621059, guid: ca9f5fa95ffab41fb9a615ab714db018, type: 3} 544 | m_CancelAction: {fileID: 7727032971491509709, guid: ca9f5fa95ffab41fb9a615ab714db018, type: 3} 545 | m_LeftClickAction: {fileID: 3001919216989983466, guid: ca9f5fa95ffab41fb9a615ab714db018, type: 3} 546 | m_MiddleClickAction: {fileID: -2185481485913320682, guid: ca9f5fa95ffab41fb9a615ab714db018, type: 3} 547 | m_RightClickAction: {fileID: -4090225696740746782, guid: ca9f5fa95ffab41fb9a615ab714db018, type: 3} 548 | m_ScrollWheelAction: {fileID: 6240969308177333660, guid: ca9f5fa95ffab41fb9a615ab714db018, type: 3} 549 | m_TrackedDevicePositionAction: {fileID: 6564999863303420839, guid: ca9f5fa95ffab41fb9a615ab714db018, type: 3} 550 | m_TrackedDeviceOrientationAction: {fileID: 7970375526676320489, guid: ca9f5fa95ffab41fb9a615ab714db018, type: 3} 551 | m_DeselectOnBackgroundClick: 1 552 | m_PointerBehavior: 0 553 | m_CursorLockBehavior: 0 554 | m_ScrollDeltaPerTick: 6 555 | --- !u!114 &1273727353 556 | MonoBehaviour: 557 | m_ObjectHideFlags: 0 558 | m_CorrespondingSourceObject: {fileID: 0} 559 | m_PrefabInstance: {fileID: 0} 560 | m_PrefabAsset: {fileID: 0} 561 | m_GameObject: {fileID: 1273727351} 562 | m_Enabled: 1 563 | m_EditorHideFlags: 0 564 | m_Script: {fileID: 11500000, guid: 76c392e42b5098c458856cdf6ecaaaa1, type: 3} 565 | m_Name: 566 | m_EditorClassIdentifier: 567 | m_FirstSelected: {fileID: 0} 568 | m_sendNavigationEvents: 1 569 | m_DragThreshold: 10 570 | --- !u!4 &1273727354 571 | Transform: 572 | m_ObjectHideFlags: 0 573 | m_CorrespondingSourceObject: {fileID: 0} 574 | m_PrefabInstance: {fileID: 0} 575 | m_PrefabAsset: {fileID: 0} 576 | m_GameObject: {fileID: 1273727351} 577 | serializedVersion: 2 578 | m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} 579 | m_LocalPosition: {x: 0, y: 0, z: 0} 580 | m_LocalScale: {x: 1, y: 1, z: 1} 581 | m_ConstrainProportionsScale: 0 582 | m_Children: [] 583 | m_Father: {fileID: 0} 584 | m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} 585 | --- !u!1 &1473156606 586 | GameObject: 587 | m_ObjectHideFlags: 0 588 | m_CorrespondingSourceObject: {fileID: 0} 589 | m_PrefabInstance: {fileID: 0} 590 | m_PrefabAsset: {fileID: 0} 591 | serializedVersion: 6 592 | m_Component: 593 | - component: {fileID: 1473156611} 594 | - component: {fileID: 1473156610} 595 | - component: {fileID: 1473156609} 596 | - component: {fileID: 1473156608} 597 | - component: {fileID: 1473156607} 598 | m_Layer: 0 599 | m_Name: Sphere 600 | m_TagString: Untagged 601 | m_Icon: {fileID: 0} 602 | m_NavMeshLayer: 0 603 | m_StaticEditorFlags: 0 604 | m_IsActive: 1 605 | --- !u!114 &1473156607 606 | MonoBehaviour: 607 | m_ObjectHideFlags: 0 608 | m_CorrespondingSourceObject: {fileID: 0} 609 | m_PrefabInstance: {fileID: 0} 610 | m_PrefabAsset: {fileID: 0} 611 | m_GameObject: {fileID: 1473156606} 612 | m_Enabled: 1 613 | m_EditorHideFlags: 0 614 | m_Script: {fileID: 11500000, guid: c47cdaaac29a480ba961290f10cf46c7, type: 3} 615 | m_Name: 616 | m_EditorClassIdentifier: 617 | animationType: 0 618 | scalingCurve: 619 | serializedVersion: 2 620 | m_Curve: 621 | - serializedVersion: 3 622 | time: 0 623 | value: 0 624 | inSlope: 0 625 | outSlope: 0 626 | tangentMode: 0 627 | weightedMode: 0 628 | inWeight: 0 629 | outWeight: 0 630 | - serializedVersion: 3 631 | time: 1 632 | value: 1 633 | inSlope: 0 634 | outSlope: 0 635 | tangentMode: 0 636 | weightedMode: 0 637 | inWeight: 0 638 | outWeight: 0 639 | m_PreInfinity: 0 640 | m_PostInfinity: 0 641 | m_RotationOrder: 4 642 | scalingSpeed: 1 643 | scalingStart: {x: 1, y: 1, z: 1} 644 | scalingEnd: {x: 2, y: 2, z: 2} 645 | --- !u!135 &1473156608 646 | SphereCollider: 647 | m_ObjectHideFlags: 0 648 | m_CorrespondingSourceObject: {fileID: 0} 649 | m_PrefabInstance: {fileID: 0} 650 | m_PrefabAsset: {fileID: 0} 651 | m_GameObject: {fileID: 1473156606} 652 | m_Material: {fileID: 0} 653 | m_IncludeLayers: 654 | serializedVersion: 2 655 | m_Bits: 0 656 | m_ExcludeLayers: 657 | serializedVersion: 2 658 | m_Bits: 0 659 | m_LayerOverridePriority: 0 660 | m_IsTrigger: 0 661 | m_ProvidesContacts: 0 662 | m_Enabled: 1 663 | serializedVersion: 3 664 | m_Radius: 0.5 665 | m_Center: {x: 0, y: 0, z: 0} 666 | --- !u!23 &1473156609 667 | MeshRenderer: 668 | m_ObjectHideFlags: 0 669 | m_CorrespondingSourceObject: {fileID: 0} 670 | m_PrefabInstance: {fileID: 0} 671 | m_PrefabAsset: {fileID: 0} 672 | m_GameObject: {fileID: 1473156606} 673 | m_Enabled: 1 674 | m_CastShadows: 1 675 | m_ReceiveShadows: 1 676 | m_DynamicOccludee: 1 677 | m_StaticShadowCaster: 0 678 | m_MotionVectors: 1 679 | m_LightProbeUsage: 1 680 | m_ReflectionProbeUsage: 1 681 | m_RayTracingMode: 2 682 | m_RayTraceProcedural: 0 683 | m_RayTracingAccelStructBuildFlagsOverride: 0 684 | m_RayTracingAccelStructBuildFlags: 1 685 | m_SmallMeshCulling: 1 686 | m_RenderingLayerMask: 1 687 | m_RendererPriority: 0 688 | m_Materials: 689 | - {fileID: 2100000, guid: 31321ba15b8f8eb4c954353edc038b1d, type: 2} 690 | m_StaticBatchInfo: 691 | firstSubMesh: 0 692 | subMeshCount: 0 693 | m_StaticBatchRoot: {fileID: 0} 694 | m_ProbeAnchor: {fileID: 0} 695 | m_LightProbeVolumeOverride: {fileID: 0} 696 | m_ScaleInLightmap: 1 697 | m_ReceiveGI: 1 698 | m_PreserveUVs: 0 699 | m_IgnoreNormalsForChartDetection: 0 700 | m_ImportantGI: 0 701 | m_StitchLightmapSeams: 1 702 | m_SelectedEditorRenderState: 3 703 | m_MinimumChartSize: 4 704 | m_AutoUVMaxDistance: 0.5 705 | m_AutoUVMaxAngle: 89 706 | m_LightmapParameters: {fileID: 0} 707 | m_SortingLayerID: 0 708 | m_SortingLayer: 0 709 | m_SortingOrder: 0 710 | m_AdditionalVertexStreams: {fileID: 0} 711 | --- !u!33 &1473156610 712 | MeshFilter: 713 | m_ObjectHideFlags: 0 714 | m_CorrespondingSourceObject: {fileID: 0} 715 | m_PrefabInstance: {fileID: 0} 716 | m_PrefabAsset: {fileID: 0} 717 | m_GameObject: {fileID: 1473156606} 718 | m_Mesh: {fileID: 10207, guid: 0000000000000000e000000000000000, type: 0} 719 | --- !u!4 &1473156611 720 | Transform: 721 | m_ObjectHideFlags: 0 722 | m_CorrespondingSourceObject: {fileID: 0} 723 | m_PrefabInstance: {fileID: 0} 724 | m_PrefabAsset: {fileID: 0} 725 | m_GameObject: {fileID: 1473156606} 726 | serializedVersion: 2 727 | m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} 728 | m_LocalPosition: {x: 2.16, y: 0, z: 0} 729 | m_LocalScale: {x: 1, y: 1, z: 1} 730 | m_ConstrainProportionsScale: 0 731 | m_Children: [] 732 | m_Father: {fileID: 0} 733 | m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} 734 | --- !u!1 &1813667956 735 | GameObject: 736 | m_ObjectHideFlags: 0 737 | m_CorrespondingSourceObject: {fileID: 0} 738 | m_PrefabInstance: {fileID: 0} 739 | m_PrefabAsset: {fileID: 0} 740 | serializedVersion: 6 741 | m_Component: 742 | - component: {fileID: 1813667958} 743 | - component: {fileID: 1813667957} 744 | - component: {fileID: 1813667959} 745 | m_Layer: 0 746 | m_Name: Directional Light 747 | m_TagString: Untagged 748 | m_Icon: {fileID: 0} 749 | m_NavMeshLayer: 0 750 | m_StaticEditorFlags: 0 751 | m_IsActive: 1 752 | --- !u!108 &1813667957 753 | Light: 754 | m_ObjectHideFlags: 0 755 | m_CorrespondingSourceObject: {fileID: 0} 756 | m_PrefabInstance: {fileID: 0} 757 | m_PrefabAsset: {fileID: 0} 758 | m_GameObject: {fileID: 1813667956} 759 | m_Enabled: 1 760 | serializedVersion: 11 761 | m_Type: 1 762 | m_Color: {r: 1, g: 0.95686275, b: 0.8392157, a: 1} 763 | m_Intensity: 1 764 | m_Range: 10 765 | m_SpotAngle: 30 766 | m_InnerSpotAngle: 21.80208 767 | m_CookieSize: 10 768 | m_Shadows: 769 | m_Type: 2 770 | m_Resolution: -1 771 | m_CustomResolution: -1 772 | m_Strength: 1 773 | m_Bias: 0.05 774 | m_NormalBias: 0.4 775 | m_NearPlane: 0.2 776 | m_CullingMatrixOverride: 777 | e00: 1 778 | e01: 0 779 | e02: 0 780 | e03: 0 781 | e10: 0 782 | e11: 1 783 | e12: 0 784 | e13: 0 785 | e20: 0 786 | e21: 0 787 | e22: 1 788 | e23: 0 789 | e30: 0 790 | e31: 0 791 | e32: 0 792 | e33: 1 793 | m_UseCullingMatrixOverride: 0 794 | m_Cookie: {fileID: 0} 795 | m_DrawHalo: 0 796 | m_Flare: {fileID: 0} 797 | m_RenderMode: 0 798 | m_CullingMask: 799 | serializedVersion: 2 800 | m_Bits: 4294967295 801 | m_RenderingLayerMask: 1 802 | m_Lightmapping: 4 803 | m_LightShadowCasterMode: 0 804 | m_AreaSize: {x: 1, y: 1} 805 | m_BounceIntensity: 1 806 | m_ColorTemperature: 6570 807 | m_UseColorTemperature: 0 808 | m_BoundingSphereOverride: {x: 0, y: 0, z: 0, w: 0} 809 | m_UseBoundingSphereOverride: 0 810 | m_UseViewFrustumForShadowCasterCull: 1 811 | m_ForceVisible: 0 812 | m_ShadowRadius: 0 813 | m_ShadowAngle: 0 814 | m_LightUnit: 1 815 | m_LuxAtDistance: 1 816 | m_EnableSpotReflector: 1 817 | --- !u!4 &1813667958 818 | Transform: 819 | m_ObjectHideFlags: 0 820 | m_CorrespondingSourceObject: {fileID: 0} 821 | m_PrefabInstance: {fileID: 0} 822 | m_PrefabAsset: {fileID: 0} 823 | m_GameObject: {fileID: 1813667956} 824 | serializedVersion: 2 825 | m_LocalRotation: {x: 0.40821788, y: -0.23456968, z: 0.10938163, w: 0.8754261} 826 | m_LocalPosition: {x: 0, y: 3, z: 0} 827 | m_LocalScale: {x: 1, y: 1, z: 1} 828 | m_ConstrainProportionsScale: 0 829 | m_Children: [] 830 | m_Father: {fileID: 0} 831 | m_LocalEulerAnglesHint: {x: 50, y: -30, z: 0} 832 | --- !u!114 &1813667959 833 | MonoBehaviour: 834 | m_ObjectHideFlags: 0 835 | m_CorrespondingSourceObject: {fileID: 0} 836 | m_PrefabInstance: {fileID: 0} 837 | m_PrefabAsset: {fileID: 0} 838 | m_GameObject: {fileID: 1813667956} 839 | m_Enabled: 1 840 | m_EditorHideFlags: 0 841 | m_Script: {fileID: 11500000, guid: 474bcb49853aa07438625e644c072ee6, type: 3} 842 | m_Name: 843 | m_EditorClassIdentifier: 844 | m_Version: 3 845 | m_UsePipelineSettings: 1 846 | m_AdditionalLightsShadowResolutionTier: 2 847 | m_LightLayerMask: 1 848 | m_RenderingLayers: 1 849 | m_CustomShadowLayers: 0 850 | m_ShadowLayerMask: 1 851 | m_ShadowRenderingLayers: 1 852 | m_LightCookieSize: {x: 1, y: 1} 853 | m_LightCookieOffset: {x: 0, y: 0} 854 | m_SoftShadowQuality: 1 855 | --- !u!1 &2013786311 856 | GameObject: 857 | m_ObjectHideFlags: 0 858 | m_CorrespondingSourceObject: {fileID: 0} 859 | m_PrefabInstance: {fileID: 0} 860 | m_PrefabAsset: {fileID: 0} 861 | serializedVersion: 6 862 | m_Component: 863 | - component: {fileID: 2013786314} 864 | - component: {fileID: 2013786313} 865 | - component: {fileID: 2013786312} 866 | - component: {fileID: 2013786315} 867 | m_Layer: 0 868 | m_Name: Main Camera 869 | m_TagString: MainCamera 870 | m_Icon: {fileID: 0} 871 | m_NavMeshLayer: 0 872 | m_StaticEditorFlags: 0 873 | m_IsActive: 1 874 | --- !u!81 &2013786312 875 | AudioListener: 876 | m_ObjectHideFlags: 0 877 | m_CorrespondingSourceObject: {fileID: 0} 878 | m_PrefabInstance: {fileID: 0} 879 | m_PrefabAsset: {fileID: 0} 880 | m_GameObject: {fileID: 2013786311} 881 | m_Enabled: 1 882 | --- !u!20 &2013786313 883 | Camera: 884 | m_ObjectHideFlags: 0 885 | m_CorrespondingSourceObject: {fileID: 0} 886 | m_PrefabInstance: {fileID: 0} 887 | m_PrefabAsset: {fileID: 0} 888 | m_GameObject: {fileID: 2013786311} 889 | m_Enabled: 1 890 | serializedVersion: 2 891 | m_ClearFlags: 1 892 | m_BackGroundColor: {r: 0.19215687, g: 0.3019608, b: 0.4745098, a: 0} 893 | m_projectionMatrixMode: 1 894 | m_GateFitMode: 2 895 | m_FOVAxisMode: 0 896 | m_Iso: 200 897 | m_ShutterSpeed: 0.005 898 | m_Aperture: 16 899 | m_FocusDistance: 10 900 | m_FocalLength: 50 901 | m_BladeCount: 5 902 | m_Curvature: {x: 2, y: 11} 903 | m_BarrelClipping: 0.25 904 | m_Anamorphism: 0 905 | m_SensorSize: {x: 36, y: 24} 906 | m_LensShift: {x: 0, y: 0} 907 | m_NormalizedViewPortRect: 908 | serializedVersion: 2 909 | x: 0 910 | y: 0 911 | width: 1 912 | height: 1 913 | near clip plane: 0.3 914 | far clip plane: 1000 915 | field of view: 60 916 | orthographic: 0 917 | orthographic size: 5 918 | m_Depth: -1 919 | m_CullingMask: 920 | serializedVersion: 2 921 | m_Bits: 4294967295 922 | m_RenderingPath: -1 923 | m_TargetTexture: {fileID: 0} 924 | m_TargetDisplay: 0 925 | m_TargetEye: 3 926 | m_HDR: 1 927 | m_AllowMSAA: 1 928 | m_AllowDynamicResolution: 0 929 | m_ForceIntoRT: 0 930 | m_OcclusionCulling: 1 931 | m_StereoConvergence: 10 932 | m_StereoSeparation: 0.022 933 | --- !u!4 &2013786314 934 | Transform: 935 | m_ObjectHideFlags: 0 936 | m_CorrespondingSourceObject: {fileID: 0} 937 | m_PrefabInstance: {fileID: 0} 938 | m_PrefabAsset: {fileID: 0} 939 | m_GameObject: {fileID: 2013786311} 940 | serializedVersion: 2 941 | m_LocalRotation: {x: 0.15738246, y: 0, z: 0, w: 0.98753774} 942 | m_LocalPosition: {x: 0, y: 3.22, z: -10} 943 | m_LocalScale: {x: 1, y: 1, z: 1} 944 | m_ConstrainProportionsScale: 0 945 | m_Children: [] 946 | m_Father: {fileID: 0} 947 | m_LocalEulerAnglesHint: {x: 18.11, y: 0, z: 0} 948 | --- !u!114 &2013786315 949 | MonoBehaviour: 950 | m_ObjectHideFlags: 0 951 | m_CorrespondingSourceObject: {fileID: 0} 952 | m_PrefabInstance: {fileID: 0} 953 | m_PrefabAsset: {fileID: 0} 954 | m_GameObject: {fileID: 2013786311} 955 | m_Enabled: 1 956 | m_EditorHideFlags: 0 957 | m_Script: {fileID: 11500000, guid: a79441f348de89743a2939f4d699eac1, type: 3} 958 | m_Name: 959 | m_EditorClassIdentifier: 960 | m_RenderShadows: 1 961 | m_RequiresDepthTextureOption: 2 962 | m_RequiresOpaqueTextureOption: 2 963 | m_CameraType: 0 964 | m_Cameras: [] 965 | m_RendererIndex: -1 966 | m_VolumeLayerMask: 967 | serializedVersion: 2 968 | m_Bits: 1 969 | m_VolumeTrigger: {fileID: 0} 970 | m_VolumeFrameworkUpdateModeOption: 2 971 | m_RenderPostProcessing: 0 972 | m_Antialiasing: 0 973 | m_AntialiasingQuality: 2 974 | m_StopNaN: 0 975 | m_Dithering: 0 976 | m_ClearDepth: 1 977 | m_AllowXRRendering: 1 978 | m_AllowHDROutput: 1 979 | m_UseScreenCoordOverride: 0 980 | m_ScreenSizeOverride: {x: 0, y: 0, z: 0, w: 0} 981 | m_ScreenCoordScaleBias: {x: 0, y: 0, z: 0, w: 0} 982 | m_RequiresDepthTexture: 0 983 | m_RequiresColorTexture: 0 984 | m_Version: 2 985 | m_TaaSettings: 986 | m_Quality: 3 987 | m_FrameInfluence: 0.1 988 | m_JitterScale: 1 989 | m_MipBias: 0 990 | m_VarianceClampScale: 0.9 991 | m_ContrastAdaptiveSharpening: 0 992 | --- !u!1660057539 &9223372036854775807 993 | SceneRoots: 994 | m_ObjectHideFlags: 0 995 | m_Roots: 996 | - {fileID: 2013786314} 997 | - {fileID: 1813667958} 998 | - {fileID: 684810860} 999 | - {fileID: 1473156611} 1000 | - {fileID: 51833948} 1001 | - {fileID: 1273727354} 1002 | -------------------------------------------------------------------------------- /Demo/DemoMove.unity.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 808c84cda95654d489705045217f0c97 3 | DefaultImporter: 4 | externalObjects: {} 5 | userData: 6 | assetBundleName: 7 | assetBundleVariant: 8 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | Apache License 2 | Version 2.0, January 2004 3 | http://www.apache.org/licenses/ 4 | 5 | TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION 6 | 7 | 1. Definitions. 8 | 9 | "License" shall mean the terms and conditions for use, reproduction, 10 | and distribution as defined by Sections 1 through 9 of this document. 11 | 12 | "Licensor" shall mean the copyright owner or entity authorized by 13 | the copyright owner that is granting the License. 14 | 15 | "Legal Entity" shall mean the union of the acting entity and all 16 | other entities that control, are controlled by, or are under common 17 | control with that entity. For the purposes of this definition, 18 | "control" means (i) the power, direct or indirect, to cause the 19 | direction or management of such entity, whether by contract or 20 | otherwise, or (ii) ownership of fifty percent (50%) or more of the 21 | outstanding shares, or (iii) beneficial ownership of such entity. 22 | 23 | "You" (or "Your") shall mean an individual or Legal Entity 24 | exercising permissions granted by this License. 25 | 26 | "Source" form shall mean the preferred form for making modifications, 27 | including but not limited to software source code, documentation 28 | source, and configuration files. 29 | 30 | "Object" form shall mean any form resulting from mechanical 31 | transformation or translation of a Source form, including but 32 | not limited to compiled object code, generated documentation, 33 | and conversions to other media types. 34 | 35 | "Work" shall mean the work of authorship, whether in Source or 36 | Object form, made available under the License, as indicated by a 37 | copyright notice that is included in or attached to the work 38 | (an example is provided in the Appendix below). 39 | 40 | "Derivative Works" shall mean any work, whether in Source or Object 41 | form, that is based on (or derived from) the Work and for which the 42 | editorial revisions, annotations, elaborations, or other modifications 43 | represent, as a whole, an original work of authorship. For the purposes 44 | of this License, Derivative Works shall not include works that remain 45 | separable from, or merely link (or bind by name) to the interfaces of, 46 | the Work and Derivative Works thereof. 47 | 48 | "Contribution" shall mean any work of authorship, including 49 | the original version of the Work and any modifications or additions 50 | to that Work or Derivative Works thereof, that is intentionally 51 | submitted to Licensor for inclusion in the Work by the copyright owner 52 | or by an individual or Legal Entity authorized to submit on behalf of 53 | the copyright owner. For the purposes of this definition, "submitted" 54 | means any form of electronic, verbal, or written communication sent 55 | to the Licensor or its representatives, including but not limited to 56 | communication on electronic mailing lists, source code control systems, 57 | and issue tracking systems that are managed by, or on behalf of, the 58 | Licensor for the purpose of discussing and improving the Work, but 59 | excluding communication that is conspicuously marked or otherwise 60 | designated in writing by the copyright owner as "Not a Contribution." 61 | 62 | "Contributor" shall mean Licensor and any individual or Legal Entity 63 | on behalf of whom a Contribution has been received by Licensor and 64 | subsequently incorporated within the Work. 65 | 66 | 2. Grant of Copyright License. Subject to the terms and conditions of 67 | this License, each Contributor hereby grants to You a perpetual, 68 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 69 | copyright license to reproduce, prepare Derivative Works of, 70 | publicly display, publicly perform, sublicense, and distribute the 71 | Work and such Derivative Works in Source or Object form. 72 | 73 | 3. Grant of Patent License. Subject to the terms and conditions of 74 | this License, each Contributor hereby grants to You a perpetual, 75 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 76 | (except as stated in this section) patent license to make, have made, 77 | use, offer to sell, sell, import, and otherwise transfer the Work, 78 | where such license applies only to those patent claims licensable 79 | by such Contributor that are necessarily infringed by their 80 | Contribution(s) alone or by combination of their Contribution(s) 81 | with the Work to which such Contribution(s) was submitted. If You 82 | institute patent litigation against any entity (including a 83 | cross-claim or counterclaim in a lawsuit) alleging that the Work 84 | or a Contribution incorporated within the Work constitutes direct 85 | or contributory patent infringement, then any patent licenses 86 | granted to You under this License for that Work shall terminate 87 | as of the date such litigation is filed. 88 | 89 | 4. Redistribution. You may reproduce and distribute copies of the 90 | Work or Derivative Works thereof in any medium, with or without 91 | modifications, and in Source or Object form, provided that You 92 | meet the following conditions: 93 | 94 | (a) You must give any other recipients of the Work or 95 | Derivative Works a copy of this License; and 96 | 97 | (b) You must cause any modified files to carry prominent notices 98 | stating that You changed the files; and 99 | 100 | (c) You must retain, in the Source form of any Derivative Works 101 | that You distribute, all copyright, patent, trademark, and 102 | attribution notices from the Source form of the Work, 103 | excluding those notices that do not pertain to any part of 104 | the Derivative Works; and 105 | 106 | (d) If the Work includes a "NOTICE" text file as part of its 107 | distribution, then any Derivative Works that You distribute must 108 | include a readable copy of the attribution notices contained 109 | within such NOTICE file, excluding those notices that do not 110 | pertain to any part of the Derivative Works, in at least one 111 | of the following places: within a NOTICE text file distributed 112 | as part of the Derivative Works; within the Source form or 113 | documentation, if provided along with the Derivative Works; or, 114 | within a display generated by the Derivative Works, if and 115 | wherever such third-party notices normally appear. The contents 116 | of the NOTICE file are for informational purposes only and 117 | do not modify the License. You may add Your own attribution 118 | notices within Derivative Works that You distribute, alongside 119 | or as an addendum to the NOTICE text from the Work, provided 120 | that such additional attribution notices cannot be construed 121 | as modifying the License. 122 | 123 | You may add Your own copyright statement to Your modifications and 124 | may provide additional or different license terms and conditions 125 | for use, reproduction, or distribution of Your modifications, or 126 | for any such Derivative Works as a whole, provided Your use, 127 | reproduction, and distribution of the Work otherwise complies with 128 | the conditions stated in this License. 129 | 130 | 5. Submission of Contributions. Unless You explicitly state otherwise, 131 | any Contribution intentionally submitted for inclusion in the Work 132 | by You to the Licensor shall be under the terms and conditions of 133 | this License, without any additional terms or conditions. 134 | Notwithstanding the above, nothing herein shall supersede or modify 135 | the terms of any separate license agreement you may have executed 136 | with Licensor regarding such Contributions. 137 | 138 | 6. Trademarks. This License does not grant permission to use the trade 139 | names, trademarks, service marks, or product names of the Licensor, 140 | except as required for reasonable and customary use in describing the 141 | origin of the Work and reproducing the content of the NOTICE file. 142 | 143 | 7. Disclaimer of Warranty. Unless required by applicable law or 144 | agreed to in writing, Licensor provides the Work (and each 145 | Contributor provides its Contributions) on an "AS IS" BASIS, 146 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 147 | implied, including, without limitation, any warranties or conditions 148 | of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A 149 | PARTICULAR PURPOSE. You are solely responsible for determining the 150 | appropriateness of using or redistributing the Work and assume any 151 | risks associated with Your exercise of permissions under this License. 152 | 153 | 8. Limitation of Liability. In no event and under no legal theory, 154 | whether in tort (including negligence), contract, or otherwise, 155 | unless required by applicable law (such as deliberate and grossly 156 | negligent acts) or agreed to in writing, shall any Contributor be 157 | liable to You for damages, including any direct, indirect, special, 158 | incidental, or consequential damages of any character arising as a 159 | result of this License or out of the use or inability to use the 160 | Work (including but not limited to damages for loss of goodwill, 161 | work stoppage, computer failure or malfunction, or any and all 162 | other commercial damages or losses), even if such Contributor 163 | has been advised of the possibility of such damages. 164 | 165 | 9. Accepting Warranty or Additional Liability. While redistributing 166 | the Work or Derivative Works thereof, You may choose to offer, 167 | and charge a fee for, acceptance of support, warranty, indemnity, 168 | or other liability obligations and/or rights consistent with this 169 | License. However, in accepting such obligations, You may act only 170 | on Your own behalf and on Your sole responsibility, not on behalf 171 | of any other Contributor, and only if You agree to indemnify, 172 | defend, and hold each Contributor harmless for any liability 173 | incurred by, or claims asserted against, such Contributor by reason 174 | of your accepting any such warranty or additional liability. 175 | 176 | END OF TERMS AND CONDITIONS 177 | 178 | APPENDIX: How to apply the Apache License to your work. 179 | 180 | To apply the Apache License to your work, attach the following 181 | boilerplate notice, with the fields enclosed by brackets "[]" 182 | replaced with your own identifying information. (Don't include 183 | the brackets!) The text should be enclosed in the appropriate 184 | comment syntax for the file format. We also recommend that a 185 | file or class name and description of purpose be included on the 186 | same "printed page" as the copyright notice for easier 187 | identification within third-party archives. 188 | 189 | Copyright [yyyy] [name of copyright owner] 190 | 191 | Licensed under the Apache License, Version 2.0 (the "License"); 192 | you may not use this file except in compliance with the License. 193 | You may obtain a copy of the License at 194 | 195 | http://www.apache.org/licenses/LICENSE-2.0 196 | 197 | Unless required by applicable law or agreed to in writing, software 198 | distributed under the License is distributed on an "AS IS" BASIS, 199 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 200 | See the License for the specific language governing permissions and 201 | limitations under the License. 202 | -------------------------------------------------------------------------------- /LICENSE.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 425da90b62e1db940ad80cc9784a622f 3 | DefaultImporter: 4 | externalObjects: {} 5 | userData: 6 | assetBundleName: 7 | assetBundleVariant: 8 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # unity-animation 2 | Extended Animation Framework for Unity based on Coroutines 3 | 4 | # install 5 | Use this repository as GitHub URL. It contains a package manifest file. 6 | 7 | ### Open UPM 8 | URL: https://package.openupm.com 9 | 10 | Scope: org.pcsoft 11 | 12 | # usage 13 | There is a builder to create and run animations. The builder supports a lot of animation types. 14 | See the following code to understood how it works: 15 | 16 | ```c# 17 | AnimationBuilder.Create(this) 18 | .Wait(1f) //Wait for one second 19 | .Animate(myCurve, mySpeed, v => {...}) //Animate along a curve only between 0 and 1! 20 | .AnimateConstant(1f, v => {...}) //Animate without curve constant (linear) 21 | .RunAll(1f, new Action[] {...}) //Run all actions with given delay of one second 22 | .RunRepeated(1f, 10, i => {...}) //Run repeated 10 times with delay of one second this action 23 | .Parallel(builder => {...}) //Run in parallel and gets a builder to create animation. This is experimental! 24 | .WithFinisher(() => {...}) //Execute an action after step before has finished. 25 | .Start(); 26 | ``` 27 | 28 | Additional you can add a finisher to each step as last parameter. 29 | 30 | As extension you can transfer data between animation steps: 31 | 32 | ```c# 33 | AnimationBuilder.Create(this) 34 | .Animate(myCurve, mySpeed, (v, data) => ..., data => data.Set(key, value)) 35 | .Animate(myCurve, mySpeed, (v, data) => Mathf.abs(v * data.Get(key))) 36 | .Start() 37 | ``` 38 | 39 | To get a better control for the animations the method `Start()` returns an `AnimationRunner` object: 40 | 41 | ```c# 42 | var runner = AnimationBuilder.Create(this) 43 | ... 44 | .Start(); 45 | 46 | ... 47 | 48 | runner.Stop(); //Stop the animation 49 | ``` 50 | 51 | If you create the `AnimationBuilder` you can setup the time is used: 52 | 53 | ```c# 54 | AnimationBuilder.Create(this, AnimationType.Unscaled) 55 | ``` 56 | 57 | The default is _scaled time_. 58 | -------------------------------------------------------------------------------- /README.md.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: e0c2817846da2d545aa8faf0db001604 3 | TextScriptImporter: 4 | externalObjects: {} 5 | userData: 6 | assetBundleName: 7 | assetBundleVariant: 8 | -------------------------------------------------------------------------------- /Scripts.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 88b60d840aa4df7489ae903e247c4ba6 3 | folderAsset: yes 4 | DefaultImporter: 5 | externalObjects: {} 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Scripts/Runtime.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: b46a0e84d6f4bac4ba5162d9a493ca62 3 | folderAsset: yes 4 | DefaultImporter: 5 | externalObjects: {} 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Scripts/Runtime/Components.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 4a7a4fc048af479f9d9680e608cb036b 3 | timeCreated: 1678732246 -------------------------------------------------------------------------------- /Scripts/Runtime/Components/Rotator.cs: -------------------------------------------------------------------------------- 1 | using UnityEngine; 2 | 3 | namespace UnityAnimation.Runtime.Projects.unity_animation.Scripts.Runtime.Components 4 | { 5 | [AddComponentMenu(UnityAnimationConstants.Root + "/Rotator")] 6 | [DisallowMultipleComponent] 7 | public sealed class Rotator : SimpleAnimator 8 | { 9 | #region Inspector Data 10 | 11 | [SerializeField] 12 | private AnimationCurve rotationCurve = AnimationCurve.Constant(0f, 1f, 1f); 13 | 14 | [SerializeField] 15 | private Vector3 eulerRotation; 16 | 17 | #endregion 18 | 19 | protected override void Animate(float deltaTime) => 20 | transform.rotation *= Quaternion.Euler(eulerRotation * (deltaTime * rotationCurve.Evaluate(deltaTime))); 21 | } 22 | } -------------------------------------------------------------------------------- /Scripts/Runtime/Components/Rotator.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: a1f8e3335efe4313b993c56f8b82506f 3 | timeCreated: 1678731466 -------------------------------------------------------------------------------- /Scripts/Runtime/Components/Scaler.cs: -------------------------------------------------------------------------------- 1 | using UnityEngine; 2 | 3 | namespace UnityAnimation.Runtime.Projects.unity_animation.Scripts.Runtime.Components 4 | { 5 | [AddComponentMenu(UnityAnimationConstants.Root + "/Scaler")] 6 | [DisallowMultipleComponent] 7 | public sealed class Scaler : SimpleAnimator 8 | { 9 | #region Inspector Data 10 | 11 | [SerializeField] 12 | private AnimationCurve scalingCurve = AnimationCurve.EaseInOut(0f, 0f, 1f, 1f); 13 | 14 | [SerializeField] 15 | [Min(0.000000000000001f)] 16 | private float scalingSpeed = 1f; 17 | 18 | [Space] 19 | [SerializeField] 20 | private Vector3 scalingStart = Vector3.one; 21 | 22 | [SerializeField] 23 | private Vector3 scalingEnd = Vector3.one * 2f; 24 | 25 | #endregion 26 | 27 | protected override void Animate(float deltaTime) => 28 | transform.localScale = Vector3.Lerp(scalingStart, scalingEnd, scalingCurve.Evaluate(deltaTime * scalingSpeed)); 29 | } 30 | } -------------------------------------------------------------------------------- /Scripts/Runtime/Components/Scaler.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: c47cdaaac29a480ba961290f10cf46c7 3 | timeCreated: 1678732167 -------------------------------------------------------------------------------- /Scripts/Runtime/Components/SimpleAnimator.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using UnityAnimation.Runtime.Projects.unity_animation.Scripts.Runtime.Types; 3 | using UnityEngine; 4 | 5 | namespace UnityAnimation.Runtime.Projects.unity_animation.Scripts.Runtime.Components 6 | { 7 | public abstract class SimpleAnimator : MonoBehaviour 8 | { 9 | #region Inspector Data 10 | 11 | [Header("Animation")] 12 | [SerializeField] 13 | protected AnimationType animationType = AnimationType.Scaled; 14 | 15 | #endregion 16 | 17 | #region Builtin Methods 18 | 19 | private void FixedUpdate() 20 | { 21 | var fixedDeltaTime = animationType switch 22 | { 23 | AnimationType.Scaled => Time.fixedDeltaTime, 24 | AnimationType.Unscaled => Time.fixedUnscaledDeltaTime, 25 | _ => throw new NotImplementedException(animationType.ToString()) 26 | }; 27 | Animate(fixedDeltaTime); 28 | } 29 | 30 | #endregion 31 | 32 | protected abstract void Animate(float deltaTime); 33 | } 34 | } -------------------------------------------------------------------------------- /Scripts/Runtime/Components/SimpleAnimator.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: f811093530f94d1c9973ca527155e8e6 3 | timeCreated: 1678732321 -------------------------------------------------------------------------------- /Scripts/Runtime/Types.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 883cbe96b4fdf8047b568cc6ac3d0d5c 3 | folderAsset: yes 4 | DefaultImporter: 5 | externalObjects: {} 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Scripts/Runtime/Types/AnimationData.cs: -------------------------------------------------------------------------------- 1 | using System.Collections.Generic; 2 | 3 | namespace UnityAnimation.Runtime.Projects.unity_animation.Scripts.Runtime.Types 4 | { 5 | public sealed class AnimationData 6 | { 7 | private readonly IDictionary _data = new Dictionary(); 8 | 9 | public object Get(object key) => _data.ContainsKey(key) ? _data[key] : null; 10 | public T Get(object key) => (T) Get(key); 11 | 12 | public void Set(object key, object value) 13 | { 14 | if (_data.ContainsKey(key)) 15 | _data[key] = value; 16 | else 17 | _data.Add(key, value); 18 | } 19 | } 20 | } -------------------------------------------------------------------------------- /Scripts/Runtime/Types/AnimationData.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 0e7f9e7b7797435eb02cdf830c829a17 3 | timeCreated: 1636833482 -------------------------------------------------------------------------------- /Scripts/Runtime/Types/AnimationType.cs: -------------------------------------------------------------------------------- 1 | namespace UnityAnimation.Runtime.Projects.unity_animation.Scripts.Runtime.Types 2 | { 3 | public enum AnimationType 4 | { 5 | Scaled, 6 | Unscaled 7 | } 8 | } -------------------------------------------------------------------------------- /Scripts/Runtime/Types/AnimationType.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: e48df84bc76dc724c9ddf6ac966637c7 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Scripts/Runtime/UnityAnimation.Runtime.asmdef: -------------------------------------------------------------------------------- 1 | { 2 | "name": "UnityAnimation.Runtime", 3 | "rootNamespace": "UnityAnimation.Runtime", 4 | "references": [ 5 | "GUID:64c52e74a682df04189ccbd30b6ca5aa" 6 | ], 7 | "includePlatforms": [], 8 | "excludePlatforms": [], 9 | "allowUnsafeCode": false, 10 | "overrideReferences": false, 11 | "precompiledReferences": [], 12 | "autoReferenced": true, 13 | "defineConstraints": [], 14 | "versionDefines": [], 15 | "noEngineReferences": false 16 | } -------------------------------------------------------------------------------- /Scripts/Runtime/UnityAnimation.Runtime.asmdef.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 6753ff2140978d34db1d9899e49b3857 3 | AssemblyDefinitionImporter: 4 | externalObjects: {} 5 | userData: 6 | assetBundleName: 7 | assetBundleVariant: 8 | -------------------------------------------------------------------------------- /Scripts/Runtime/UnityAnimationConstants.cs: -------------------------------------------------------------------------------- 1 | namespace UnityAnimation.Runtime.Projects.unity_animation.Scripts.Runtime 2 | { 3 | internal static class UnityAnimationConstants 4 | { 5 | public const string Root = "Unity Animations"; 6 | } 7 | } -------------------------------------------------------------------------------- /Scripts/Runtime/UnityAnimationConstants.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: a944953f7ff8394459d6ef4539d78f1d 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Scripts/Runtime/Utils.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 498f9f7f1d138e441936a92ed981ab1a 3 | folderAsset: yes 4 | DefaultImporter: 5 | externalObjects: {} 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Scripts/Runtime/Utils/AnimationBuilder.Runner.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections; 3 | using UnityAnimation.Runtime.Projects.unity_animation.Scripts.Runtime.Types; 4 | using UnityEngine; 5 | 6 | namespace UnityAnimation.Runtime.Projects.unity_animation.Scripts.Runtime.Utils 7 | { 8 | public sealed partial class AnimationBuilder 9 | { 10 | public bool IsRunning { get; private set; } 11 | 12 | public AnimationRunner Start(float delayed, Action onFinished = null) 13 | { 14 | if (_steps.Count <= 0) 15 | throw new InvalidOperationException("No animation inside builder"); 16 | if (IsRunning) 17 | throw new InvalidOperationException("Is already running"); 18 | 19 | var animationRunner = new AnimationRunner(_behaviour); 20 | 21 | IsRunning = true; 22 | animationRunner.Coroutine = Run(AnimationUtils.WaitAndRun(delayed, new AnimationData(), data => 23 | { 24 | onFinished?.Invoke(data); 25 | if (animationRunner.IsStopped) 26 | return; 27 | 28 | StartNext(0, animationRunner, data); 29 | })); 30 | 31 | return animationRunner; 32 | } 33 | 34 | public AnimationRunner Start() 35 | { 36 | return Start(new AnimationData()); 37 | } 38 | 39 | private AnimationRunner Start(AnimationData data) 40 | { 41 | if (_steps.Count <= 0) 42 | throw new InvalidOperationException("No animation inside builder"); 43 | if (IsRunning) 44 | throw new InvalidOperationException("Is already running"); 45 | 46 | var animationRunner = new AnimationRunner(_behaviour); 47 | 48 | IsRunning = true; 49 | StartNext(0, animationRunner, data); 50 | 51 | return animationRunner; 52 | } 53 | 54 | private void StartNext(int stepIndex, AnimationRunner animationRunner, AnimationData data) 55 | { 56 | if (stepIndex >= _steps.Count) 57 | { 58 | _onFinished?.Invoke(data); 59 | IsRunning = false; 60 | 61 | return; 62 | } 63 | 64 | var step = _steps[stepIndex]; 65 | if (step is SubAnimationStep subAnimStep) 66 | { 67 | subAnimStep.RunSubAnimation.Invoke(() => 68 | { 69 | subAnimStep.OnFinished?.Invoke(data); 70 | if (animationRunner.IsStopped) 71 | return; 72 | StartNext(stepIndex + 1, animationRunner, data); 73 | }, data); 74 | } 75 | else if (step is AnimateAnimationStep animStep) 76 | { 77 | animationRunner.Coroutine = Run(AnimationUtils.RunAnimation(_type, animStep.Curves, animStep.Speed, animStep.Revert, animStep.Handler, data, data => 78 | { 79 | animStep.OnFinished?.Invoke(data); 80 | if (animationRunner.IsStopped) 81 | return; 82 | StartNext(stepIndex + 1, animationRunner, data); 83 | })); 84 | } 85 | else if (step is AnimateConstantAnimationStep animConstStep) 86 | { 87 | animationRunner.Coroutine = Run(AnimationUtils.RunAnimationConstant(_type, animConstStep.Time, animConstStep.Handler, data, data => 88 | { 89 | animConstStep.OnFinished?.Invoke(data); 90 | if (animationRunner.IsStopped) 91 | return; 92 | StartNext(stepIndex + 1, animationRunner, data); 93 | })); 94 | } 95 | else if (step is WaitSecondsAnimationStep waitSecStep) 96 | { 97 | animationRunner.Coroutine = Run(AnimationUtils.WaitAndRun(_type, waitSecStep.Seconds, data, data => 98 | { 99 | waitSecStep.OnFinished?.Invoke(data); 100 | if (animationRunner.IsStopped) 101 | return; 102 | StartNext(stepIndex + 1, animationRunner, data); 103 | })); 104 | } 105 | else if (step is WaitFramesAnimationStep waitFrameStep) 106 | { 107 | animationRunner.Coroutine = Run(AnimationUtils.WaitAndRun(waitFrameStep.Frames, data, data => 108 | { 109 | waitFrameStep.OnFinished?.Invoke(data); 110 | if (animationRunner.IsStopped) 111 | return; 112 | StartNext(stepIndex + 1, animationRunner, data); 113 | })); 114 | } 115 | else if (step is RunAllSecondsAnimationStep runAllSecStep) 116 | { 117 | animationRunner.Coroutine = Run(AnimationUtils.RunAll(_type, runAllSecStep.Seconds, data, data => 118 | { 119 | runAllSecStep.OnFinished?.Invoke(data); 120 | if (animationRunner.IsStopped) 121 | return; 122 | StartNext(stepIndex + 1, animationRunner, data); 123 | }, runAllSecStep.Actions)); 124 | } 125 | else if (step is RunAllFramesAnimationStep runAllFramesStep) 126 | { 127 | animationRunner.Coroutine = Run(AnimationUtils.RunAll(_type, runAllFramesStep.Frames, data, data => 128 | { 129 | runAllFramesStep.OnFinished?.Invoke(data); 130 | if (animationRunner.IsStopped) 131 | return; 132 | StartNext(stepIndex + 1, animationRunner, data); 133 | }, runAllFramesStep.Actions)); 134 | } 135 | else if (step is RunRepeatSecondsAnimationStep runRepeatSecStep) 136 | { 137 | animationRunner.Coroutine = Run(AnimationUtils.RunAllSeconds( 138 | runRepeatSecStep.Seconds, runRepeatSecStep.RepeatCount, runRepeatSecStep.Inverted, runRepeatSecStep.Action, data, _type, data => 139 | { 140 | runRepeatSecStep.OnFinished?.Invoke(data); 141 | if (animationRunner.IsStopped) 142 | return; 143 | StartNext(stepIndex + 1, animationRunner, data); 144 | } 145 | )); 146 | } 147 | else if (step is RunRepeatFramesAnimationStep runRepeatFramesStep) 148 | { 149 | animationRunner.Coroutine = Run(AnimationUtils.RunAllFrames( 150 | runRepeatFramesStep.Frames, runRepeatFramesStep.RepeatCount, runRepeatFramesStep.Inverted, runRepeatFramesStep.Action, data, data => 151 | { 152 | runRepeatFramesStep.OnFinished?.Invoke(data); 153 | if (animationRunner.IsStopped) 154 | return; 155 | StartNext(stepIndex + 1, animationRunner, data); 156 | } 157 | )); 158 | } 159 | else if (step is ParallelAnimationStep parallelStep) 160 | { 161 | var builder = Create(_behaviour, _type); 162 | builder = parallelStep.BuildAction.Invoke(builder); 163 | 164 | if (!builder.IsRunning) 165 | { 166 | builder.Start(data); 167 | } 168 | } 169 | else if (step is ImmediatelyStep immediatelyStep) 170 | { 171 | immediatelyStep.OnFinished?.Invoke(data); 172 | StartNext(stepIndex + 1, animationRunner, data); 173 | } 174 | else 175 | throw new NotImplementedException(step.GetType().FullName); 176 | } 177 | 178 | private Coroutine Run(IEnumerator animation) 179 | { 180 | return _behaviour.StartCoroutine(animation); 181 | } 182 | } 183 | } -------------------------------------------------------------------------------- /Scripts/Runtime/Utils/AnimationBuilder.Runner.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 2734e5ea50f8ae149ac7cb128fadeb0d 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Scripts/Runtime/Utils/AnimationBuilder.Step.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using UnityAnimation.Runtime.Projects.unity_animation.Scripts.Runtime.Types; 3 | using UnityEngine; 4 | 5 | namespace UnityAnimation.Runtime.Projects.unity_animation.Scripts.Runtime.Utils 6 | { 7 | public sealed partial class AnimationBuilder 8 | { 9 | private abstract class AnimationStep 10 | { 11 | public Action OnFinished { get; } 12 | 13 | protected AnimationStep(Action onFinished) 14 | { 15 | OnFinished = onFinished; 16 | } 17 | } 18 | 19 | private sealed class AnimateConstantAnimationStep : AnimationStep 20 | { 21 | public float Time { get; } 22 | public Action Handler { get; } 23 | 24 | public AnimateConstantAnimationStep(float time, Action handler, Action onFinished) : base(onFinished) 25 | { 26 | Time = time; 27 | Handler = handler; 28 | } 29 | } 30 | 31 | private sealed class SubAnimationStep : AnimationStep 32 | { 33 | public Action RunSubAnimation { get; } 34 | 35 | public SubAnimationStep(Action runSubAnimation, Action onFinished) : base(onFinished) 36 | { 37 | RunSubAnimation = runSubAnimation; 38 | } 39 | } 40 | 41 | private sealed class AnimateAnimationStep : AnimationStep 42 | { 43 | public AnimationCurve[] Curves { get; } 44 | public float Speed { get; } 45 | public bool Revert { get; } 46 | public Action Handler { get; } 47 | 48 | public AnimateAnimationStep(AnimationCurve curve, float speed, bool revert, Action handler, Action onFinished) 49 | : this(new[] { curve }, speed, revert, (values, data) => handler(values[0], data), onFinished) 50 | { 51 | } 52 | 53 | public AnimateAnimationStep(AnimationCurve[] curves, float speed, bool revert, Action handler, Action onFinished) : base(onFinished) 54 | { 55 | Curves = curves; 56 | Speed = speed; 57 | Revert = revert; 58 | Handler = handler; 59 | } 60 | } 61 | 62 | private sealed class WaitSecondsAnimationStep : AnimationStep 63 | { 64 | public float Seconds { get; } 65 | 66 | public WaitSecondsAnimationStep(float seconds, Action onFinished) : base(onFinished) 67 | { 68 | Seconds = seconds; 69 | } 70 | } 71 | 72 | private sealed class WaitFramesAnimationStep : AnimationStep 73 | { 74 | public uint Frames { get; } 75 | 76 | public WaitFramesAnimationStep(uint frames, Action onFinished) : base(onFinished) 77 | { 78 | Frames = frames; 79 | } 80 | } 81 | 82 | private sealed class RunAllSecondsAnimationStep : AnimationStep 83 | { 84 | public float Seconds { get; } 85 | public Action[] Actions { get; } 86 | 87 | public RunAllSecondsAnimationStep(float seconds, Action[] actions, Action onFinished) : base(onFinished) 88 | { 89 | Seconds = seconds; 90 | Actions = actions; 91 | } 92 | } 93 | 94 | private sealed class RunAllFramesAnimationStep : AnimationStep 95 | { 96 | public uint Frames { get; } 97 | public Action[] Actions { get; } 98 | 99 | public RunAllFramesAnimationStep(uint frames, Action[] actions, Action onFinished) : base(onFinished) 100 | { 101 | Frames = frames; 102 | Actions = actions; 103 | } 104 | } 105 | 106 | private sealed class RunRepeatSecondsAnimationStep : AnimationStep 107 | { 108 | public float Seconds { get; } 109 | public uint RepeatCount { get; } 110 | public bool Inverted { get; } 111 | public Action Action { get; } 112 | 113 | public RunRepeatSecondsAnimationStep(float seconds, uint repeatCount, bool inverted, Action action, Action onFinished) : base(onFinished) 114 | { 115 | Seconds = seconds; 116 | RepeatCount = repeatCount; 117 | Inverted = inverted; 118 | Action = action; 119 | } 120 | } 121 | 122 | private sealed class RunRepeatFramesAnimationStep : AnimationStep 123 | { 124 | public uint Frames { get; } 125 | public uint RepeatCount { get; } 126 | public bool Inverted { get; } 127 | public Action Action { get; } 128 | 129 | public RunRepeatFramesAnimationStep(uint frames, uint repeatCount, bool inverted, Action action, Action onFinished) : base(onFinished) 130 | { 131 | Frames = frames; 132 | RepeatCount = repeatCount; 133 | Inverted = inverted; 134 | Action = action; 135 | } 136 | } 137 | 138 | private sealed class ParallelAnimationStep : AnimationStep 139 | { 140 | public Func BuildAction { get; } 141 | 142 | public ParallelAnimationStep(Func buildAction, Action onFinished) : base(onFinished) 143 | { 144 | BuildAction = buildAction; 145 | } 146 | } 147 | 148 | private sealed class ImmediatelyStep : AnimationStep 149 | { 150 | public ImmediatelyStep(Action onFinished) : base(onFinished) 151 | { 152 | } 153 | } 154 | } 155 | } -------------------------------------------------------------------------------- /Scripts/Runtime/Utils/AnimationBuilder.Step.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: ecaed89e2eb167544940bff369a49259 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Scripts/Runtime/Utils/AnimationBuilder.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using UnityAnimation.Runtime.Projects.unity_animation.Scripts.Runtime.Types; 5 | using UnityBase.Runtime.Projects.unity_base.Scripts.Runtime.Components; 6 | using UnityEngine; 7 | 8 | namespace UnityAnimation.Runtime.Projects.unity_animation.Scripts.Runtime.Utils 9 | { 10 | public sealed partial class AnimationBuilder 11 | { 12 | public static AnimationBuilder Create(MonoBehaviour behaviour, AnimationType type = AnimationType.Scaled) 13 | { 14 | return new AnimationBuilder(behaviour, type); 15 | } 16 | 17 | public static AnimationBuilder Create(AnimationType type = AnimationType.Scaled) 18 | { 19 | return new AnimationBuilder(HelpBehavior.Instance, type); 20 | } 21 | 22 | private readonly MonoBehaviour _behaviour; 23 | private readonly AnimationType _type; 24 | private readonly IList _steps = new List(); 25 | 26 | private Action _onFinished; 27 | 28 | private AnimationBuilder(MonoBehaviour behaviour, AnimationType type) 29 | { 30 | _behaviour = behaviour; 31 | _type = type; 32 | } 33 | 34 | public AnimationBuilder SubAnimation(Action runSubAnimation) => SubAnimation(runSubAnimation, null); 35 | 36 | public AnimationBuilder SubAnimation(Action runSubAnimation, Action onFinished) => 37 | SubAnimation((finisher, _) => runSubAnimation?.Invoke(finisher), _ => onFinished?.Invoke()); 38 | 39 | public AnimationBuilder SubAnimation(Action runSubAnimation) => SubAnimation(runSubAnimation, null); 40 | 41 | public AnimationBuilder SubAnimation(Action runSubAnimation, Action onFinished) 42 | { 43 | _steps.Add(new SubAnimationStep(runSubAnimation, onFinished)); 44 | return this; 45 | } 46 | 47 | public AnimationBuilder Animate(AnimationCurve curve, float speed, Action handler) => 48 | Animate(curve, speed, false, handler, null); 49 | 50 | public AnimationBuilder Animate(AnimationCurve curve, float speed, bool revert, Action handler) => 51 | Animate(curve, speed, revert, handler, null); 52 | 53 | public AnimationBuilder Animate(AnimationCurve curve, float speed, Action handler, Action onFinished) => 54 | Animate(curve, speed, false, (v, _) => handler?.Invoke(v), _ => onFinished?.Invoke()); 55 | 56 | public AnimationBuilder Animate(AnimationCurve curve, float speed, bool revert, Action handler, Action onFinished) => 57 | Animate(curve, speed, revert, (v, _) => handler?.Invoke(v), _ => onFinished?.Invoke()); 58 | 59 | public AnimationBuilder Animate(AnimationCurve curve, float speed, Action handler) => 60 | Animate(curve, speed, false, handler, null); 61 | 62 | public AnimationBuilder Animate(AnimationCurve curve, float speed, bool revert, Action handler) => 63 | Animate(curve, speed, revert, handler, null); 64 | 65 | public AnimationBuilder Animate(AnimationCurve curve, float speed, Action handler, Action onFinished) => 66 | Animate(curve, speed, false, handler, onFinished); 67 | 68 | public AnimationBuilder Animate(AnimationCurve curve, float speed, bool revert, Action handler, Action onFinished) 69 | { 70 | _steps.Add(new AnimateAnimationStep(curve, speed, revert, handler, onFinished)); 71 | return this; 72 | } 73 | 74 | public AnimationBuilder Animate(AnimationCurve curve, Action handler) => Animate(curve, handler, null); 75 | 76 | public AnimationBuilder Animate(AnimationCurve curve, Action handler, Action onFinished) => 77 | Animate(curve, (v, _) => handler?.Invoke(v), _ => onFinished?.Invoke()); 78 | 79 | public AnimationBuilder Animate(AnimationCurve curve, Action handler) => Animate(curve, handler, null); 80 | 81 | public AnimationBuilder Animate(AnimationCurve curve, Action handler, Action onFinished) => 82 | Animate(curve, 1f, handler, onFinished); 83 | 84 | public AnimationBuilder AnimateConstant(float time, Action handler) => AnimateConstant(time, handler, null); 85 | 86 | public AnimationBuilder AnimateConstant(float time, Action handler, Action onFinished) => 87 | AnimateConstant(time, (v, _) => handler?.Invoke(v), _ => onFinished?.Invoke()); 88 | 89 | public AnimationBuilder AnimateConstant(float time, Action handler) => AnimateConstant(time, handler, null); 90 | 91 | public AnimationBuilder AnimateConstant(float time, Action handler, Action onFinished) 92 | { 93 | _steps.Add(new AnimateConstantAnimationStep(time, handler, onFinished)); 94 | return this; 95 | } 96 | 97 | public AnimationBuilder Wait(float seconds) => Wait(seconds, (Action)null); 98 | 99 | public AnimationBuilder Wait(float seconds, Action onFinished) => Wait(seconds, _ => onFinished?.Invoke()); 100 | 101 | public AnimationBuilder Wait(float seconds, Action onFinished) 102 | { 103 | _steps.Add(new WaitSecondsAnimationStep(seconds, onFinished)); 104 | return this; 105 | } 106 | 107 | public AnimationBuilder Wait(uint frames) => Wait(frames, (Action)null); 108 | 109 | public AnimationBuilder Wait(uint frames, Action onFinished) => Wait(frames, _ => onFinished?.Invoke()); 110 | 111 | public AnimationBuilder Wait(uint frames, Action onFinished) 112 | { 113 | _steps.Add(new WaitFramesAnimationStep(frames, onFinished)); 114 | return this; 115 | } 116 | 117 | public AnimationBuilder RunAll(float seconds, Action[] actions) => RunAll(seconds, actions, null); 118 | 119 | public AnimationBuilder RunAll(float seconds, Action[] actions, Action onFinished) => 120 | RunAll(seconds, actions.Select(x => (Action)(_ => x?.Invoke())).ToArray(), _ => onFinished?.Invoke()); 121 | 122 | public AnimationBuilder RunAll(float seconds, Action[] actions) => RunAll(seconds, actions, null); 123 | 124 | public AnimationBuilder RunAll(float seconds, Action[] actions, Action onFinished) 125 | { 126 | _steps.Add(new RunAllSecondsAnimationStep(seconds, actions, onFinished)); 127 | return this; 128 | } 129 | 130 | public AnimationBuilder RunAll(uint frames, Action[] actions) => RunAll(frames, actions, null); 131 | 132 | public AnimationBuilder RunAll(uint frames, Action[] actions, Action onFinished) => 133 | RunAll(frames, actions.Select(x => (Action)(_ => x?.Invoke())).ToArray(), _ => onFinished?.Invoke()); 134 | 135 | public AnimationBuilder RunAll(uint frames, Action[] actions) => RunAll(frames, actions, null); 136 | 137 | public AnimationBuilder RunAll(uint frames, Action[] actions, Action onFinished) 138 | { 139 | _steps.Add(new RunAllFramesAnimationStep(frames, actions, onFinished)); 140 | return this; 141 | } 142 | 143 | public AnimationBuilder RunRepeated(float seconds, uint repeatCount, bool inverted, Action action) => 144 | RunRepeated(seconds, repeatCount, inverted, action, null); 145 | 146 | public AnimationBuilder RunRepeated(float seconds, uint repeatCount, Action action) => 147 | RunRepeated(seconds, repeatCount, false, action, null); 148 | 149 | public AnimationBuilder RunRepeated(float seconds, uint repeatCount, bool inverted, Action action, Action onFinished) => 150 | RunRepeated(seconds, repeatCount, inverted, (i, _) => action?.Invoke(i), _ => onFinished?.Invoke()); 151 | 152 | public AnimationBuilder RunRepeated(float seconds, uint repeatCount, Action action, Action onFinished) => 153 | RunRepeated(seconds, repeatCount, false, (i, _) => action?.Invoke(i), _ => onFinished?.Invoke()); 154 | 155 | public AnimationBuilder RunRepeated(float seconds, uint repeatCount, bool inverted, Action action) => 156 | RunRepeated(seconds, repeatCount, inverted, action, null); 157 | 158 | public AnimationBuilder RunRepeated(float seconds, uint repeatCount, Action action) => 159 | RunRepeated(seconds, repeatCount, false, action, null); 160 | 161 | public AnimationBuilder RunRepeated(float seconds, uint repeatCount, Action action, Action onFinished) => 162 | RunRepeated(seconds, repeatCount, false, action, onFinished); 163 | 164 | public AnimationBuilder RunRepeated(float seconds, uint repeatCount, bool inverted, Action action, Action onFinished) 165 | { 166 | _steps.Add(new RunRepeatSecondsAnimationStep(seconds, repeatCount, inverted, action, onFinished)); 167 | return this; 168 | } 169 | 170 | public AnimationBuilder RunRepeated(uint frames, uint repeatCount, bool inverted, Action action) => 171 | RunRepeated(frames, repeatCount, inverted, action, null); 172 | 173 | public AnimationBuilder RunRepeated(uint frames, uint repeatCount, Action action) => 174 | RunRepeated(frames, repeatCount, false, action, null); 175 | 176 | public AnimationBuilder RunRepeated(uint frames, uint repeatCount, bool inverted, Action action, Action onFinished) => 177 | RunRepeated(frames, repeatCount, inverted, (i, _) => action?.Invoke(i), _ => onFinished?.Invoke()); 178 | 179 | public AnimationBuilder RunRepeated(uint frames, uint repeatCount, Action action, Action onFinished) => 180 | RunRepeated(frames, repeatCount, false, (i, _) => action?.Invoke(i), _ => onFinished?.Invoke()); 181 | 182 | public AnimationBuilder RunRepeated(uint frames, uint repeatCount, bool inverted, Action action) => 183 | RunRepeated(frames, repeatCount, inverted, action, null); 184 | 185 | public AnimationBuilder RunRepeated(uint frames, uint repeatCount, Action action) => 186 | RunRepeated(frames, repeatCount, false, action, null); 187 | 188 | public AnimationBuilder RunRepeated(uint frames, uint repeatCount, Action action, Action onFinished) => 189 | RunRepeated(frames, repeatCount, false, action, onFinished); 190 | 191 | public AnimationBuilder RunRepeated(uint frames, uint repeatCount, bool inverted, Action action, Action onFinished) 192 | { 193 | _steps.Add(new RunRepeatFramesAnimationStep(frames, repeatCount, inverted, action, onFinished)); 194 | return this; 195 | } 196 | 197 | /// 198 | /// Experimental 199 | /// 200 | /// 201 | /// 202 | public AnimationBuilder Parallel(Func action) => Parallel(action, (Action)null); 203 | 204 | /// 205 | /// Experimental 206 | /// 207 | /// 208 | /// 209 | /// 210 | public AnimationBuilder Parallel(Func action, Action onFinished) => 211 | Parallel(action, _ => onFinished?.Invoke()); 212 | 213 | /// 214 | /// Experimental 215 | /// 216 | /// 217 | /// 218 | /// 219 | public AnimationBuilder Parallel(Func action, Action onFinished) 220 | { 221 | _steps.Add(new ParallelAnimationStep(action, onFinished)); 222 | return this; 223 | } 224 | 225 | public AnimationBuilder Immediately(Action onFinished) => Immediately(_ => onFinished?.Invoke()); 226 | 227 | public AnimationBuilder Immediately(Action onFinished) 228 | { 229 | _steps.Add(new ImmediatelyStep(onFinished)); 230 | return this; 231 | } 232 | 233 | public AnimationBuilder WithFinisher(Action onFinished) => WithFinisher(_ => onFinished?.Invoke()); 234 | 235 | public AnimationBuilder WithFinisher(Action onFinished) 236 | { 237 | _onFinished = onFinished; 238 | return this; 239 | } 240 | } 241 | } -------------------------------------------------------------------------------- /Scripts/Runtime/Utils/AnimationBuilder.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 8e4b34c5d403dce4fbadcd50d2caa7f0 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Scripts/Runtime/Utils/AnimationRunner.cs: -------------------------------------------------------------------------------- 1 | using UnityEngine; 2 | 3 | namespace UnityAnimation.Runtime.Projects.unity_animation.Scripts.Runtime.Utils 4 | { 5 | public sealed class AnimationRunner 6 | { 7 | internal Coroutine Coroutine { get; set; } 8 | public bool IsStopped { get; private set; } 9 | 10 | private readonly MonoBehaviour _behaviour; 11 | 12 | internal AnimationRunner(MonoBehaviour behaviour) 13 | { 14 | _behaviour = behaviour; 15 | } 16 | 17 | public void Stop() 18 | { 19 | IsStopped = true; 20 | if (Coroutine != null) 21 | { 22 | _behaviour.StopCoroutine(Coroutine); 23 | } 24 | } 25 | } 26 | } -------------------------------------------------------------------------------- /Scripts/Runtime/Utils/AnimationRunner.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 8845062f86836a545bd1d69caf1e5305 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Scripts/Runtime/Utils/AnimationUtils.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections; 3 | using System.Linq; 4 | using UnityAnimation.Runtime.Projects.unity_animation.Scripts.Runtime.Types; 5 | using UnityEngine; 6 | 7 | namespace UnityAnimation.Runtime.Projects.unity_animation.Scripts.Runtime.Utils 8 | { 9 | internal static class AnimationUtils 10 | { 11 | public static IEnumerator RunAnimation(AnimationType type, AnimationCurve[] curves, float speed, bool revert, Action handler, AnimationData data, Action onFinished = null) 12 | { 13 | return RunAnimation(type, 0f, curves, speed, revert, handler, data, onFinished); 14 | } 15 | 16 | public static IEnumerator RunAnimation(AnimationType type, float preDelay, AnimationCurve[] curves, float speed, bool revert, Action handler, AnimationData data, Action onFinished) 17 | { 18 | if (preDelay > 0f) 19 | { 20 | switch (type) 21 | { 22 | case AnimationType.Scaled: 23 | yield return new WaitForSeconds(preDelay); 24 | break; 25 | case AnimationType.Unscaled: 26 | yield return new WaitForSecondsRealtime(preDelay); 27 | break; 28 | default: 29 | throw new NotImplementedException(); 30 | } 31 | } 32 | 33 | for (var i = 0f; i < speed; i += GetDelta(type)) 34 | { 35 | var v = i / speed; 36 | var values = curves.Select(x => x.Evaluate(revert ? 1f - v : v)).ToArray(); 37 | handler(values, data); 38 | 39 | yield return null; 40 | } 41 | 42 | var oneArray = new float[curves.Length]; 43 | for (var i = 0; i < oneArray.Length; i++) 44 | { 45 | oneArray[i] = 1f; 46 | } 47 | 48 | handler(oneArray, data); 49 | onFinished?.Invoke(data); 50 | } 51 | 52 | public static IEnumerator RunAnimationConstant(AnimationType type, float time, Action handler, AnimationData data, Action onFinished) 53 | { 54 | return RunAnimationConstant(type, 0f, time, handler, data, onFinished); 55 | } 56 | 57 | public static IEnumerator RunAnimationConstant(AnimationType type, float preDelay, float time, Action handler, AnimationData data, Action onFinished) 58 | { 59 | if (preDelay > 0f) 60 | { 61 | switch (type) 62 | { 63 | case AnimationType.Scaled: 64 | yield return new WaitForSeconds(preDelay); 65 | break; 66 | case AnimationType.Unscaled: 67 | yield return new WaitForSecondsRealtime(preDelay); 68 | break; 69 | default: 70 | throw new NotImplementedException(); 71 | } 72 | } 73 | 74 | for (var i = 0f; i < time; i += GetDelta(type)) 75 | { 76 | var value = i / time; 77 | handler(value, data); 78 | 79 | yield return null; 80 | } 81 | 82 | handler(1f, data); 83 | 84 | onFinished?.Invoke(data); 85 | } 86 | 87 | public static IEnumerator WaitAndRun(float preDelay, float postDelay, AnimationType type, AnimationData data, Action preAction, Action postAction) 88 | { 89 | switch (type) 90 | { 91 | case AnimationType.Scaled: 92 | yield return new WaitForSeconds(preDelay); 93 | break; 94 | case AnimationType.Unscaled: 95 | yield return new WaitForSecondsRealtime(preDelay); 96 | break; 97 | default: 98 | throw new NotImplementedException(); 99 | } 100 | 101 | preAction.Invoke(data); 102 | 103 | switch (type) 104 | { 105 | case AnimationType.Scaled: 106 | yield return new WaitForSeconds(postDelay); 107 | break; 108 | case AnimationType.Unscaled: 109 | yield return new WaitForSecondsRealtime(postDelay); 110 | break; 111 | default: 112 | throw new NotImplementedException(); 113 | } 114 | 115 | postAction.Invoke(data); 116 | } 117 | 118 | public static IEnumerator WaitAndRun(float delay, AnimationData data, Action onFinished) 119 | { 120 | return WaitAndRun(AnimationType.Scaled, delay, data, onFinished); 121 | } 122 | 123 | public static IEnumerator WaitAndRun(AnimationType type, float delay, AnimationData data, Action onFinished) 124 | { 125 | switch (type) 126 | { 127 | case AnimationType.Scaled: 128 | yield return new WaitForSeconds(delay); 129 | break; 130 | case AnimationType.Unscaled: 131 | yield return new WaitForSecondsRealtime(delay); 132 | break; 133 | default: 134 | throw new NotImplementedException(); 135 | } 136 | 137 | onFinished.Invoke(data); 138 | } 139 | 140 | public static IEnumerator WaitAndRun(uint frames, AnimationData data, Action onFinished) 141 | { 142 | for (var i = 0; i < frames; i++) 143 | { 144 | yield return null; 145 | } 146 | 147 | onFinished.Invoke(data); 148 | } 149 | 150 | public static IEnumerator RunAll(AnimationType type, float delay, AnimationData data, Action onFinished, params Action[] actions) 151 | { 152 | foreach (var action in actions) 153 | { 154 | action.Invoke(data); 155 | switch (type) 156 | { 157 | case AnimationType.Scaled: 158 | yield return new WaitForSeconds(delay); 159 | break; 160 | case AnimationType.Unscaled: 161 | yield return new WaitForSecondsRealtime(delay); 162 | break; 163 | default: 164 | throw new NotImplementedException(); 165 | } 166 | } 167 | 168 | onFinished?.Invoke(data); 169 | } 170 | 171 | public static IEnumerator RunAllSeconds(float delay, uint repeat, bool inverted, Action handler, AnimationData data, AnimationType type = AnimationType.Scaled, Action onFinished = null) 172 | { 173 | if (inverted) 174 | { 175 | for (var i = (int)(repeat - 1); i >= 0; i--) 176 | { 177 | handler.Invoke(i, data); 178 | yield return type switch 179 | { 180 | AnimationType.Scaled => new WaitForSeconds(delay), 181 | AnimationType.Unscaled => new WaitForSecondsRealtime(delay), 182 | _ => throw new NotImplementedException() 183 | }; 184 | } 185 | } 186 | else 187 | { 188 | for (var i = 0; i < repeat; i++) 189 | { 190 | handler.Invoke(i, data); 191 | yield return type switch 192 | { 193 | AnimationType.Scaled => new WaitForSeconds(delay), 194 | AnimationType.Unscaled => new WaitForSecondsRealtime(delay), 195 | _ => throw new NotImplementedException() 196 | }; 197 | } 198 | } 199 | 200 | onFinished?.Invoke(data); 201 | } 202 | 203 | public static IEnumerator RunAllFrames(uint frames, uint repeat, bool inverted, Action handler, AnimationData data, Action onFinished = null) 204 | { 205 | if (inverted) 206 | { 207 | for (var i = (int)(repeat - 1); i >= 0; i--) 208 | { 209 | handler.Invoke(i, data); 210 | for (var j = 0; j < frames; j++) 211 | { 212 | yield return null; 213 | } 214 | } 215 | } 216 | else 217 | { 218 | for (var i = 0; i < repeat; i++) 219 | { 220 | handler.Invoke(i, data); 221 | for (var j = 0; j < frames; j++) 222 | { 223 | yield return null; 224 | } 225 | } 226 | } 227 | 228 | onFinished?.Invoke(data); 229 | } 230 | 231 | private static float GetDelta(AnimationType type) 232 | { 233 | switch (type) 234 | { 235 | case AnimationType.Scaled: 236 | return Time.deltaTime; 237 | case AnimationType.Unscaled: 238 | return Time.unscaledDeltaTime; 239 | default: 240 | throw new NotImplementedException(); 241 | } 242 | } 243 | } 244 | } -------------------------------------------------------------------------------- /Scripts/Runtime/Utils/AnimationUtils.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: d90120ba2a28c6341a65c1d7d08252cc 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Scripts/Test.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 9fd46fca5c28662458c1a13e4976120f 3 | folderAsset: yes 4 | DefaultImporter: 5 | externalObjects: {} 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Scripts/Test/AnimationTest.cs: -------------------------------------------------------------------------------- 1 | using System.Collections; 2 | using NUnit.Framework; 3 | using UnityAnimation.Runtime.Projects.unity_animation.Scripts.Runtime.Utils; 4 | using UnityEngine; 5 | using UnityEngine.TestTools; 6 | 7 | namespace UnityAnimation.Test.Projects.unity_animation.Scripts.Test 8 | { 9 | public class AnimationTest 10 | { 11 | [UnityTest] 12 | [Timeout(2000)] 13 | public IEnumerator TestWait() 14 | { 15 | yield return new MonoBehaviourTest(); 16 | } 17 | 18 | [UnityTest] 19 | [Timeout(2000)] 20 | public IEnumerator TestAnimate() 21 | { 22 | yield return new MonoBehaviourTest(); 23 | } 24 | 25 | [UnityTest] 26 | [Timeout(500)] 27 | public IEnumerator TestImmediately() 28 | { 29 | yield return new MonoBehaviourTest(); 30 | } 31 | 32 | [UnityTest] 33 | [Timeout(5000)] 34 | public IEnumerator TestMixedWithFinisher() 35 | { 36 | yield return new MonoBehaviourTest(); 37 | } 38 | 39 | [UnityTest] 40 | [Timeout(5000)] 41 | public IEnumerator TestMixedWithData() 42 | { 43 | yield return new MonoBehaviourTest(); 44 | } 45 | 46 | private sealed class TestWaitBehavior : MonoBehaviour, IMonoBehaviourTest 47 | { 48 | public bool IsTestFinished { get; private set; } 49 | 50 | private void OnEnable() 51 | { 52 | AnimationBuilder.Create(this) 53 | .Wait(1f, () => IsTestFinished = true) 54 | .Start(); 55 | } 56 | } 57 | 58 | private sealed class TestAnimateBehavior : MonoBehaviour, IMonoBehaviourTest 59 | { 60 | public bool IsTestFinished { get; private set; } 61 | 62 | private void OnEnable() 63 | { 64 | var counter = 0f; 65 | AnimationBuilder.Create(this) 66 | .Animate(AnimationCurve.EaseInOut(0f, 0f, 1f, 1f), 1f, 67 | v => counter = v, () => IsTestFinished = counter >= 1f) 68 | .Start(); 69 | } 70 | } 71 | 72 | private sealed class TestImmediatelyBehavior : MonoBehaviour, IMonoBehaviourTest 73 | { 74 | public bool IsTestFinished { get; private set; } 75 | 76 | private void OnEnable() 77 | { 78 | AnimationBuilder.Create(this) 79 | .Immediately(() => IsTestFinished = true) 80 | .Start(); 81 | } 82 | } 83 | 84 | private sealed class TestMixedWithFinisherBehavior : MonoBehaviour, IMonoBehaviourTest 85 | { 86 | public bool IsTestFinished => _waiterFinished && _animationFinished && _finisher; 87 | 88 | private bool _waiterFinished, _animationFinished, _finisher; 89 | 90 | private void OnEnable() 91 | { 92 | var counter = 0f; 93 | AnimationBuilder.Create(this) 94 | .Wait(1f, () => _waiterFinished = true) 95 | .Animate(AnimationCurve.EaseInOut(0f, 0f, 1f, 1f), 1f, 96 | v => counter = v, () => _animationFinished = counter >= 1f) 97 | .WithFinisher(() => _finisher = true) 98 | .Start(); 99 | } 100 | } 101 | 102 | private sealed class TestMixedWithDataBehavior : MonoBehaviour, IMonoBehaviourTest 103 | { 104 | private const byte WaiterKey = 1; 105 | private const string WaiterData = "waiter"; 106 | 107 | private const byte AnimationKey = 2; 108 | private const string AnimationValue = "animation"; 109 | 110 | private const byte CounterKey = 99; 111 | 112 | public bool IsTestFinished => _waiterFinished && _animationFinished && _finisher; 113 | 114 | private bool _waiterFinished, _animationFinished, _finisher; 115 | 116 | private void OnEnable() 117 | { 118 | AnimationBuilder.Create(this) 119 | .Wait(1f, data => 120 | { 121 | data.Set(WaiterKey, WaiterData); 122 | _waiterFinished = true; 123 | }) 124 | .Animate(AnimationCurve.EaseInOut(0f, 0f, 1f, 1f), 1f, 125 | (v, data) => data.Set(CounterKey, v), 126 | data => 127 | { 128 | _animationFinished = data.Get(WaiterKey) == WaiterData && data.Get(CounterKey) >= 1f; 129 | data.Set(AnimationKey, AnimationValue); 130 | }) 131 | .WithFinisher(data => _finisher = data.Get(WaiterKey) == WaiterData && data.Get(AnimationKey) == AnimationValue) 132 | .Start(); 133 | } 134 | } 135 | } 136 | } 137 | -------------------------------------------------------------------------------- /Scripts/Test/AnimationTest.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: b521c31146bd4ff4b93dd934f6fd7ce8 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Scripts/Test/UnityAnimation.Test.asmdef: -------------------------------------------------------------------------------- 1 | { 2 | "name": "UnityAnimation.Test", 3 | "rootNamespace": "UnityAnimation.Test", 4 | "references": [ 5 | "UnityEngine.TestRunner", 6 | "UnityEditor.TestRunner", 7 | "UnityAnimation.Runtime" 8 | ], 9 | "includePlatforms": [], 10 | "excludePlatforms": [], 11 | "allowUnsafeCode": false, 12 | "overrideReferences": true, 13 | "precompiledReferences": [ 14 | "nunit.framework.dll" 15 | ], 16 | "autoReferenced": false, 17 | "defineConstraints": [ 18 | "UNITY_INCLUDE_TESTS" 19 | ], 20 | "versionDefines": [], 21 | "noEngineReferences": false 22 | } -------------------------------------------------------------------------------- /Scripts/Test/UnityAnimation.Test.asmdef.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 89bf0c28bacc07c499a0b878af6ea44d 3 | AssemblyDefinitionImporter: 4 | externalObjects: {} 5 | userData: 6 | assetBundleName: 7 | assetBundleVariant: 8 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "org.pcsoft.animation", 3 | "version": "1.3.2", 4 | "displayName": "Animation Extension", 5 | "description": "Provide a builder for animations based on Coroutines", 6 | "unity": "2021.3", 7 | "keywords": [ 8 | "animation", 9 | "tooling", 10 | "extension", 11 | "builder" 12 | ], 13 | "dependencies": { 14 | "org.pcsoft.base": "2.0.0-EA.2" 15 | }, 16 | "author": { 17 | "name": "Pfeiffer C Soft", 18 | "email": "kl3in3rhack3r@gmail.com", 19 | "url": "https://github.com/KleinerHacker/unity-animation" 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /package.json.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 34c814c4787958d41a2c2eb550ffbfed 3 | TextScriptImporter: 4 | externalObjects: {} 5 | userData: 6 | assetBundleName: 7 | assetBundleVariant: 8 | --------------------------------------------------------------------------------