├── .gitignore ├── Assets ├── EasyAnimation.meta └── EasyAnimation │ ├── README.txt │ ├── README.txt.meta │ ├── Scripts.meta │ └── Scripts │ ├── EaseAction.cs │ ├── EaseAction.cs.meta │ ├── EaseAinmationDrive.cs │ ├── EaseAinmationDrive.cs.meta │ ├── EasyAnimationTemplateMethod.cs │ ├── EasyAnimationTemplateMethod.cs.meta │ ├── Moulds.meta │ └── Moulds │ ├── EasyAnimation_Enlarge.cs │ ├── EasyAnimation_Enlarge.cs.meta │ ├── EasyAnimation_Fade.cs │ ├── EasyAnimation_Fade.cs.meta │ ├── EasyAnimation_Move.cs │ ├── EasyAnimation_Move.cs.meta │ ├── EasyAnimation_Rotate.cs │ └── EasyAnimation_Rotate.cs.meta ├── ProjectSettings ├── AudioManager.asset ├── ClusterInputManager.asset ├── DynamicsManager.asset ├── EditorBuildSettings.asset ├── EditorSettings.asset ├── GraphicsSettings.asset ├── InputManager.asset ├── NavMeshAreas.asset ├── NetworkManager.asset ├── Physics2DSettings.asset ├── ProjectSettings.asset ├── ProjectVersion.txt ├── QualitySettings.asset ├── TagManager.asset ├── TimeManager.asset └── UnityConnectSettings.asset ├── README.md ├── _config.yml └── unitypackages ├── EasyAnimation 1.4.unitypackage └── unitypackage.txt /.gitignore: -------------------------------------------------------------------------------- 1 | /[Ll]ibrary/ 2 | /[Tt]emp/ 3 | /[Oo]bj/ 4 | /[Bb]uild/ 5 | /[Bb]uilds/ 6 | /Assets/AssetStoreTools* 7 | 8 | # Visual Studio 2015 cache directory 9 | /.vs/ 10 | 11 | # Autogenerated VS/MD/Consulo solution and project files 12 | ExportedObj/ 13 | .consulo/ 14 | *.csproj 15 | *.unityproj 16 | *.sln 17 | *.suo 18 | *.tmp 19 | *.user 20 | *.userprefs 21 | *.pidb 22 | *.booproj 23 | *.svd 24 | *.pdb 25 | 26 | # Unity3D generated meta files 27 | *.pidb.meta 28 | 29 | # Unity3D Generated File On Crash Reports 30 | sysinfo.txt 31 | 32 | # Builds 33 | *.apk 34 | *.unitypackage 35 | -------------------------------------------------------------------------------- /Assets/EasyAnimation.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 43dcea87c8d51bf49b3a5e287e5db998 3 | folderAsset: yes 4 | timeCreated: 1513736688 5 | licenseType: Pro 6 | DefaultImporter: 7 | userData: 8 | assetBundleName: 9 | assetBundleVariant: 10 | -------------------------------------------------------------------------------- /Assets/EasyAnimation/README.txt: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/foldcc/EasyAnimation/0ee2246413faea3a329ae2d7410a113282093d2d/Assets/EasyAnimation/README.txt -------------------------------------------------------------------------------- /Assets/EasyAnimation/README.txt.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 79e48d07a51e0ad4098784b6dd844384 3 | timeCreated: 1534155314 4 | licenseType: Pro 5 | TextScriptImporter: 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Assets/EasyAnimation/Scripts.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 65477e5972d5a9f438572a84a89b830c 3 | folderAsset: yes 4 | timeCreated: 1514339517 5 | licenseType: Pro 6 | DefaultImporter: 7 | userData: 8 | assetBundleName: 9 | assetBundleVariant: 10 | -------------------------------------------------------------------------------- /Assets/EasyAnimation/Scripts/EaseAction.cs: -------------------------------------------------------------------------------- 1 | using System.Collections; 2 | using System.Collections.Generic; 3 | using UnityEngine; 4 | 5 | namespace EasyAnimation { 6 | 7 | public enum EaseActionMethod 8 | { 9 | Linear, 10 | 11 | Spring, 12 | 13 | InQuad, 14 | OutQuad, 15 | InOutQuad, 16 | 17 | InCubic, 18 | OutCubic, 19 | InOutCubic, 20 | 21 | InQuart, 22 | OutQuart, 23 | InOutQuart, 24 | 25 | InQuint, 26 | OutQuint, 27 | InOutQuint, 28 | 29 | InSine, 30 | OutSine, 31 | InOutSine, 32 | 33 | InExpo, 34 | OutExpo, 35 | InOutExpo, 36 | 37 | InCirc, 38 | OutCirc, 39 | InOutCirc, 40 | 41 | InBounce, 42 | OutBounce, 43 | InOutBounce, 44 | 45 | InBack, 46 | OutBack, 47 | InOutBack, 48 | 49 | InElastic, 50 | OutElastic, 51 | InOutElastic, 52 | } 53 | /// 54 | /// 缓动函数集 55 | /// 56 | public static class EaseAction 57 | { 58 | 59 | public static float GetEaseAction(EaseActionMethod ease_type , float x) { 60 | switch (ease_type) { 61 | 62 | case EaseActionMethod.InBack: 63 | return InBack(0, 1, x); 64 | case EaseActionMethod.InBounce: 65 | return InBounce(0, 1, x); 66 | case EaseActionMethod.InCirc: 67 | return InCirc(0, 1, x); 68 | case EaseActionMethod.InCubic: 69 | return InCubic(0, 1, x); 70 | case EaseActionMethod.InElastic: 71 | return InElastic(0, 1, x); 72 | case EaseActionMethod.InExpo: 73 | return InExpo(0, 1, x); 74 | case EaseActionMethod.InOutBack: 75 | return InOutBack(0, 1, x); 76 | case EaseActionMethod.InOutBounce: 77 | return InOutBounce(0, 1, x); 78 | case EaseActionMethod.InOutCirc: 79 | return InOutCirc(0, 1, x); 80 | case EaseActionMethod.InOutCubic: 81 | return InOutCubic(0, 1, x); 82 | case EaseActionMethod.InOutElastic: 83 | return InOutElastic(0, 1, x); 84 | case EaseActionMethod.InOutExpo: 85 | return InOutExpo(0, 1, x); 86 | case EaseActionMethod.InOutQuad: 87 | return InOutQuad(0, 1, x); 88 | case EaseActionMethod.InOutQuart: 89 | return InOutQuart(0, 1, x); 90 | case EaseActionMethod.InOutQuint: 91 | return InOutQuint(0, 1, x); 92 | case EaseActionMethod.InOutSine: 93 | return InOutSine(0, 1, x); 94 | case EaseActionMethod.InQuad: 95 | return InQuad(0, 1, x); 96 | case EaseActionMethod.InQuart: 97 | return InQuart(0, 1, x); 98 | case EaseActionMethod.InQuint: 99 | return InQuint(0, 1, x); 100 | case EaseActionMethod.InSine: 101 | return InSine(0, 1, x); 102 | case EaseActionMethod.Linear: 103 | return Linear(0, 1, x); 104 | case EaseActionMethod.OutBack: 105 | return OutBack(0, 1, x); 106 | case EaseActionMethod.OutBounce: 107 | return OutBounce(0, 1, x); 108 | case EaseActionMethod.OutCirc: 109 | return OutCirc(0, 1, x); 110 | case EaseActionMethod.OutCubic: 111 | return OutCubic(0, 1, x); 112 | case EaseActionMethod.OutElastic: 113 | return OutElastic(0, 1, x); 114 | case EaseActionMethod.OutExpo: 115 | return OutExpo(0, 1, x); 116 | case EaseActionMethod.OutQuad: 117 | return OutQuad(0, 1, x); 118 | case EaseActionMethod.OutQuart: 119 | return OutQuart(0, 1, x); 120 | case EaseActionMethod.OutQuint: 121 | return OutQuint(0, 1, x); 122 | case EaseActionMethod.OutSine: 123 | return OutSine(0, 1, x); 124 | case EaseActionMethod.Spring: 125 | return Spring(0, 1, x); 126 | default: 127 | return x; 128 | } 129 | } 130 | 131 | 132 | 133 | //2018-8-13 新增 134 | 135 | public static float Linear(float start, float end, float value) 136 | { 137 | return Mathf.Lerp(start, end, value); 138 | } 139 | 140 | public static float Spring(float start, float end, float value) 141 | { 142 | value = Mathf.Clamp01(value); 143 | value = (Mathf.Sin(value * Mathf.PI * (0.2f + 2.5f * value * value * value)) * Mathf.Pow(1f - value, 2.2f) + value) * (1f + (1.2f * (1f - value))); 144 | return start + (end - start) * value; 145 | } 146 | 147 | public static float InQuad(float start, float end, float value) 148 | { 149 | end -= start; 150 | return end * value * value + start; 151 | } 152 | 153 | public static float OutQuad(float start, float end, float value) 154 | { 155 | end -= start; 156 | return -end * value * (value - 2) + start; 157 | } 158 | 159 | public static float InOutQuad(float start, float end, float value) 160 | { 161 | value /= .5f; 162 | end -= start; 163 | if (value < 1) return end / 2 * value * value + start; 164 | value--; 165 | return -end / 2 * (value * (value - 2) - 1) + start; 166 | } 167 | 168 | public static float InCubic(float start, float end, float value) 169 | { 170 | end -= start; 171 | return end * value * value * value + start; 172 | } 173 | 174 | public static float OutCubic(float start, float end, float value) 175 | { 176 | value--; 177 | end -= start; 178 | return end * (value * value * value + 1) + start; 179 | } 180 | 181 | public static float InOutCubic(float start, float end, float value) 182 | { 183 | value /= .5f; 184 | end -= start; 185 | if (value < 1) return end / 2 * value * value * value + start; 186 | value -= 2; 187 | return end / 2 * (value * value * value + 2) + start; 188 | } 189 | 190 | public static float InQuart(float start, float end, float value) 191 | { 192 | end -= start; 193 | return end * value * value * value * value + start; 194 | } 195 | 196 | public static float OutQuart(float start, float end, float value) 197 | { 198 | value--; 199 | end -= start; 200 | return -end * (value * value * value * value - 1) + start; 201 | } 202 | 203 | public static float InOutQuart(float start, float end, float value) 204 | { 205 | value /= .5f; 206 | end -= start; 207 | if (value < 1) return end / 2 * value * value * value * value + start; 208 | value -= 2; 209 | return -end / 2 * (value * value * value * value - 2) + start; 210 | } 211 | 212 | public static float InQuint(float start, float end, float value) 213 | { 214 | end -= start; 215 | return end * value * value * value * value * value + start; 216 | } 217 | 218 | public static float OutQuint(float start, float end, float value) 219 | { 220 | value--; 221 | end -= start; 222 | return end * (value * value * value * value * value + 1) + start; 223 | } 224 | 225 | public static float InOutQuint(float start, float end, float value) 226 | { 227 | value /= .5f; 228 | end -= start; 229 | if (value < 1) return end / 2 * value * value * value * value * value + start; 230 | value -= 2; 231 | return end / 2 * (value * value * value * value * value + 2) + start; 232 | } 233 | 234 | public static float InSine(float start, float end, float value) 235 | { 236 | end -= start; 237 | return -end * Mathf.Cos(value / 1 * (Mathf.PI / 2)) + end + start; 238 | } 239 | 240 | public static float OutSine(float start, float end, float value) 241 | { 242 | end -= start; 243 | return end * Mathf.Sin(value / 1 * (Mathf.PI / 2)) + start; 244 | } 245 | 246 | public static float InOutSine(float start, float end, float value) 247 | { 248 | end -= start; 249 | return -end / 2 * (Mathf.Cos(Mathf.PI * value / 1) - 1) + start; 250 | } 251 | 252 | public static float InExpo(float start, float end, float value) 253 | { 254 | end -= start; 255 | return end * Mathf.Pow(2, 10 * (value / 1 - 1)) + start; 256 | } 257 | 258 | public static float OutExpo(float start, float end, float value) 259 | { 260 | end -= start; 261 | return end * (-Mathf.Pow(2, -10 * value / 1) + 1) + start; 262 | } 263 | 264 | public static float InOutExpo(float start, float end, float value) 265 | { 266 | value /= .5f; 267 | end -= start; 268 | if (value < 1) return end / 2 * Mathf.Pow(2, 10 * (value - 1)) + start; 269 | value--; 270 | return end / 2 * (-Mathf.Pow(2, -10 * value) + 2) + start; 271 | } 272 | 273 | public static float InCirc(float start, float end, float value) 274 | { 275 | end -= start; 276 | return -end * (Mathf.Sqrt(1 - value * value) - 1) + start; 277 | } 278 | 279 | public static float OutCirc(float start, float end, float value) 280 | { 281 | value--; 282 | end -= start; 283 | return end * Mathf.Sqrt(1 - value * value) + start; 284 | } 285 | 286 | public static float InOutCirc(float start, float end, float value) 287 | { 288 | value /= .5f; 289 | end -= start; 290 | if (value < 1) return -end / 2 * (Mathf.Sqrt(1 - value * value) - 1) + start; 291 | value -= 2; 292 | return end / 2 * (Mathf.Sqrt(1 - value * value) + 1) + start; 293 | } 294 | 295 | public static float InBounce(float start, float end, float value) 296 | { 297 | end -= start; 298 | float d = 1f; 299 | return end - OutBounce(0, end, d - value) + start; 300 | } 301 | 302 | public static float OutBounce(float start, float end, float value) 303 | { 304 | value /= 1f; 305 | end -= start; 306 | if (value < (1 / 2.75f)) 307 | { 308 | return end * (7.5625f * value * value) + start; 309 | } 310 | else if (value < (2 / 2.75f)) 311 | { 312 | value -= (1.5f / 2.75f); 313 | return end * (7.5625f * (value) * value + .75f) + start; 314 | } 315 | else if (value < (2.5 / 2.75)) 316 | { 317 | value -= (2.25f / 2.75f); 318 | return end * (7.5625f * (value) * value + .9375f) + start; 319 | } 320 | else 321 | { 322 | value -= (2.625f / 2.75f); 323 | return end * (7.5625f * (value) * value + .984375f) + start; 324 | } 325 | } 326 | 327 | public static float InOutBounce(float start, float end, float value) 328 | { 329 | end -= start; 330 | float d = 1f; 331 | if (value < d / 2) return InBounce(0, end, value * 2) * 0.5f + start; 332 | else return OutBounce(0, end, value * 2 - d) * 0.5f + end * 0.5f + start; 333 | } 334 | 335 | public static float InBack(float start, float end, float value) 336 | { 337 | end -= start; 338 | value /= 1; 339 | float s = 1.70158f; 340 | return end * (value) * value * ((s + 1) * value - s) + start; 341 | } 342 | 343 | public static float OutBack(float start, float end, float value) 344 | { 345 | float s = 1.70158f; 346 | end -= start; 347 | value = (value / 1) - 1; 348 | return end * ((value) * value * ((s + 1) * value + s) + 1) + start; 349 | } 350 | 351 | public static float InOutBack(float start, float end, float value) 352 | { 353 | float s = 1.70158f; 354 | end -= start; 355 | value /= .5f; 356 | if ((value) < 1) 357 | { 358 | s *= (1.525f); 359 | return end / 2 * (value * value * (((s) + 1) * value - s)) + start; 360 | } 361 | value -= 2; 362 | s *= (1.525f); 363 | return end / 2 * ((value) * value * (((s) + 1) * value + s) + 2) + start; 364 | } 365 | 366 | public static float InElastic(float start, float end, float value) 367 | { 368 | end -= start; 369 | 370 | float d = 1f; 371 | float p = d * .3f; 372 | float s = 0; 373 | float a = 0; 374 | 375 | if (value == 0) return start; 376 | 377 | if ((value /= d) == 1) return start + end; 378 | 379 | if (a == 0f || a < Mathf.Abs(end)) 380 | { 381 | a = end; 382 | s = p / 4; 383 | } 384 | else 385 | { 386 | s = p / (2 * Mathf.PI) * Mathf.Asin(end / a); 387 | } 388 | 389 | return -(a * Mathf.Pow(2, 10 * (value -= 1)) * Mathf.Sin((value * d - s) * (2 * Mathf.PI) / p)) + start; 390 | } 391 | 392 | public static float OutElastic(float start, float end, float value) 393 | { 394 | end -= start; 395 | 396 | float d = 1f; 397 | float p = d * .3f; 398 | float s = 0; 399 | float a = 0; 400 | 401 | if (value == 0) return start; 402 | 403 | if ((value /= d) == 1) return start + end; 404 | 405 | if (a == 0f || a < Mathf.Abs(end)) 406 | { 407 | a = end; 408 | s = p / 4; 409 | } 410 | else 411 | { 412 | s = p / (2 * Mathf.PI) * Mathf.Asin(end / a); 413 | } 414 | 415 | return (a * Mathf.Pow(2, -10 * value) * Mathf.Sin((value * d - s) * (2 * Mathf.PI) / p) + end + start); 416 | } 417 | 418 | public static float InOutElastic(float start, float end, float value) 419 | { 420 | end -= start; 421 | 422 | float d = 1f; 423 | float p = d * .3f; 424 | float s = 0; 425 | float a = 0; 426 | 427 | if (value == 0) return start; 428 | 429 | if ((value /= d / 2) == 2) return start + end; 430 | 431 | if (a == 0f || a < Mathf.Abs(end)) 432 | { 433 | a = end; 434 | s = p / 4; 435 | } 436 | else 437 | { 438 | s = p / (2 * Mathf.PI) * Mathf.Asin(end / a); 439 | } 440 | 441 | if (value < 1) return -0.5f * (a * Mathf.Pow(2, 10 * (value -= 1)) * Mathf.Sin((value * d - s) * (2 * Mathf.PI) / p)) + start; 442 | return a * Mathf.Pow(2, -10 * (value -= 1)) * Mathf.Sin((value * d - s) * (2 * Mathf.PI) / p) * 0.5f + end + start; 443 | } 444 | 445 | static float Punch(float amplitude, float value) 446 | { 447 | float s = 9; 448 | if (value == 0) 449 | { 450 | return 0; 451 | } 452 | if (value == 1) 453 | { 454 | return 0; 455 | } 456 | float period = 1 * 0.3f; 457 | s = period / (2 * Mathf.PI) * Mathf.Asin(0); 458 | return (amplitude * Mathf.Pow(2, -10 * value) * Mathf.Sin((value * 1 - s) * (2 * Mathf.PI) / period)); 459 | } 460 | 461 | static float Clerp(float start, float end, float value) 462 | { 463 | float min = 0.0f; 464 | float max = 360.0f; 465 | float half = Mathf.Abs((max - min) / 2.0f); 466 | float retval = 0.0f; 467 | float diff = 0.0f; 468 | if ((end - start) < -half) 469 | { 470 | diff = ((max - start) + end) * value; 471 | retval = start + diff; 472 | } 473 | else if ((end - start) > half) 474 | { 475 | diff = -((max - end) + start) * value; 476 | retval = start + diff; 477 | } 478 | else retval = start + (end - start) * value; 479 | return retval; 480 | } 481 | 482 | } 483 | } -------------------------------------------------------------------------------- /Assets/EasyAnimation/Scripts/EaseAction.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 83a94716b4e36aa4f80d423c1da28403 3 | timeCreated: 1514426245 4 | licenseType: Pro 5 | MonoImporter: 6 | serializedVersion: 2 7 | defaultReferences: [] 8 | executionOrder: 0 9 | icon: {instanceID: 0} 10 | userData: 11 | assetBundleName: 12 | assetBundleVariant: 13 | -------------------------------------------------------------------------------- /Assets/EasyAnimation/Scripts/EaseAinmationDrive.cs: -------------------------------------------------------------------------------- 1 | using System.Collections; 2 | using System.Collections.Generic; 3 | using UnityEngine; 4 | 5 | namespace EasyAnimation 6 | { 7 | public class EaseAinmationDrive 8 | { 9 | public float maxTime; 10 | public float startNum; 11 | public float overNum; 12 | public Vector3 startVector; 13 | public Vector3 overVector; 14 | public EaseActionMethod easeType; 15 | 16 | /// 17 | /// 初始化动画事件 18 | /// 19 | /// 最大时间 20 | /// 初始倍率 21 | /// 结束倍率 22 | /// 缓动函数类型 23 | public EaseAinmationDrive(float maxTime, float startNum, float overNum, EaseActionMethod easeType) { 24 | this.maxTime = maxTime; 25 | this.overNum = overNum; 26 | this.startNum = startNum; 27 | this.easeType = easeType; 28 | startVector = Vector3.one * startNum; 29 | overVector = Vector3.one * overNum; 30 | } 31 | 32 | public EaseAinmationDrive(float maxTime, Vector3 startPos, Vector3 overPos, EaseActionMethod easeType) 33 | { 34 | this.maxTime = maxTime; 35 | this.easeType = easeType; 36 | startVector = startPos; 37 | overVector = overPos; 38 | } 39 | /// 40 | /// 返回一个[0-1]的进度 41 | /// 42 | /// [0-maxTime]的值 43 | /// 44 | public float getProgress(float time) { 45 | if (time < 0) 46 | time = 0; 47 | else if (time > maxTime) 48 | time = maxTime; 49 | 50 | return EaseAction.GetEaseAction(easeType, time / maxTime * (overNum - startNum) + startNum); 51 | } 52 | 53 | /// 54 | /// 返回由3个进度值组成的Vector进度值 55 | /// 56 | /// [0-maxTime]的值 57 | /// 58 | public Vector3 getProgressForVector3(float time) { 59 | if (time < 0) 60 | time = 0; 61 | else if (time > maxTime) 62 | time = maxTime; 63 | return new Vector3( 64 | EaseAction.GetEaseAction(easeType, time / maxTime * (overVector.x - startVector.x) + startVector.x) , 65 | EaseAction.GetEaseAction(easeType, time / maxTime * (overVector.y - startVector.y) + startVector.y) , 66 | EaseAction.GetEaseAction(easeType, time / maxTime * (overVector.z - startVector.z)) + startVector.z); 67 | } 68 | 69 | /// 70 | /// 返回当前进度下对应的一个Vector数值而非进度值 71 | /// 72 | /// [0-maxTime]的值 73 | /// 74 | public Vector3 GetValueForVector3(float time) 75 | { 76 | if (time < 0) 77 | time = 0; 78 | else if (time > maxTime) 79 | time = maxTime; 80 | float offset = EaseAction.GetEaseAction(easeType, time / maxTime); 81 | return (startVector + (overVector - startVector) * offset); 82 | } 83 | } 84 | } 85 | 86 | 87 | -------------------------------------------------------------------------------- /Assets/EasyAnimation/Scripts/EaseAinmationDrive.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 2f8ee24be7f5dfc4ea7bb4a83bb3f754 3 | timeCreated: 1514429827 4 | licenseType: Pro 5 | MonoImporter: 6 | serializedVersion: 2 7 | defaultReferences: [] 8 | executionOrder: 0 9 | icon: {instanceID: 0} 10 | userData: 11 | assetBundleName: 12 | assetBundleVariant: 13 | -------------------------------------------------------------------------------- /Assets/EasyAnimation/Scripts/EasyAnimationTemplateMethod.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections; 3 | using System.Collections.Generic; 4 | using UnityEngine; 5 | 6 | 7 | namespace EasyAnimation { 8 | 9 | public enum PlayActionType { 10 | On_Start, 11 | On_End 12 | } 13 | 14 | 15 | /// 16 | /// 动画播放模板 17 | /// 18 | abstract public class EasyAnimationTemplateMethod : MonoBehaviour 19 | { 20 | [Header("自动播放")] 21 | public bool isAutoPlay = false; 22 | 23 | [Header("反向播放")] 24 | public bool isReverse = false; 25 | 26 | [Header("往返播放")] 27 | public bool isBack = false; 28 | 29 | [Header("循环播放")] 30 | public bool isLoop = false; 31 | 32 | [Header("缓动函数类型")] 33 | public EaseActionMethod easetype; 34 | 35 | [Header("动画时长"), Range(0.01f, 4)] 36 | public float animationTime = 0.25f; 37 | 38 | [Header("当前时间轴(仅用于观察动画播放情况)"), Range(0, 4)] 39 | public float animationNowTime = 0; 40 | 41 | /// 42 | /// 缓动函数驱动器 43 | /// 44 | protected EaseAinmationDrive ead; 45 | 46 | protected Vector3 initPostion; 47 | 48 | protected Quaternion initRotation; 49 | 50 | protected Vector3 initScale; 51 | 52 | private float playSpeed = 1; 53 | /// 54 | /// 判断是否初始化 55 | /// 56 | private bool isInit = false; 57 | /// 58 | /// 用于判断是否正在播放中,防止同时播放多次 59 | /// 60 | private bool isPlaying = false; 61 | 62 | void OnEnable() { 63 | 64 | if (!isInit) 65 | { 66 | initAction(); 67 | Easy_Animation_Awake(); 68 | isInit = true; 69 | } 70 | if (isAutoPlay) 71 | { 72 | rPlay(); 73 | } 74 | } 75 | 76 | void OnDisable() { 77 | if (isPlaying) { 78 | StopCoroutine(animationDrive()); 79 | play_end(); 80 | } 81 | } 82 | 83 | /// 84 | /// 初始化方法 85 | /// 86 | protected virtual void Easy_Animation_Awake() { } 87 | 88 | /// 89 | /// 动画播放前触发事件 90 | /// 91 | private Action start_Actions; 92 | /// 93 | /// 动画播放结束触发事件 94 | /// 95 | private Action end_Actions; 96 | 97 | /// 98 | /// 播放动画模板,0.02s/执行一次,返回false时 执行跳出 99 | /// 100 | /// 当返回值为true 表示播放进行中 false表示播放结束 101 | protected virtual bool PrimitiveOperation_UpDate(float time) { 102 | return false; 103 | } 104 | /// 105 | /// 当每个周期播放时初始化执行一次 106 | /// 107 | protected virtual void PrimitiveOperation_Start() { 108 | 109 | } 110 | /// 111 | /// 复位 112 | /// 113 | public virtual void Rese() { 114 | transform.localScale = initScale; 115 | transform.localRotation = initRotation; 116 | transform.localPosition = initPostion; 117 | } 118 | 119 | /// 120 | /// 动画驱动器 121 | /// 122 | /// 123 | private IEnumerator animationDrive() { 124 | do 125 | { 126 | Rese(); 127 | PrimitiveOperation_Start(); 128 | animationNowTime = 0; 129 | playSpeed = 1; 130 | PrimitiveOperation_UpDate(0); 131 | while (PrimitiveOperation_UpDate(getPlayValue(animationNowTime / animationTime))) { 132 | yield return 0; 133 | animationNowTime += Time.deltaTime * playSpeed; 134 | if (isBack && gameObject.activeSelf) 135 | { 136 | if (playSpeed > 0) 137 | { 138 | if (animationNowTime >= animationTime) 139 | { 140 | animationNowTime = animationTime - 0.01f; 141 | playSpeed = -1; 142 | } 143 | } 144 | else if (playSpeed == -1) 145 | { 146 | if (animationNowTime <= 0) 147 | { 148 | animationNowTime = 0f; 149 | break; 150 | } 151 | } 152 | } 153 | else 154 | { 155 | if (playSpeed <= 0) 156 | { 157 | playSpeed = 1; 158 | } 159 | } 160 | 161 | if (animationNowTime >= animationTime) 162 | { 163 | break; 164 | } 165 | } 166 | yield return 0; 167 | } while (isLoop); 168 | play_end(); 169 | yield return 0; 170 | } 171 | 172 | private float getPlayValue(float value , float max = 1) { 173 | if (isReverse) 174 | { 175 | return max - value; 176 | } 177 | else { 178 | return value; 179 | } 180 | } 181 | 182 | /// 183 | /// 钩子方法用于确定是否播放,可重写,默认播放 184 | /// 185 | /// 186 | protected bool isPlay() 187 | { 188 | return true; 189 | } 190 | 191 | /// 192 | /// 动画播放开始 193 | /// 194 | private void play_start() 195 | { 196 | isPlaying = true; 197 | if(start_Actions != null) 198 | start_Actions(); 199 | } 200 | 201 | /// 202 | /// 动画播放结束 203 | /// 204 | protected void play_end() 205 | { 206 | if (isBack) 207 | { 208 | animationNowTime = getPlayValue(0 , animationTime); 209 | PrimitiveOperation_UpDate(getPlayValue(0)); 210 | } 211 | else { 212 | animationNowTime = getPlayValue(animationTime , animationTime); 213 | PrimitiveOperation_UpDate(getPlayValue(1)); 214 | } 215 | isPlaying = false; 216 | if(end_Actions != null) 217 | end_Actions(); 218 | } 219 | 220 | /// 221 | /// 模板方法模板 222 | /// 223 | private void TemplateMethod() 224 | { 225 | play_start(); 226 | StartCoroutine(animationDrive()); 227 | } 228 | 229 | /// 230 | /// 开始播放动画(不进行复位) 231 | /// 232 | public void Play() { 233 | if (isPlay() && !isPlaying && gameObject.activeSelf) { 234 | TemplateMethod(); 235 | } 236 | } 237 | 238 | /// 239 | /// 先进行重置复位在开始播放动画 240 | /// 241 | public void rPlay() 242 | { 243 | Rese(); 244 | if (isPlay() && !isPlaying && gameObject.activeSelf) 245 | { 246 | TemplateMethod(); 247 | } 248 | } 249 | 250 | /// 251 | /// 结束动画播放 252 | /// 253 | public void Stop() { 254 | if (isPlaying) 255 | { 256 | StopCoroutine(animationDrive()); 257 | play_end(); 258 | } 259 | } 260 | 261 | /// 262 | /// 刷新原始的重置位置信息 263 | /// 264 | public void initAction() { 265 | initPostion = transform.localPosition; 266 | initRotation = transform.localRotation; 267 | initScale = transform.localScale; 268 | } 269 | 270 | /// 271 | /// 添加事件 272 | /// 273 | /// Active 274 | /// 动画播放类型 275 | public void addListener(Action e , PlayActionType type) { 276 | if (type == PlayActionType.On_Start) 277 | { 278 | start_Actions += e; 279 | } 280 | else 281 | { 282 | end_Actions += e; 283 | } 284 | } 285 | /// 286 | /// 删除事件 287 | /// 288 | /// 289 | /// 290 | public void removeListener(Action e, PlayActionType type) { 291 | 292 | if (type == PlayActionType.On_Start) 293 | { 294 | if (start_Actions != null) 295 | start_Actions -= e; 296 | } 297 | else 298 | { 299 | if (end_Actions != null) 300 | end_Actions -= e; 301 | } 302 | } 303 | } 304 | } 305 | -------------------------------------------------------------------------------- /Assets/EasyAnimation/Scripts/EasyAnimationTemplateMethod.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: b414d78c172313b4ba17021a3dafa339 3 | timeCreated: 1514339631 4 | licenseType: Pro 5 | MonoImporter: 6 | serializedVersion: 2 7 | defaultReferences: [] 8 | executionOrder: 0 9 | icon: {instanceID: 0} 10 | userData: 11 | assetBundleName: 12 | assetBundleVariant: 13 | -------------------------------------------------------------------------------- /Assets/EasyAnimation/Scripts/Moulds.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 2baf7276b9802e147a55a5ccef10a867 3 | folderAsset: yes 4 | timeCreated: 1514344768 5 | licenseType: Pro 6 | DefaultImporter: 7 | userData: 8 | assetBundleName: 9 | assetBundleVariant: 10 | -------------------------------------------------------------------------------- /Assets/EasyAnimation/Scripts/Moulds/EasyAnimation_Enlarge.cs: -------------------------------------------------------------------------------- 1 | using UnityEngine; 2 | 3 | namespace EasyAnimation { 4 | 5 | [AddComponentMenu("EasyAnimation/缩放效果")] 6 | public class EasyAnimation_Enlarge : EasyAnimationTemplateMethod 7 | { 8 | 9 | Vector3 rectSize = Vector3.one; 10 | 11 | protected override void Easy_Animation_Awake() 12 | { 13 | rectSize = transform.localScale; 14 | } 15 | 16 | protected override void PrimitiveOperation_Start() 17 | { 18 | ead = new EaseAinmationDrive(1, 0, 1, easetype); 19 | } 20 | 21 | protected override bool PrimitiveOperation_UpDate(float time) 22 | { 23 | transform.localScale = rectSize * ead.getProgress(time) ; 24 | return true; 25 | } 26 | 27 | public override void Rese() 28 | { 29 | transform.localScale = initScale; 30 | } 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /Assets/EasyAnimation/Scripts/Moulds/EasyAnimation_Enlarge.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: fd1d8fbd90bcf674ea1012dc9e003b0b 3 | timeCreated: 1514361988 4 | licenseType: Pro 5 | MonoImporter: 6 | serializedVersion: 2 7 | defaultReferences: [] 8 | executionOrder: 0 9 | icon: {instanceID: 0} 10 | userData: 11 | assetBundleName: 12 | assetBundleVariant: 13 | -------------------------------------------------------------------------------- /Assets/EasyAnimation/Scripts/Moulds/EasyAnimation_Fade.cs: -------------------------------------------------------------------------------- 1 | using System.Collections; 2 | using System.Collections.Generic; 3 | using UnityEngine; 4 | using UnityEngine.UI; 5 | 6 | namespace EasyAnimation 7 | { 8 | [AddComponentMenu("EasyAnimation/透明渐变效果")] 9 | public class EasyAnimation_Fade : EasyAnimationTemplateMethod 10 | { 11 | [Header("起始透明度"), Range(0, 1)] 12 | public float startAlpha; 13 | 14 | [Header("结束透明度"), Range(0, 1)] 15 | public float endAlpha; 16 | 17 | private MaskableGraphic image; 18 | 19 | private bool isImage = false; 20 | 21 | protected override void Easy_Animation_Awake() 22 | { 23 | 24 | image = GetComponent(); 25 | if (image != null) 26 | { 27 | image.color = new Color(image.color.r, image.color.g, image.color.b, startAlpha); 28 | isImage = true; 29 | } 30 | 31 | } 32 | 33 | protected override void PrimitiveOperation_Start() 34 | { 35 | ead = new EaseAinmationDrive(1, 0, 1, easetype); 36 | } 37 | 38 | protected override bool PrimitiveOperation_UpDate(float time) 39 | { 40 | if (isImage) 41 | { 42 | float i = ead.getProgress(time); 43 | float s = startAlpha + (endAlpha - startAlpha) * i; 44 | image.color = new Color(image.color.r, image.color.g, image.color.b, s); 45 | return true; 46 | } 47 | else 48 | { 49 | return false; 50 | } 51 | } 52 | 53 | public override void Rese() 54 | { 55 | if (isImage) 56 | { 57 | image.color = new Color(image.color.r, image.color.g, image.color.b, startAlpha); 58 | } 59 | } 60 | } 61 | } -------------------------------------------------------------------------------- /Assets/EasyAnimation/Scripts/Moulds/EasyAnimation_Fade.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 3b5d7ce3089d3264cbb63214e7723b29 3 | timeCreated: 1515744148 4 | licenseType: Pro 5 | MonoImporter: 6 | serializedVersion: 2 7 | defaultReferences: [] 8 | executionOrder: 0 9 | icon: {instanceID: 0} 10 | userData: 11 | assetBundleName: 12 | assetBundleVariant: 13 | -------------------------------------------------------------------------------- /Assets/EasyAnimation/Scripts/Moulds/EasyAnimation_Move.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections; 3 | using System.Collections.Generic; 4 | using UnityEngine; 5 | 6 | namespace EasyAnimation { 7 | 8 | [AddComponentMenu("EasyAnimation/移动效果")] 9 | public class EasyAnimation_Move : EasyAnimationTemplateMethod 10 | { 11 | [Header("移动增量")] 12 | public Vector3 vector_To; 13 | 14 | private Vector3 nowPos; 15 | 16 | protected override void PrimitiveOperation_Start() 17 | { 18 | ead = new EaseAinmationDrive(1, 0, 1, easetype); 19 | nowPos = transform.localPosition; 20 | } 21 | 22 | protected override bool PrimitiveOperation_UpDate(float time) 23 | { 24 | float i = ead.getProgress(time); 25 | transform.localPosition = vector_To*i + nowPos; 26 | return true; 27 | } 28 | 29 | public override void Rese() 30 | { 31 | transform.localPosition = initPostion; 32 | } 33 | } 34 | } -------------------------------------------------------------------------------- /Assets/EasyAnimation/Scripts/Moulds/EasyAnimation_Move.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: ac74be0f6b7b50c4e8627f5ff6e721a8 3 | timeCreated: 1514344830 4 | licenseType: Pro 5 | MonoImporter: 6 | serializedVersion: 2 7 | defaultReferences: [] 8 | executionOrder: 0 9 | icon: {instanceID: 0} 10 | userData: 11 | assetBundleName: 12 | assetBundleVariant: 13 | -------------------------------------------------------------------------------- /Assets/EasyAnimation/Scripts/Moulds/EasyAnimation_Rotate.cs: -------------------------------------------------------------------------------- 1 | using System.Collections; 2 | using System.Collections.Generic; 3 | using UnityEngine; 4 | 5 | namespace EasyAnimation { 6 | [AddComponentMenu("EasyAnimation/旋转效果")] 7 | public class EasyAnimation_Rotate : EasyAnimationTemplateMethod 8 | { 9 | [Header("旋转增量")] 10 | public Vector3 incrementRotate = Vector3.zero; 11 | 12 | Vector3 lastRotation; 13 | 14 | protected override void Easy_Animation_Awake() 15 | { 16 | lastRotation = initRotation.eulerAngles; 17 | } 18 | 19 | protected override void PrimitiveOperation_Start() 20 | { 21 | ead = new EaseAinmationDrive(1, 0, 1, easetype); 22 | } 23 | 24 | protected override bool PrimitiveOperation_UpDate(float time) 25 | { 26 | transform.localRotation = Quaternion.Euler(incrementRotate * ead.getProgress(time) + lastRotation); 27 | return true; 28 | } 29 | 30 | public override void Rese() 31 | { 32 | transform.localRotation = initRotation; 33 | } 34 | } 35 | } 36 | 37 | -------------------------------------------------------------------------------- /Assets/EasyAnimation/Scripts/Moulds/EasyAnimation_Rotate.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 40d43645064d3dc49878478400eb6496 3 | timeCreated: 1536656832 4 | licenseType: Pro 5 | MonoImporter: 6 | serializedVersion: 2 7 | defaultReferences: [] 8 | executionOrder: 0 9 | icon: {instanceID: 0} 10 | userData: 11 | assetBundleName: 12 | assetBundleVariant: 13 | -------------------------------------------------------------------------------- /ProjectSettings/AudioManager.asset: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/foldcc/EasyAnimation/0ee2246413faea3a329ae2d7410a113282093d2d/ProjectSettings/AudioManager.asset -------------------------------------------------------------------------------- /ProjectSettings/ClusterInputManager.asset: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/foldcc/EasyAnimation/0ee2246413faea3a329ae2d7410a113282093d2d/ProjectSettings/ClusterInputManager.asset -------------------------------------------------------------------------------- /ProjectSettings/DynamicsManager.asset: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/foldcc/EasyAnimation/0ee2246413faea3a329ae2d7410a113282093d2d/ProjectSettings/DynamicsManager.asset -------------------------------------------------------------------------------- /ProjectSettings/EditorBuildSettings.asset: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/foldcc/EasyAnimation/0ee2246413faea3a329ae2d7410a113282093d2d/ProjectSettings/EditorBuildSettings.asset -------------------------------------------------------------------------------- /ProjectSettings/EditorSettings.asset: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/foldcc/EasyAnimation/0ee2246413faea3a329ae2d7410a113282093d2d/ProjectSettings/EditorSettings.asset -------------------------------------------------------------------------------- /ProjectSettings/GraphicsSettings.asset: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/foldcc/EasyAnimation/0ee2246413faea3a329ae2d7410a113282093d2d/ProjectSettings/GraphicsSettings.asset -------------------------------------------------------------------------------- /ProjectSettings/InputManager.asset: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/foldcc/EasyAnimation/0ee2246413faea3a329ae2d7410a113282093d2d/ProjectSettings/InputManager.asset -------------------------------------------------------------------------------- /ProjectSettings/NavMeshAreas.asset: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/foldcc/EasyAnimation/0ee2246413faea3a329ae2d7410a113282093d2d/ProjectSettings/NavMeshAreas.asset -------------------------------------------------------------------------------- /ProjectSettings/NetworkManager.asset: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/foldcc/EasyAnimation/0ee2246413faea3a329ae2d7410a113282093d2d/ProjectSettings/NetworkManager.asset -------------------------------------------------------------------------------- /ProjectSettings/Physics2DSettings.asset: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/foldcc/EasyAnimation/0ee2246413faea3a329ae2d7410a113282093d2d/ProjectSettings/Physics2DSettings.asset -------------------------------------------------------------------------------- /ProjectSettings/ProjectSettings.asset: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/foldcc/EasyAnimation/0ee2246413faea3a329ae2d7410a113282093d2d/ProjectSettings/ProjectSettings.asset -------------------------------------------------------------------------------- /ProjectSettings/ProjectVersion.txt: -------------------------------------------------------------------------------- 1 | m_EditorVersion: 5.5.4f1 2 | -------------------------------------------------------------------------------- /ProjectSettings/QualitySettings.asset: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/foldcc/EasyAnimation/0ee2246413faea3a329ae2d7410a113282093d2d/ProjectSettings/QualitySettings.asset -------------------------------------------------------------------------------- /ProjectSettings/TagManager.asset: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/foldcc/EasyAnimation/0ee2246413faea3a329ae2d7410a113282093d2d/ProjectSettings/TagManager.asset -------------------------------------------------------------------------------- /ProjectSettings/TimeManager.asset: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/foldcc/EasyAnimation/0ee2246413faea3a329ae2d7410a113282093d2d/ProjectSettings/TimeManager.asset -------------------------------------------------------------------------------- /ProjectSettings/UnityConnectSettings.asset: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/foldcc/EasyAnimation/0ee2246413faea3a329ae2d7410a113282093d2d/ProjectSettings/UnityConnectSettings.asset -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # EasyAnimation 2 | 3 | ![Unity 5][1] ![Unity 2017][2] ![Unity 2018][3] 4 | 5 | --- 6 | 7 | [下载插件](https://gitee.com/Foldcc/EasyAnimation/releases) 8 | 9 | ## 简介 10 | 11 | > **该项目停止维护,推荐使用另外一套UI动画系统 [MintAnimation](https://github.com/foldcc/MintAnimation) , 这套动画系统灵活性更高,且性能优化远高于EasyAnimation,能做到0 GC Alloc。** 12 | 13 | EasyAnimation是一套简单并适用于UI系统的动画控制工具,满足大部分UI的动画效果,最大的优势在于创建动画轻便易上手,可灵活控制支持多效果复合。 14 | 使用Unity的动画系统来控制UI显得太过庞大臃肿,针对UI的通用性控制不够灵活并且麻烦,相比之下该工具集成了大部分UI动效并且开放了动画播放的控制接口以及监听事件,更加简单。 15 | > [2018-8-13] 由于录制GIF图时帧率较低,该页面显示效果可能有所欠佳,可自行在Unity上测试实际效果 16 | > **注:图片较多流量消耗可能较高** 17 | 18 | **效果演示-"缩放效果"** 19 | 点击属性面板选择EasyAnimation选项选择缩放效果并设置自动播放 20 | 21 | ![缩放效果][4] 22 | 23 | ## 动画效果 24 | 25 | EasyAnimation动画通过缓动函数实现,目前实现了大约提供了十多种常用缓动效果,以下是几种常用缓动效果演示: 26 | 27 | - Sine 28 | ![Sine][5] 29 | 30 | - Bounce 31 | ![Bounce][6] 32 | 33 | - Back 34 | ![Back][7] 35 | 36 | 缓动函数可为系统提供稳定的动画效果,并且未来会逐步测试增加新的效果。 37 | 38 | ## 动画类型 39 | 40 | 目前提供3种类型分别为: 缩放(scale)、移动(postion)、透明度(alpha) 41 | 42 | - 缩放效果 43 | ![缩放效果][8] 44 | - 移动 45 | ![移动][9] 46 | - 透明度 47 | ![透明度][10] 48 | 49 | ## 系统机制 50 | 51 | ### 事件监听 52 | 53 | 每一个动画提供两个监听事件,分别为 54 | 55 | - OnStart : 该动画Play()之后和开始播放前执行 56 | 57 | - OnEnd :该动画结束播放之后执行 58 | 59 | 注册监听方法 60 | **public void addListener(Action e , PlayActionType type)** 61 | 62 | ### 动画播放周期流程图 63 | 64 | ![动画周期][11] 65 | 66 | ## 使用介绍 67 | 68 | 导入该插件后 69 | 70 | - 选种任意UI对象点击属性面板的Add Component按钮添加EasyAnimation 71 | 72 | - 选择需要的动画类型 73 | 74 | - 设置参数,勾选自动播放 75 | 76 | - 当该UI被创建或者被激活时 自动播放设置好的动画 77 | 78 | [1]: https://img.shields.io/badge/Unity-5-red.svg 79 | [2]: https://img.shields.io/badge/Unity-2017-blue.svg 80 | [3]: https://img.shields.io/badge/Unity-2018-green.svg 81 | [4]: https://fold.oss-cn-shanghai.aliyuncs.com/Geeit/EasyAnimation/1001.gif 82 | [5]: https://fold.oss-cn-shanghai.aliyuncs.com/Geeit/EasyAnimation/1003.gif 83 | [6]: https://fold.oss-cn-shanghai.aliyuncs.com/Geeit/EasyAnimation/1004.gif 84 | [7]: https://fold.oss-cn-shanghai.aliyuncs.com/Geeit/EasyAnimation/1005.gif 85 | [8]: https://fold.oss-cn-shanghai.aliyuncs.com/Geeit/EasyAnimation/1001.gif 86 | [9]: https://fold.oss-cn-shanghai.aliyuncs.com/Geeit/EasyAnimation/1007.gif 87 | [10]: https://fold.oss-cn-shanghai.aliyuncs.com/Geeit/EasyAnimation/1006.gif 88 | [11]: https://fold.oss-cn-shanghai.aliyuncs.com/Geeit/EasyAnimation/1008.png 89 | -------------------------------------------------------------------------------- /_config.yml: -------------------------------------------------------------------------------- 1 | theme: jekyll-theme-midnight -------------------------------------------------------------------------------- /unitypackages/EasyAnimation 1.4.unitypackage: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/foldcc/EasyAnimation/0ee2246413faea3a329ae2d7410a113282093d2d/unitypackages/EasyAnimation 1.4.unitypackage -------------------------------------------------------------------------------- /unitypackages/unitypackage.txt: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/foldcc/EasyAnimation/0ee2246413faea3a329ae2d7410a113282093d2d/unitypackages/unitypackage.txt --------------------------------------------------------------------------------