123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155 |
- using System;
- using UnityEngine;
- [Serializable]
- public class AMRotationAction : AMAction
- {
- public override string ToString(int codeLanguage, int frameRate)
- {
- if (this.endFrame == -1)
- {
- return null;
- }
- string text;
- if (codeLanguage == 0)
- {
- text = string.Concat(new object[]
- {
- "AMTween.RotateTo (obj.gameObject, AMTween.Hash (\"delay\", ",
- base.getWaitTime(frameRate, 0f),
- "f, \"time\", ",
- this.getTime(frameRate),
- "f, "
- });
- string text2 = text;
- text = string.Concat(new object[]
- {
- text2,
- "\"rotation\", new Vector3(",
- this.endRotation.eulerAngles.x,
- "f, ",
- this.endRotation.eulerAngles.y,
- "f, ",
- this.endRotation.eulerAngles.z,
- "f), "
- });
- text = text + base.getEaseString(codeLanguage) + "));";
- }
- else
- {
- text = string.Concat(new object[]
- {
- "AMTween.RotateTo (obj.gameObject, {\"delay\": ",
- base.getWaitTime(frameRate, 0f),
- ", \"time\": ",
- this.getTime(frameRate),
- ", "
- });
- string text2 = text;
- text = string.Concat(new object[]
- {
- text2,
- "\"rotation\": Vector3(",
- this.endRotation.eulerAngles.x,
- ", ",
- this.endRotation.eulerAngles.y,
- ", ",
- this.endRotation.eulerAngles.z,
- "), "
- });
- text = text + base.getEaseString(codeLanguage) + "});";
- }
- return text;
- }
- public override int getNumberOfFrames()
- {
- return this.endFrame - this.startFrame;
- }
- public float getTime(int frameRate)
- {
- return (float)this.getNumberOfFrames() / (float)frameRate;
- }
- public override void execute(int frameRate, float delay, string trackId)
- {
- if (!this.obj)
- {
- return;
- }
- if (this.endFrame == -1)
- {
- return;
- }
- if (base.hasCustomEase())
- {
- AMTween.RotateTo(this.obj.gameObject, AMTween.Hash(new object[]
- {
- "trackid",
- trackId,
- "delay",
- base.getWaitTime(frameRate, delay),
- "time",
- this.getTime(frameRate),
- "rotation",
- this.endRotation.eulerAngles,
- "easecurve",
- base.easeCurve
- }));
- }
- else
- {
- AMTween.RotateTo(this.obj.gameObject, AMTween.Hash(new object[]
- {
- "trackid",
- trackId,
- "delay",
- base.getWaitTime(frameRate, delay),
- "time",
- this.getTime(frameRate),
- "rotation",
- this.endRotation.eulerAngles,
- "easetype",
- (AMTween.EaseType)this.easeType
- }));
- }
- }
- public Quaternion getStartQuaternion()
- {
- return this.startRotation;
- }
- public Quaternion getEndQuaternion()
- {
- return this.endRotation;
- }
- public override AnimatorTimeline.JSONAction getJSONAction(int frameRate)
- {
- if (!this.obj || this.endFrame == -1)
- {
- return null;
- }
- AnimatorTimeline.JSONAction jsonaction = new AnimatorTimeline.JSONAction();
- jsonaction.go = this.obj.gameObject.name;
- jsonaction.method = "rotateto";
- jsonaction.delay = base.getWaitTime(frameRate, 0f);
- jsonaction.time = this.getTime(frameRate);
- base.setupJSONActionEase(jsonaction);
- jsonaction.setPath(new Vector3[]
- {
- this.endRotation.eulerAngles
- });
- return jsonaction;
- }
- public int endFrame;
- public Transform obj;
- public Quaternion startRotation;
- public Quaternion endRotation;
- }
|