public void PositionXYZEaseDelay(GameObject targetObject, EaseType type, TweenType tweentype, float start, float end, float delay, float duration, bool isLocal = false, EventHandler hdr = null) { TweenInformation info = new TweenInformation(); info.SetTweenValue(type, tweentype, targetObject, duration, delay, isLocal, hdr, new Vector2(start, end)); _tweenObjectList.Add(info); }
/** * @fn public void TimeScaleEase(EaseType type, float start, float end, float duration) * @author 김경호([email protected]) * @brief TimeScale을 Tween한다. */ public void TimeScaleEase(EaseType type, float start, float end, float duration) { TweenInformation info = new TweenInformation(); info.SetTweenValue(type, TweenType.TimeScale, null, duration, 0.0f, false, null, new Vector2(start, end)); _tweenObjectList.Add(info); }
/** * @fn public void ScaleEase(GameObject targetObject, EaseType type, Vector3 start, Vector3 end, float duration, EventHandler hdr = null) * @author 김경호([email protected]) * @brief GameObject Scale을 트윈한다. * @param targetObject tween할 GameObject * @param type Tween에 사용할 Ease Type * @param start 시작크기 * @param end 목표크기 * @param duration Tween의 지속시간 * @param hdr Tween이 끝난 후 호출될 Event함수 */ public void ScaleEase(GameObject targetObject, EaseType type, Vector3 start, Vector3 end, float duration, EventHandler hdr = null) { TweenInformation info = new TweenInformation(); info.SetTweenValue(type, TweenType.Scale, targetObject, duration, 0.0f, true, hdr, new Vector2(start.x, end.x), new Vector2(start.y, end.y), new Vector2(start.z, end.z)); _tweenObjectList.Add(info); }
public void FogEase(EaseType type, Color start, Color end, float duration) { TweenInformation info = new TweenInformation(); info.SetTweenValue(type, TweenType.Fog, null, duration, 0.0f, false, null, new Vector2(start.r, end.r), new Vector3(start.g, end.g), new Vector2(start.b, end.b)); _tweenObjectList.Add(info); }
/** * @fn public void PositionEase(GameObject targetObject, EaseType type, Vector3 start, Vector3 end, float duration, bool isLocal = false, EventHandler hdr = null) * @author 김경호([email protected]) * @brief GameObject position을 트윈한다. * @param targetObject tween할 GameObject * @param type Tween에 사용할 Ease Type * @param start 시작점 * @param end 도착점 * @param duration Tween의 지속시간 * @param isLocal 위치 이동의 공간이 로컬인지 월드인지 셋팅 * @param hdr 이동이 끝난 후 호출될 Event함수 */ public void PositionEase(GameObject targetObject, EaseType type, Vector3 start, Vector3 end, float duration, bool isLocal = false, EventHandler hdr = null, object obj = null) { TweenInformation info = new TweenInformation(); info.SetTweenValue(type, TweenType.Position, targetObject, duration, 0.0f, isLocal, hdr, obj, new Vector2(start.x, end.x), new Vector2(start.y, end.y), new Vector2(start.z, end.z)); _tweenObjectList.Add(info); }
/** * @fn public void RotationEase(GameObject targetObject, EaseType type, Quaternion start, Quaternion end, float duration, bool isLocal = false, EventHandler hdr = null) * @author 김경호([email protected]) * @brief GameObject 회전을 트윈한다. * @param targetObject tween할 GameObject * @param type Tween에 사용할 Ease Type * @param start 시작 Quaternion * @param end 목표 Quaternion * @param duration Tween의 지속시간 * @param hdr Tween 이 끝난 후 호출될 Event함수 */ public void RotationEase(GameObject targetObject, EaseType type, Quaternion start, Quaternion end, float duration, bool isLocal = false, EventHandler hdr = null) { TweenInformation info = new TweenInformation(); float tempEndX; float tempEndY; float tempEndZ; if (start.eulerAngles.x > end.eulerAngles.x) { tempEndX = end.eulerAngles.x + 360.0f; } else { tempEndX = end.eulerAngles.x - 360.0f; } if (Mathf.Abs(start.eulerAngles.x - end.eulerAngles.x) < Mathf.Abs(start.eulerAngles.x - tempEndX)) { tempEndX = end.eulerAngles.x; } if (start.eulerAngles.y > end.eulerAngles.y) { tempEndY = end.eulerAngles.y + 360.0f; } else { tempEndY = end.eulerAngles.y - 360.0f; } if (Mathf.Abs(start.eulerAngles.y - end.eulerAngles.y) < Mathf.Abs(start.eulerAngles.y - tempEndY)) { tempEndY = end.eulerAngles.y; } if (start.eulerAngles.z > end.eulerAngles.z) { tempEndZ = end.eulerAngles.z + 360.0f; } else { tempEndZ = end.eulerAngles.z - 360.0f; } if (Mathf.Abs(start.eulerAngles.z - end.eulerAngles.z) < Mathf.Abs(start.eulerAngles.z - tempEndZ)) { tempEndZ = end.eulerAngles.z; } //Debug.Log(tempEndY); info.SetTweenValue(type, TweenType.Rotation, targetObject, duration, 0.0f, isLocal, hdr, new Vector2(start.eulerAngles.x, tempEndX), new Vector2(start.eulerAngles.y, tempEndY), new Vector2(start.eulerAngles.z, tempEndZ)); _tweenObjectList.Add(info); }
public void PositionEaseStop(GameObject targetObject) { for (int i = 0; i < _tweenObjectList.Count; i++) { TweenInformation info = _tweenObjectList[i]; if (info._targetObject == targetObject && info._tweenType == TweenType.Position) { _tweenObjectList.Remove(info); return; } } }
public void RotationEaseStop(GameObject targetObject) { StopCoroutine("RotationEaseCoroutine"); for (int i = 0; i < _tweenObjectList.Count; i++) { TweenInformation info = _tweenObjectList[i]; if (info._targetObject == targetObject) { _tweenObjectList.Remove(info); return; } } }
public void PositionEaseDelay(GameObject targetObject, EaseType type, Vector3 end, float duration, float delay, bool isLocal = false, EventHandler hdr = null) { if (isLocal == true) { TweenInformation info = new TweenInformation(); info.SetTweenValue(type, TweenType.Position, targetObject, duration, delay, isLocal, hdr, new Vector2(targetObject.transform.localPosition.x, end.x), new Vector2(targetObject.transform.localPosition.y, end.y), new Vector2(targetObject.transform.localPosition.z, end.z)); _tweenObjectList.Add(info); } else { TweenInformation info = new TweenInformation(); info.SetTweenValue(type, TweenType.Position, targetObject, duration, delay, isLocal, hdr, new Vector2(targetObject.transform.position.x, end.x), new Vector2(targetObject.transform.position.y, end.y), new Vector2(targetObject.transform.position.z, end.z)); _tweenObjectList.Add(info); } }
// Update is called once per frame void Update() { if (_isPause == false) { for (int i = 0; i < _tweenObjectList.Count; i++) { TweenInformation info = _tweenObjectList[i]; if (info._tweenType != TweenType.TimeScale) { //if(info._targetObject == null) //{ // Debug.Log("Tween Target Object is Null : " + info._tweenType + "\t\t" + info._easeType + "\t\t" + info._time + "\t\t" + info._isLocal); // _tweenObjectList.Remove(info); // i--; // continue; //} } if (info._currentTime >= 0.0f && info._currentTime < info._time) { for (int j = 0; j < info._start.Length; j++) { switch (info._easeType) { case EaseType.Linear: info._currentValue[j] = linear(info._start[j], info._end[j], info._currentTime / info._time); break; case EaseType.Clerp: info._currentValue[j] = clerp(info._start[j], info._end[j], info._currentTime / info._time); break; case EaseType.Spring: info._currentValue[j] = spring(info._start[j], info._end[j], info._currentTime / info._time); break; case EaseType.EaseInQuad: info._currentValue[j] = easeInQuad(info._start[j], info._end[j], info._currentTime / info._time); break; case EaseType.EaseOutQuad: info._currentValue[j] = easeOutQuad(info._start[j], info._end[j], info._currentTime / info._time); break; case EaseType.EaseInOutQuad: info._currentValue[j] = easeInOutQuad(info._start[j], info._end[j], info._currentTime / info._time); break; case EaseType.EaseInCubic: info._currentValue[j] = easeInCubic(info._start[j], info._end[j], info._currentTime / info._time); break; case EaseType.EaseOutCubic: info._currentValue[j] = easeOutCubic(info._start[j], info._end[j], info._currentTime / info._time); break; case EaseType.EaseInOutCubic: info._currentValue[j] = easeInOutCubic(info._start[j], info._end[j], info._currentTime / info._time); break; case EaseType.EaseInQuart: info._currentValue[j] = easeInQuart(info._start[j], info._end[j], info._currentTime / info._time); break; case EaseType.EaseOutQuart: info._currentValue[j] = easeOutQuart(info._start[j], info._end[j], info._currentTime / info._time); break; case EaseType.EaseInOutQuart: info._currentValue[j] = easeInOutQuart(info._start[j], info._end[j], info._currentTime / info._time); break; case EaseType.EaseInQuint: info._currentValue[j] = easeInQuint(info._start[j], info._end[j], info._currentTime / info._time); break; case EaseType.EaseOutQuint: info._currentValue[j] = easeOutQuint(info._start[j], info._end[j], info._currentTime / info._time); break; case EaseType.EaseInOutQuint: info._currentValue[j] = easeInOutQuint(info._start[j], info._end[j], info._currentTime / info._time); break; case EaseType.EaseInSine: info._currentValue[j] = easeInSine(info._start[j], info._end[j], info._currentTime / info._time); break; case EaseType.EaseOutSine: info._currentValue[j] = easeOutSine(info._start[j], info._end[j], info._currentTime / info._time); break; case EaseType.EaseInOutSine: info._currentValue[j] = easeInOutSine(info._start[j], info._end[j], info._currentTime / info._time); break; case EaseType.EaseInExpo: info._currentValue[j] = easeInExpo(info._start[j], info._end[j], info._currentTime / info._time); break; case EaseType.EaseOutExpo: info._currentValue[j] = easeOutExpo(info._start[j], info._end[j], info._currentTime / info._time); break; case EaseType.EaseInOutExpo: info._currentValue[j] = easeInOutExpo(info._start[j], info._end[j], info._currentTime / info._time); break; case EaseType.EaseInCirc: info._currentValue[j] = easeInCirc(info._start[j], info._end[j], info._currentTime / info._time); break; case EaseType.EaseOutCirc: info._currentValue[j] = easeOutCirc(info._start[j], info._end[j], info._currentTime / info._time); break; case EaseType.EaseInOutCirc: info._currentValue[j] = easeInOutCirc(info._start[j], info._end[j], info._currentTime / info._time); break; case EaseType.EaseInBounce: info._currentValue[j] = easeInBounce(info._start[j], info._end[j], info._currentTime / info._time); break; case EaseType.EaseOutBounce: info._currentValue[j] = easeOutBounce(info._start[j], info._end[j], info._currentTime / info._time); break; case EaseType.EaseInOutBounce: info._currentValue[j] = easeInOutBounce(info._start[j], info._end[j], info._currentTime / info._time); break; case EaseType.EaseInBack: info._currentValue[j] = easeInBack(info._start[j], info._end[j], info._currentTime / info._time); break; case EaseType.EaseOutBack: info._currentValue[j] = easeOutBack(info._start[j], info._end[j], info._currentTime / info._time); break; case EaseType.EaseInOutBack: info._currentValue[j] = easeInOutBack(info._start[j], info._end[j], info._currentTime / info._time); break; case EaseType.EaseInElastic: info._currentValue[j] = easeInElastic(info._start[j], info._end[j], info._currentTime / info._time); break; case EaseType.EaseOutElastic: info._currentValue[j] = easeOutElastic(info._start[j], info._end[j], info._currentTime / info._time); break; case EaseType.EaseInOutElastic: info._currentValue[j] = easeInOutElastic(info._start[j], info._end[j], info._currentTime / info._time); break; } } switch (info._tweenType) { case TweenType.Position: if (info._isLocal == true) { info._targetObject.transform.localPosition = new Vector3(info._currentValue[0], info._currentValue[1], info._currentValue[2]); } else { info._targetObject.transform.position = new Vector3(info._currentValue[0], info._currentValue[1], info._currentValue[2]); } break; case TweenType.Scale: info._targetObject.transform.localScale = new Vector3(info._currentValue[0], info._currentValue[1], info._currentValue[2]); break; case TweenType.Rotation: if (info._isLocal == true) { info._targetObject.transform.localRotation = Quaternion.Euler(info._currentValue[0], info._currentValue[1], info._currentValue[2]); } else { info._targetObject.transform.rotation = Quaternion.Euler(info._currentValue[0], info._currentValue[1], info._currentValue[2]); } break; case TweenType.Ambient: RenderSettings.ambientLight = new Color(info._currentValue[0], info._currentValue[1], info._currentValue[2], 0.0f); break; case TweenType.Fog: RenderSettings.fogColor = new Color(info._currentValue[0], info._currentValue[1], info._currentValue[2], 0.0f); break; case TweenType.TimeScale: Time.timeScale = info._currentValue[0]; break; case TweenType.PositionX: if (info._isLocal == false) { info._targetObject.transform.position = new Vector3(info._currentValue[0], info._targetObject.transform.position.y, info._targetObject.transform.position.z); } else { info._targetObject.transform.localPosition = new Vector3(info._currentValue[0], info._targetObject.transform.localPosition.y, info._targetObject.transform.localPosition.z); } break; case TweenType.PositionY: if (info._isLocal == false) { info._targetObject.transform.position = new Vector3(info._targetObject.transform.position.x, info._currentValue[0], info._targetObject.transform.position.z); } else { info._targetObject.transform.localPosition = new Vector3(info._targetObject.transform.localPosition.x, info._currentValue[0], info._targetObject.transform.localPosition.z); } break; case TweenType.PositionZ: if (info._isLocal == false) { info._targetObject.transform.position = new Vector3(info._targetObject.transform.position.x, info._targetObject.transform.position.y, info._currentValue[0]); } else { info._targetObject.transform.localPosition = new Vector3(info._targetObject.transform.localPosition.x, info._targetObject.transform.localPosition.y, info._currentValue[0]); } break; } info._currentTime += Time.deltaTime; } else if (info._currentTime >= 0.0f && info._currentTime >= info._time) { switch (info._tweenType) { case TweenType.Position: if (info._isLocal == false) { info._targetObject.transform.position = new Vector3(info._end[0], info._end[1], info._end[2]); } else { info._targetObject.transform.localPosition = new Vector3(info._end[0], info._end[1], info._end[2]); } info.PlayEndEventHandler(); break; case TweenType.Scale: info._targetObject.transform.localScale = new Vector3(info._end[0], info._end[1], info._end[2]); info.PlayEndEventHandler(); break; case TweenType.Rotation: if (info._isLocal == false) { info._targetObject.transform.rotation = Quaternion.Euler(info._end[0], info._end[1], info._end[2]); } else { info._targetObject.transform.localRotation = Quaternion.Euler(info._end[0], info._end[1], info._end[2]); } info.PlayEndEventHandler(); break; case TweenType.Ambient: RenderSettings.ambientLight = new Color(info._end[0], info._end[1], info._end[2], 0.0f); break; case TweenType.Fog: RenderSettings.fogColor = new Color(info._end[0], info._end[1], info._end[2], 0.0f); break; case TweenType.TimeScale: Time.timeScale = info._end[0]; break; case TweenType.PositionX: if (info._isLocal == false) { info._targetObject.transform.position = new Vector3(info._end[0], info._targetObject.transform.position.y, info._targetObject.transform.position.z); } else { info._targetObject.transform.localPosition = new Vector3(info._end[0], info._targetObject.transform.localPosition.y, info._targetObject.transform.localPosition.z); } info.PlayEndEventHandler(); break; case TweenType.PositionY: if (info._isLocal == false) { info._targetObject.transform.position = new Vector3(info._targetObject.transform.position.x, info._end[0], info._targetObject.transform.position.z); } else { info._targetObject.transform.localPosition = new Vector3(info._targetObject.transform.localPosition.x, info._end[0], info._targetObject.transform.localPosition.z); } info.PlayEndEventHandler(); break; case TweenType.PositionZ: if (info._isLocal == false) { info._targetObject.transform.position = new Vector3(info._targetObject.transform.position.x, info._targetObject.transform.position.y, info._end[0]); } else { info._targetObject.transform.localPosition = new Vector3(info._targetObject.transform.localPosition.x, info._targetObject.transform.localPosition.y, info._end[0]); } info.PlayEndEventHandler(); break; } _tweenObjectList.Remove(info); i--; } else { info._currentTime += Time.deltaTime; } } } }