# AnimatedLite
**Repository Path**: Sun_ME/AnimatedLite
## Basic Information
- **Project Name**: AnimatedLite
- **Description**: 一个模仿DoTween动画插件的精简版脚本,有移动、旋转、缩放、淡入淡出以及给定时间内改变值类型的值。同时,每个动作均可调用动画播放的回调函数。依据Unity 协程完成。自带Demo实现。
- **Primary Language**: C#
- **License**: Not specified
- **Default Branch**: master
- **Homepage**: None
- **GVP Project**: No
## Statistics
- **Stars**: 1
- **Forks**: 1
- **Created**: 2018-11-09
- **Last Updated**: 2022-05-20
## Categories & Tags
**Categories**: Uncategorized
**Tags**: None
## README
**实现了一个Dotween超精简版的脚本,核心均基于Unity MonoNehaviour.StartCoroutine方法实现,添加了Unity.Transform添加扩展方法,方便调用。包含动画过程中常用的基本的位移、缩放、旋转、淡入淡出、以及数值的动态变化。使用也非常简单。直接将Plugins下的Prefabs拖动到场景中,然后再脚本中调用即可。**
## Demo截图预览

---
## 部分代码如下
```csharp
using System;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
namespace SunME {
public static class Extensionmethod {
///
/// 移动对象到目标位置
///
///
目标坐标
///
过程的持续时间
///
是否忽视时间缩放
///
执行完成的回调函数
public static void DoMove (this Transform t, Vector3 targetPos, float duration = 1, bool ignoreTimeScale = false, Action OnComplete = null) {
Tween.Instance.MoveAtion (t, targetPos, duration, ignoreTimeScale, OnComplete);
}
///
/// 旋转对象到目标欧拉角
///
///
目标欧拉角
///
过程的持续时间
///
是否忽视时间缩放
///
执行完成的回调函数
public static void DoRotate (this Transform t, Vector3 targetRotate, float duration = 1, bool ignoreTimeScale = false, Action OnComplete = null) {
Tween.Instance.RoateAction (t, targetRotate, duration, ignoreTimeScale, OnComplete);
}
///
/// 缩放对象到目标值
///
///
目标缩放值
///
过程的持续时间
///
///
执行完成的回调函数
public static void DoScale (this Transform t, Vector3 targetScale, float duration = 1, bool ignoreTimeScale = false, Action OnComplete = null) {
Tween.Instance.ScaleAction (t, targetScale, duration, ignoreTimeScale, OnComplete);
}
///
/// 改变对象的Alpha为目标值
///
///
是否是淡入,否则为淡出
///
过程的持续时间
///
是否忽视时间缩放
///
执行完成的回调函数
public static void DoFade (this Transform t, bool isfadeIn, float duration = 1, bool ignoreTimeScale = false, Action OnComplete = null) {
Tween.Instance.FadeAction (t, isfadeIn, duration, ignoreTimeScale, OnComplete);
}
///
/// 在给定时间内改变一个浮点值
///
///
目标值
///
值发生改变时的回调函数
///
持续时间
///
是否忽视时间缩放
///
值更改完成时回调
public static void DoValueChange (this float t, float targetValue, Action
valueChangeAction, float duration = 1, bool ignoreTimeScale = false, Action OnComplete = null) {
Tween.Instance.ValueChangeAction (t, targetValue, valueChangeAction, duration, ignoreTimeScale, OnComplete);
}
}
}
```
---
## 调用方式如下
```csharp
t1.DoMove (new Vector3 (3, -2, 0), 2, true, ()=>{ Debug.Log ("移动完成"); { Debug.Log ("移动完成"); });
t2.DoRotate (new Vector3 (0, 60, 0), 2, false, () => { Debug.Log ("旋转完成"); });
t3.DoScale (new Vector3 (3, 3, 3), 3);
spriteRenderer.transform.DoFade (false, 3);
image.transform.DoFade (false, 2);
kk.DoValueChange (80, value => { _camera.fieldOfView = value; }, 2, false, () => {
Debug.Log ("值改变完成");
});
```
Demo和工程地质地址:扫码—>当前文章—>文章末尾

## 地址:https://gitee.com/Sun_ME/AnimatedLite.git