public static void ITweenMoveTo(GameObject _obj, AnimKeyFrameInfo _keyInfo, iTween.EventDelegate complete, float time, Vector3 refPosition, Vector3 refRotation) { iTween.MoveTo(_obj, iTween.Hash("position", _keyInfo.Position + refPosition, "time", time, "delay", _keyInfo.DelayTime, "easetype", iTween.EaseType.easeInOutSine), null, complete); iTween.RotateTo(_obj, iTween.Hash("rotation", _keyInfo.EulerAngles + refRotation, "time", time, "delay", _keyInfo.DelayTime, "easetype", iTween.EaseType.easeInOutSine)); }
// Response when user click the "AddPoint" Button void OnClickThisPoint() { if (null == Selection.activeGameObject) { EditorUtility.DisplayDialog("Warning", "Please selection your target gameObject.", "Ok"); return; } Transform tf = Selection.activeGameObject.transform; // Debug.Log("" + tf.position); // Debug.Log("" + tf.rotation.eulerAngles); AnimKeyFrameInfo frame = new AnimKeyFrameInfo(); frame.Position = absoluteAnim ? tf.position : tf.position - startPostion; Vector3 tempAngles = absoluteAnim ? tf.rotation.eulerAngles : tf.rotation.eulerAngles - startEulerAngles; tempAngles.x %= 360; tempAngles.y %= 360; tempAngles.z %= 360; frame.EulerAngles = tempAngles; frame.TransformTime = 1.0f; frame.DelayTime = 0.0f; if (currGameObj != Selection.activeGameObject) { animFrames.Clear(); currGameObj = Selection.activeGameObject; RelAnimControl animCtrl = currGameObj.GetComponent <RelAnimControl>() as RelAnimControl; if (null == animCtrl || null == animCtrl.keyFrameInfos || 0 == animCtrl.keyFrameInfos.Length) { animFrames = new List <AnimKeyFrameInfo>(); animFrames.Capacity = 5; } else { animFrames = new List <AnimKeyFrameInfo>(); animFrames.Capacity = animCtrl.keyFrameInfos.Length + 5; foreach (AnimKeyFrameInfo info in animCtrl.keyFrameInfos) { animFrames.Add(info); } } animFrames.Add(frame); } else { animFrames.Add(frame); } needUpdateFrames = true; }
void Awake() { origPos = gameObject.transform.position; origEulerAngles = gameObject.transform.rotation.eulerAngles; if (null == keyFrameInfos) { keyFrameInfos = new AnimKeyFrameInfo[0]; } // if (null == targetGameObj) targetGameObj = this.gameObject; currentIndex = 0; isTrackEnalbed = true; trackEnumerator = DoMoveTrack(); }
private void ITweenStart() { if (currentIndex >= keyFrameInfos.Length) { isTrackEnalbed = false; PlayDoneDelegate(); return; } AnimKeyFrameInfo info = keyFrameInfos[currentIndex]; ITweenMoveTo(info, delegate() { currentIndex++; ITweenStart(); } ); }
//! tzz added for camera move public static void ITweenMoveTo(GameObject _obj, AnimKeyFrameInfo _keyInfo, iTween.EventDelegate complete, float time) { ITweenMoveTo(_obj, _keyInfo, complete, time, Vector3.zero, Vector3.zero); }
private void ITweenMoveTo(AnimKeyFrameInfo _keyInfo, iTween.EventDelegate complete) { ITweenMoveTo(targetGameObj, _keyInfo, complete, _keyInfo.TransformTime, origPos, origEulerAngles); }