public static int easeIndex(LeanTweenItem item) { if (item.easeStr.Length <= 0) // First Time setup { item.easeStr = easeStrMapping[(int)item.ease]; if (item.ease == LeanTweenType.notUsed) { item.easeStr = "linear"; } } int easeIndex = -1; // easeIndex( item ) for (int j = 0; j < easeStrMapping.Length; j++) { if (item.easeStr == easeStrMapping[j]) { easeIndex = j; // Debug.Log("found match easeIndex:"+easeIndex + " easeStrMapping[easeIndex]:"+easeStrMapping[easeIndex]); break; } } if (easeIndex < 0) // nothing found set to intial { easeIndex = 0; } return(easeIndex); }
// Instantiates LeanTweenGroup by making a copy of group. // <param name="group">Group.</param> public LeanTweenItem(LeanTweenItem item) { name = item.name; action = item.action; between = item.between; ease = item.ease; from = item.from; to = item.to; axis = item.axis; duration = item.duration; delay = item.delay; foldout = item.foldout; }
public static int actionIndex(LeanTweenItem item) { int actionIndex = -1; for (int j = 0; j < methodStrMapping.Length; j++) { if (item.actionStr == methodStrMapping[j]) { actionIndex = j; // Debug.Log("found match actionIndex:"+actionIndex + " methodStrMapping[actionIndex]:"+methodStrMapping[actionIndex]); break; } } if (actionIndex < 0) // nothing found set to intial { actionIndex = 0; } return(actionIndex); }
public override void OnInspectorGUI() { GUI.DrawTexture(new Rect(16, EditorGUILayout.GetControlRect().y - 16, 16, 16), LTEditor.editorIcon()); LeanTweenVisual tween = target as LeanTweenVisual; EditorGUI.BeginChangeCheck(); float overallDelay = 0; bool clicked, deleted; Vector3 vec; clicked = false; tween.playOnStart = EditorGUILayout.Toggle(new GUIContent("Play on Start", "Tweens won't start automatically, you can start them via code with .start()"), tween.playOnStart, GUILayout.Width(100)); EditorGUILayout.BeginHorizontal(); tween.restartOnEnable = EditorGUILayout.Toggle(new GUIContent("Restart on enable", "When you enable the gameobject these set of tweens will start again"), tween.restartOnEnable); tween.repeat = EditorGUILayout.Toggle(new GUIContent("Repeat All", "Repeat the whole set of tween groups once they finish"), tween.repeat); EditorGUILayout.EndHorizontal(); if (tween.repeat) { tween.repeatDelay = EditorGUILayout.FloatField("All Delay", tween.repeatDelay); tween.repeatCount = EditorGUILayout.IntField("All Repeat Count", tween.repeatCount); } float addedGroupDelay = 0f; foreach (LeanTweenGroup group in tween.groupList) { EditorGUILayout.Space(); GUI.color = LTEditor.shared.colorGroupName; EditorGUILayout.BeginHorizontal(); group.foldout = EditorGUILayout.Foldout(group.foldout, "", LTEditor.shared.styleGroupFoldout); clicked = GUILayout.Button("Group: " + group.name + " " + (group.startTime) + "s - " + (group.endTime) + "s", LTEditor.shared.styleGroupButton); GUI.color = LTEditor.shared.colorDelete; deleted = GUILayout.Button("Delete", LTEditor.shared.styleDeleteGroupButton); EditorGUILayout.EndHorizontal(); GUI.color = Color.white; if (clicked) { group.foldout = !group.foldout; } if (deleted) { Undo.RecordObject(tween, "Removing group item"); tween.groupList.Remove(group); break; } float addedTweenDelay = 0f; if (group.foldout) { group.name = EditorGUILayout.TextField("Group Name", group.name); EditorGUILayout.BeginHorizontal(); group.repeat = EditorGUILayout.Toggle("Group Repeat", group.repeat); group.delay = EditorGUILayout.FloatField("Group Delay", group.delay); EditorGUILayout.EndHorizontal(); group.gameObject = EditorGUILayout.ObjectField("Group GameObject", group.gameObject, typeof(GameObject), true) as GameObject; if (group.gameObject == null) // Should default to the current object { group.gameObject = tween.gameObject; } if (group.repeat) { group.repeatCount = EditorGUILayout.IntField("Group Repeat Count", group.repeatCount); } int i = 0; foreach (LeanTweenItem item in group.itemList) { TweenAction a = (TweenAction)item.action; EditorGUILayout.BeginHorizontal(); GUILayout.Space(15); item.foldout = EditorGUILayout.Foldout(item.foldout, "Tween "); GUI.color = LTEditor.shared.colorTweenName; int actionIndex = EditorGUILayout.Popup(LTVisualShared.actionIndex(item), LTVisualShared.methodLabels); LTVisualShared.setActionIndex(item, actionIndex); // clicked = GUILayout.Button(""+a + " " + ( group.delay + item.delay) + "s - " + ( group.delay + item.delay + item.duration) + "s"); GUI.color = LTEditor.shared.colorDelete; deleted = GUILayout.Button("Delete", LTEditor.shared.styleDeleteButton); EditorGUILayout.EndHorizontal(); GUI.color = Color.white; if (clicked) { item.foldout = !item.foldout; } if (deleted) { Undo.RecordObject(tween, "Removing tween item"); group.itemList.Remove(item); break; } if (item.foldout) { a = item.action; bool tweenTypeChanged = (int)item.action != item.actionLast; if (tweenTypeChanged && item.actionLast >= 0) { // Setup with the helpful default values // Debug.Log("Setting up to default values a:"+a); /*item.to = Vector3.zero; * if((a>=TweenAction.MOVE_X && a<=TweenAction.MOVE_LOCAL_Z) || a==TweenAction.MOVE || a==TweenAction.MOVE_LOCAL) * item.to = item.from = tween.gameObject.transform.position; * else if((a>=TweenAction.SCALE_X && a<=TweenAction.SCALE_Z) || a==TweenAction.SCALE) * item.to = item.from = tween.gameObject.transform.localScale; #if !UNITY_4_3 && !UNITY_4_5 * else if(a==TweenAction.CANVAS_MOVE) * item.to = item.from = tween.gameObject.GetComponent<RectTransform>().anchoredPosition; * else if(a==TweenAction.CANVAS_SCALE) * item.to = item.from = tween.gameObject.GetComponent<RectTransform>().localScale; #endif */ } item.actionLast = (int)item.action; // Debug.Log("a:"+a); item.gameObject = EditorGUILayout.ObjectField(" GameObject", item.gameObject, typeof(GameObject), true, GUILayout.Width(250)) as GameObject; if (item.gameObject == null) // Should default to the current object { item.gameObject = tween.gameObject; } // Path bool isCurve = false; if (a == TweenAction.MOVE_CURVED || a == TweenAction.MOVE_CURVED_LOCAL) { item.bezierPath = EditorGUILayout.ObjectField(" LeanTweenPath:", item.bezierPath, typeof(LeanTweenPath), true) as LeanTweenPath; EditorGUILayout.BeginHorizontal(); change(ref item.orientToPath, EditorGUILayout.Toggle(" Orient to Path", item.orientToPath), tween, "Orient to path"); // if(orientToPath!=item.orientToPath){ // Undo.RecordObject(tween,"Orient to path"); // item.orientToPath = orientToPath; // } isCurve = true; item.isPath2d = EditorGUILayout.Toggle(" 2D Path", item.isPath2d); EditorGUILayout.EndHorizontal(); } else if (a == TweenAction.MOVE_SPLINE || a == TweenAction.MOVE_SPLINE_LOCAL) { item.splinePath = EditorGUILayout.ObjectField(" LeanTweenPath:", item.splinePath, typeof(LeanTweenPath), true) as LeanTweenPath; item.orientToPath = EditorGUILayout.Toggle(" Orient to Path", item.orientToPath); isCurve = true; } if (isCurve == false) { bool isVector = a == TweenAction.MOVE || a == TweenAction.MOVE_LOCAL || a == TweenAction.CANVAS_MOVE || a == TweenAction.ROTATE || a == TweenAction.ROTATE_LOCAL || a == TweenAction.SCALE || a == TweenAction.CANVAS_SCALE || a == TweenAction.CANVAS_SIZEDELTA || a == TweenAction.DELAYED_SOUND; bool isColor = a >= TweenAction.COLOR && a < TweenAction.CALLBACK; bool isPlay = a == TweenAction.CANVAS_PLAYSPRITE; bool usesFrom = !isColor && !isPlay; // From Values EditorGUILayout.BeginHorizontal(); if (usesFrom) // Not a Color tween { EditorGUILayout.LabelField(new GUIContent(" From", "Specify where the tween starts from, otherwise it will start from it's current value"), GUILayout.Width(50)); LeanTweenBetween between = EditorGUILayout.Toggle("", item.between == LeanTweenBetween.FromTo, GUILayout.Width(30)) ? LeanTweenBetween.FromTo : LeanTweenBetween.To; if (between != item.between) { Undo.RecordObject(tween, "Changing to from/to"); item.between = between; } } if (item.between == LeanTweenBetween.FromTo) { if (isVector) { // item.from = EditorGUILayout.Vector3Field("", item.from); change(ref item.from, EditorGUILayout.Vector3Field("", item.from), tween, "Changing from"); } else if (isColor) { } else { vec = Vector3.zero; vec.x = EditorGUILayout.FloatField("From", item.from.x); if (vec.x != item.from.x) { Undo.RecordObject(tween, "Setting new from value"); item.from = vec; } } } EditorGUILayout.EndHorizontal(); // To Values EditorGUILayout.BeginHorizontal(); if (isVector) { EditorGUILayout.LabelField(" To", GUILayout.Width(85)); change(ref item.to, EditorGUILayout.Vector3Field("", item.to), tween, "Changing vector3 to"); } else if (isColor) { EditorGUILayout.LabelField(" To", GUILayout.Width(85)); change(ref item.colorTo, EditorGUILayout.ColorField("", item.colorTo), tween, "Change color to"); } else if (isPlay) { GUILayout.Space(24); item.spritesMaximized = EditorGUILayout.Foldout(item.spritesMaximized, "Sprites"); if (item.spritesMaximized) { EditorGUILayout.LabelField("Add", GUILayout.Width(35)); UnityEngine.Sprite sprite = EditorGUILayout.ObjectField("", null, typeof(UnityEngine.Sprite), true, GUILayout.Width(150)) as UnityEngine.Sprite; if (sprite != null) { Undo.RecordObject(tween, "Adding a sprite"); item.sprites = add(item.sprites, sprite); } EditorGUILayout.Separator(); EditorGUILayout.Separator(); EditorGUILayout.Separator(); } } else { vec = Vector3.zero; EditorGUILayout.LabelField(" To", GUILayout.Width(85)); float setToX = EditorGUILayout.FloatField("", item.to.x); if (setToX != vec.x) { Undo.RecordObject(tween, "Setting x to"); vec.x = setToX; item.to = vec; } } EditorGUILayout.EndHorizontal(); // Sprite List if (isPlay && item.spritesMaximized) { for (int j = 0; j < item.sprites.Length; j++) { EditorGUILayout.BeginHorizontal(); EditorGUILayout.LabelField(" sprite" + j, GUILayout.Width(85)); item.sprites[j] = EditorGUILayout.ObjectField("", item.sprites[j], typeof(UnityEngine.Sprite), true) as UnityEngine.Sprite; GUI.color = LTEditor.shared.colorDelete; deleted = GUILayout.Button("Delete", LTEditor.shared.styleDeleteButton); GUI.color = Color.white; EditorGUILayout.EndHorizontal(); if (deleted) { Undo.RecordObject(tween, "Removing sprite"); item.sprites = remove(item.sprites, j); break; } } } if (a == TweenAction.ROTATE_AROUND || a == TweenAction.ROTATE_AROUND_LOCAL #if !UNITY_4_3 && !UNITY_4_5 || a == TweenAction.CANVAS_ROTATEAROUND || a == TweenAction.CANVAS_ROTATEAROUND_LOCAL #endif ) { item.axis = ShowAxis(" Axis", item.axis); } } EditorGUILayout.Space(); // Easing if (a == TweenAction.DELAYED_SOUND) { change(ref item.audioClip, EditorGUILayout.ObjectField(" AudioClip:", item.audioClip, typeof(AudioClip), true) as AudioClip, tween, "set audio clip"); } else { EditorGUILayout.BeginHorizontal(); EditorGUILayout.LabelField(" Easing", GUILayout.Width(80)); int easeIndex = LTVisualShared.easeIndex(item); int easeIndexNew = EditorGUILayout.Popup("", easeIndex, LTVisualShared.easeStrMapping, GUILayout.Width(128)); if (easeIndex != easeIndexNew) { Undo.RecordObject(tween, "changing easing type"); LTVisualShared.setEaseIndex(item, easeIndexNew); } EditorGUILayout.Separator(); EditorGUILayout.EndHorizontal(); if (item.ease == LeanTweenType.animationCurve) { Undo.RecordObject(tween, "changing easing type anim curve"); item.animationCurve = EditorGUILayout.CurveField(" Ease Curve", item.animationCurve); } EditorGUILayout.Space(); } if (item.ease >= LeanTweenType.once && item.ease < LeanTweenType.animationCurve) { EditorGUILayout.LabelField(new GUIContent(" ERROR: You Specified a non-easing type", "Select a type with the value 'Ease' in front of it (or linear)"), EditorStyles.boldLabel); } // Speed EditorGUILayout.BeginHorizontal(); change(ref item.useSpeed, EditorGUILayout.Toggle(" Use Speed", item.useSpeed), tween, "toggled use speed"); EditorGUILayout.EndHorizontal(); // Timing if (i > 0) { change(ref item.alignWithPrevious, EditorGUILayout.Toggle(new GUIContent(" Align with Previous", "When you change the timing of a previous tween, this tween's timing will be adjusted to follow afterwards."), item.alignWithPrevious), tween, "toggle align with previous"); } EditorGUILayout.BeginHorizontal(); if (i > 0 && item.alignWithPrevious) { change(ref item.delay, addedTweenDelay, tween, "change delay"); EditorGUILayout.LabelField(" Delay: " + item.delay, GUILayout.Width(50)); } else { EditorGUILayout.LabelField(" Delay", GUILayout.Width(50)); change(ref item.delay, EditorGUILayout.FloatField("", item.delay, GUILayout.Width(50)), tween, "change delay"); } if (a == TweenAction.DELAYED_SOUND) { EditorGUILayout.LabelField("Volume", GUILayout.Width(50)); change(ref item.duration, EditorGUILayout.FloatField("", item.duration, GUILayout.Width(50)), tween, "change volume"); } else if (a == TweenAction.CANVAS_PLAYSPRITE) { EditorGUILayout.LabelField("Frame Rate", GUILayout.Width(85)); change(ref item.frameRate, EditorGUILayout.FloatField("", item.frameRate, GUILayout.Width(50)), tween, "change volume"); } else if (item.useSpeed) { EditorGUILayout.LabelField("Speed", GUILayout.Width(50)); change(ref item.speed, EditorGUILayout.FloatField("", item.speed, GUILayout.Width(50)), tween, "change speed"); } else { EditorGUILayout.LabelField("Time", GUILayout.Width(50)); float newDuration = EditorGUILayout.FloatField("", item.duration, GUILayout.Width(50)); if (newDuration <= 0.0f) { newDuration = 0.0001f; } change(ref item.duration, newDuration, tween, "change timing"); } EditorGUILayout.Separator(); EditorGUILayout.EndHorizontal(); // Repeat EditorGUILayout.Space(); EditorGUILayout.BeginHorizontal(); EditorGUILayout.LabelField(" Loops", GUILayout.Width(50)); change(ref item.doesLoop, EditorGUILayout.Toggle("", item.doesLoop, GUILayout.Width(50)), tween, "toggled does loop"); if (item.doesLoop) { EditorGUILayout.LabelField(new GUIContent("Repeat", "-1 repeats infinitely"), GUILayout.Width(50)); change(ref item.loopCount, EditorGUILayout.IntField(new GUIContent("", ""), item.loopCount, GUILayout.Width(50)), tween, "changed loop count"); EditorGUILayout.LabelField(new GUIContent(" Wrap", "How the tween repeats\nclamp: restart from beginning\npingpong: goes back and forth"), GUILayout.Width(50)); int index = item.loopType == LeanTweenType.pingPong ? 1 : 0; index = EditorGUILayout.Popup("", index, new string[] { "Clamp", "Ping Pong" }, GUILayout.Width(70)); LeanTweenType newLoopType = index == 0 ? LeanTweenType.clamp : LeanTweenType.pingPong; if (newLoopType != item.loopType) { Undo.RecordObject(tween, "change loop type"); item.loopType = newLoopType; } } EditorGUILayout.EndHorizontal(); addedTweenDelay = item.duration + item.delay; EditorGUILayout.Separator(); EditorGUILayout.Separator(); i++; } } if (ShowLeftButton("+ Tween", LTEditor.shared.colorAddTween, 15)) { Undo.RecordObject(tween, "adding another tween"); LeanTweenItem newItem = new LeanTweenItem(addedTweenDelay); newItem.alignWithPrevious = true; group.itemList.Add(newItem); } addedGroupDelay += addedTweenDelay; EditorGUILayout.Separator(); } overallDelay += group.endTime; } if (ShowLeftButton("+ Group", LTEditor.shared.colorAddGroup)) { Undo.RecordObject(tween, "adding another group"); // Debug.Log("adding group with delay:"+addedGroupDelay); tween.groupList.Add(new LeanTweenGroup(addedGroupDelay)); } EditorGUILayout.Separator(); EditorGUILayout.Separator(); EditorGUILayout.LabelField("Generated C# Code", EditorStyles.boldLabel); if (Application.isPlaying == false) { scrollCodeViewPos = EditorGUILayout.BeginScrollView(scrollCodeViewPos, GUILayout.Height(150)); EditorGUILayout.TextArea(tween.buildAllTweens(true), LTEditor.shared.styleCodeTextArea); EditorGUILayout.EndScrollView(); } else { EditorGUILayout.LabelField(" Not available during runtime"); } if (EditorGUI.EndChangeCheck()) { // Debug.Log("Saving time:"+Time.time); //Undo.RecordObject(tween, "LeanTweenVisual change"); } }
public static void setEaseIndex(LeanTweenItem item, int newIndex) { item.ease = (LeanTweenType)LTVisualShared.easeIntMapping[newIndex]; item.easeStr = LTVisualShared.easeStrMapping[newIndex]; }
public static void setActionIndex(LeanTweenItem item, int newIndex) { item.action = (TweenAction)LTVisualShared.methodIntMapping[newIndex]; item.actionStr = LTVisualShared.methodStrMapping[newIndex]; }
public override void OnInspectorGUI() { GUI.DrawTexture( new Rect(16, EditorGUILayout.GetControlRect().y - 16, 16, 16), LTEditor.editorIcon() ); LeanTweenVisual tween = target as LeanTweenVisual; float overallDelay = 0; bool clicked, deleted; Vector3 vec; clicked = false; EditorGUILayout.BeginHorizontal(); tween.restartOnEnable = EditorGUILayout.Toggle(new GUIContent("Restart on enable","When you enable the gameobject these set of tweens will start again"), tween.restartOnEnable); tween.repeat = EditorGUILayout.Toggle(new GUIContent("Repeat All","Repeat the whole set of tween groups once they finish"), tween.repeat); EditorGUILayout.EndHorizontal(); if(tween.repeat){ tween.repeatDelay = EditorGUILayout.FloatField("All Delay", tween.repeatDelay); tween.repeatCount = EditorGUILayout.IntField("All Repeat Count", tween.repeatCount); } float addedGroupDelay = 0f; foreach(LeanTweenGroup group in tween.groupList) { EditorGUILayout.Space(); GUI.color = LTEditor.shared.colorGroupName; EditorGUILayout.BeginHorizontal(); group.foldout = EditorGUILayout.Foldout(group.foldout,"",LTEditor.shared.styleGroupFoldout); clicked = GUILayout.Button("Group: " + group.name + " " + (group.startTime ) + "s - " + (group.endTime ) + "s", LTEditor.shared.styleGroupButton); GUI.color = LTEditor.shared.colorDelete; deleted = GUILayout.Button("Delete", LTEditor.shared.styleDeleteGroupButton); EditorGUILayout.EndHorizontal(); GUI.color = Color.white; if(clicked) { group.foldout = !group.foldout; } if (deleted) { tween.groupList.Remove(group); break; } float addedTweenDelay = 0f; if(group.foldout) { group.name = EditorGUILayout.TextField("Group Name", group.name); EditorGUILayout.BeginHorizontal(); group.repeat = EditorGUILayout.Toggle("Group Repeat", group.repeat); group.delay = EditorGUILayout.FloatField("Group Delay", group.delay); EditorGUILayout.EndHorizontal(); if(group.repeat){ group.repeatCount = EditorGUILayout.IntField("Group Repeat Count", group.repeatCount); } int i = 0; foreach(LeanTweenItem item in group.itemList) { TweenAction a = (TweenAction)item.action; EditorGUILayout.BeginHorizontal(); GUILayout.Space(15); item.foldout = EditorGUILayout.Foldout(item.foldout,"Tween "); GUI.color = LTEditor.shared.colorTweenName; int actionIndex = EditorGUILayout.Popup( LTVisualShared.actionIndex(item) , LTVisualShared.methodLabels ); LTVisualShared.setActionIndex(item, actionIndex); // clicked = GUILayout.Button(""+a + " " + ( group.delay + item.delay) + "s - " + ( group.delay + item.delay + item.duration) + "s"); GUI.color = LTEditor.shared.colorDelete; deleted = GUILayout.Button("Delete", LTEditor.shared.styleDeleteButton); EditorGUILayout.EndHorizontal(); GUI.color = Color.white; if(clicked) { item.foldout = !item.foldout; } if (deleted) { group.itemList.Remove(item); break; } if(item.foldout) { a = item.action; bool tweenTypeChanged = (int)item.action != item.actionLast; if(tweenTypeChanged && item.actionLast>=0){ // Setup with the helpful default values // Debug.Log("Setting up to default values a:"+a); /*item.to = Vector3.zero; if((a>=TweenAction.MOVE_X && a<=TweenAction.MOVE_LOCAL_Z) || a==TweenAction.MOVE || a==TweenAction.MOVE_LOCAL) item.to = item.from = tween.gameObject.transform.position; else if((a>=TweenAction.SCALE_X && a<=TweenAction.SCALE_Z) || a==TweenAction.SCALE) item.to = item.from = tween.gameObject.transform.localScale; #if !UNITY_4_3 && !UNITY_4_5 else if(a==TweenAction.CANVAS_MOVE) item.to = item.from = tween.gameObject.GetComponent<RectTransform>().anchoredPosition; else if(a==TweenAction.CANVAS_SCALE) item.to = item.from = tween.gameObject.GetComponent<RectTransform>().localScale; #endif */ } item.actionLast = (int)item.action; // Debug.Log("a:"+a); // Path bool isCurve = false; if(a == TweenAction.MOVE_CURVED || a == TweenAction.MOVE_CURVED_LOCAL) { item.bezierPath = EditorGUILayout.ObjectField(" LeanTweenPath:",item.bezierPath, typeof(LeanTweenPath), true) as LeanTweenPath; EditorGUILayout.BeginHorizontal(); item.orientToPath = EditorGUILayout.Toggle(" Orient to Path", item.orientToPath); isCurve = true; item.isPath2d = EditorGUILayout.Toggle(" 2D Path", item.isPath2d); EditorGUILayout.EndHorizontal(); }else if(a == TweenAction.MOVE_SPLINE || a == TweenAction.MOVE_SPLINE_LOCAL) { item.splinePath = EditorGUILayout.ObjectField(" LeanTweenPath:",item.splinePath, typeof(LeanTweenPath), true) as LeanTweenPath; item.orientToPath = EditorGUILayout.Toggle(" Orient to Path", item.orientToPath); isCurve = true; } if(isCurve==false){ bool isVector = a == TweenAction.MOVE || a == TweenAction.MOVE_LOCAL || a == TweenAction.CANVAS_MOVE || a == TweenAction.ROTATE || a == TweenAction.ROTATE_LOCAL || a == TweenAction.SCALE || a == TweenAction.CANVAS_SCALE || a == TweenAction.DELAYED_SOUND; bool isColor = a >= TweenAction.COLOR && a < TweenAction.CALLBACK; bool isPlay = a == TweenAction.CANVAS_PLAYSPRITE; bool usesFrom = !isColor && !isPlay; // From Values EditorGUILayout.BeginHorizontal(); if(usesFrom){ // Not a Color tween EditorGUILayout.LabelField(new GUIContent(" From", "Specify where the tween starts from, otherwise it will start from it's current value"), GUILayout.Width(50)); item.between = EditorGUILayout.Toggle( "", item.between == LeanTweenBetween.FromTo, GUILayout.Width(30)) ? LeanTweenBetween.FromTo : LeanTweenBetween.To; } if(item.between == LeanTweenBetween.FromTo){ if(isVector) { item.from = EditorGUILayout.Vector3Field("", item.from); } else if(isColor) { } else { vec = Vector3.zero; vec.x = EditorGUILayout.FloatField("From", item.from.x); item.from = vec; } } EditorGUILayout.EndHorizontal(); // To Values EditorGUILayout.BeginHorizontal(); if(isVector) { EditorGUILayout.LabelField(" To", GUILayout.Width(85)); item.to = EditorGUILayout.Vector3Field("", item.to); } else if(isColor) { EditorGUILayout.LabelField(" To", GUILayout.Width(85)); item.colorTo = EditorGUILayout.ColorField("", item.colorTo); } else if(isPlay) { GUILayout.Space(24); item.spritesMaximized = EditorGUILayout.Foldout(item.spritesMaximized,"Sprites"); if(item.spritesMaximized){ EditorGUILayout.LabelField("Add", GUILayout.Width(35)); UnityEngine.Sprite sprite = EditorGUILayout.ObjectField("",null, typeof(UnityEngine.Sprite), true, GUILayout.Width(150)) as UnityEngine.Sprite; if(sprite!=null){ item.sprites = add(item.sprites, sprite); } EditorGUILayout.Separator(); EditorGUILayout.Separator(); EditorGUILayout.Separator(); } } else { vec = Vector3.zero; EditorGUILayout.LabelField(" To", GUILayout.Width(85)); vec.x = EditorGUILayout.FloatField("", item.to.x); item.to = vec; } EditorGUILayout.EndHorizontal(); // Sprite List if(isPlay && item.spritesMaximized) { for(int j = 0; j < item.sprites.Length; j++){ EditorGUILayout.BeginHorizontal(); EditorGUILayout.LabelField(" sprite"+j, GUILayout.Width(85)); item.sprites[j] = EditorGUILayout.ObjectField("",item.sprites[j], typeof(UnityEngine.Sprite), true) as UnityEngine.Sprite; GUI.color = LTEditor.shared.colorDelete; deleted = GUILayout.Button("Delete", LTEditor.shared.styleDeleteButton); GUI.color = Color.white; EditorGUILayout.EndHorizontal(); if(deleted){ item.sprites = remove(item.sprites, j); break; } } } if(a == TweenAction.ROTATE_AROUND || a == TweenAction.ROTATE_AROUND_LOCAL #if !UNITY_4_3 && !UNITY_4_5 || a == TweenAction.CANVAS_ROTATEAROUND || a == TweenAction.CANVAS_ROTATEAROUND_LOCAL #endif ) { item.axis = ShowAxis(" Axis", item.axis); } } EditorGUILayout.Space(); // Easing if(a == TweenAction.DELAYED_SOUND){ item.audioClip = EditorGUILayout.ObjectField(" AudioClip:",item.audioClip, typeof(AudioClip), true) as AudioClip; }else{ EditorGUILayout.BeginHorizontal(); EditorGUILayout.LabelField(" Easing", GUILayout.Width(80)); int easeIndex = LTVisualShared.easeIndex( item ); easeIndex = EditorGUILayout.Popup("", easeIndex, LTVisualShared.easeStrMapping, GUILayout.Width(128) ); LTVisualShared.setEaseIndex( item, easeIndex); EditorGUILayout.Separator(); EditorGUILayout.EndHorizontal(); if(item.ease==LeanTweenType.animationCurve){ item.animationCurve = EditorGUILayout.CurveField(" Ease Curve", item.animationCurve); } EditorGUILayout.Space(); } if(item.ease>=LeanTweenType.once && item.ease < LeanTweenType.animationCurve){ EditorGUILayout.LabelField( new GUIContent(" ERROR: You Specified a non-easing type", "Select a type with the value 'Ease' in front of it (or linear)"), EditorStyles.boldLabel ); } // Timing if(i>0) item.alignWithPrevious = EditorGUILayout.Toggle(new GUIContent(" Align with Previous","When you change the timing of a previous tween, this tween's timing will be adjusted to follow afterwards."), item.alignWithPrevious); EditorGUILayout.BeginHorizontal(); if(i>0 && item.alignWithPrevious){ item.delay = addedTweenDelay; EditorGUILayout.LabelField(" Delay: "+item.delay, GUILayout.Width(50)); }else{ EditorGUILayout.LabelField(" Delay", GUILayout.Width(50)); item.delay = EditorGUILayout.FloatField("", item.delay, GUILayout.Width(50)); } if(a == TweenAction.DELAYED_SOUND){ EditorGUILayout.LabelField("Volume", GUILayout.Width(50)); item.duration = EditorGUILayout.FloatField("", item.duration); }else if(a == TweenAction.CANVAS_PLAYSPRITE){ EditorGUILayout.LabelField("Frame Rate", GUILayout.Width(85)); item.frameRate = EditorGUILayout.FloatField("", item.frameRate); }else{ EditorGUILayout.LabelField("Time", GUILayout.Width(50)); item.duration = EditorGUILayout.FloatField("", item.duration, GUILayout.Width(50)); if(item.duration<=0.0f) item.duration = 0.0001f; } EditorGUILayout.Separator(); EditorGUILayout.EndHorizontal(); // Repeat EditorGUILayout.Space(); EditorGUILayout.BeginHorizontal(); EditorGUILayout.LabelField(" Loops", GUILayout.Width(50)); item.doesLoop = EditorGUILayout.Toggle("",item.doesLoop, GUILayout.Width(50)); if(item.doesLoop){ EditorGUILayout.LabelField(new GUIContent("Repeat","-1 repeats infinitely"), GUILayout.Width(50)); item.loopCount = EditorGUILayout.IntField(new GUIContent("",""),item.loopCount, GUILayout.Width(50)); EditorGUILayout.LabelField(new GUIContent(" Wrap","How the tween repeats\nclamp: restart from beginning\npingpong: goes back and forth"), GUILayout.Width(50)); int index = item.loopType==LeanTweenType.pingPong ? 1 : 0; index = EditorGUILayout.Popup("", index, new string[]{"Clamp","Ping Pong"}, GUILayout.Width(70)); item.loopType = index==0 ? LeanTweenType.clamp : LeanTweenType.pingPong; } EditorGUILayout.EndHorizontal(); addedTweenDelay = item.duration + item.delay; EditorGUILayout.Separator(); EditorGUILayout.Separator(); i++; } } if (ShowLeftButton("+ Tween", LTEditor.shared.colorAddTween, 15)) { LeanTweenItem newItem = new LeanTweenItem(addedTweenDelay); newItem.alignWithPrevious = true; group.itemList.Add(newItem); } addedGroupDelay += addedTweenDelay; EditorGUILayout.Separator(); } overallDelay += group.endTime; } if (ShowLeftButton("+ Group", LTEditor.shared.colorAddGroup)) { // Debug.Log("adding group with delay:"+addedGroupDelay); tween.groupList.Add(new LeanTweenGroup(addedGroupDelay)); } EditorGUILayout.Separator(); EditorGUILayout.Separator(); EditorGUILayout.LabelField("Generated C# Code", EditorStyles.boldLabel ); if(Application.isPlaying==false){ scrollCodeViewPos = EditorGUILayout.BeginScrollView(scrollCodeViewPos, GUILayout.Height(150) ); EditorGUILayout.TextArea( tween.buildAllTweens(true), LTEditor.shared.styleCodeTextArea ); EditorGUILayout.EndScrollView(); }else{ EditorGUILayout.LabelField(" Not available during runtime"); } }
public static void setEaseIndex( LeanTweenItem item, int newIndex){ item.ease = (LeanTweenType)LTVisualShared.easeIntMapping[ newIndex ]; item.easeStr = LTVisualShared.easeStrMapping[ newIndex ]; }
private void buildTween(LeanTweenItem item, float delayAdd, bool generateCode) { float delay = item.delay + delayAdd; bool code = generateCode; float d = item.duration; // Debug.Log("item:"+item.action); if (item.action == TweenAction.ALPHA) { tween = code ? append("alpha", item.to.x, d) : LeanTween.alpha(gameObject, item.to.x, d); } else if (item.action == TweenAction.ALPHA_VERTEX) { tween = code ? append("alphaVertex", item.to.x, d) : LeanTween.alphaVertex(gameObject, item.to.x, d); } else if (item.action == TweenAction.MOVE) { tween = code ? append("move", item.to, d) : LeanTween.move(gameObject, item.to, d); } else if (item.action == TweenAction.MOVE_LOCAL) { tween = code ? append("moveLocal", item.to, d) : LeanTween.moveLocal(gameObject, item.to, d); } else if (item.action == TweenAction.MOVE_LOCAL_X) { tween = code ? append("moveLocalX", item.to.x, d) : LeanTween.moveLocalX(gameObject, item.to.x, d); } else if (item.action == TweenAction.MOVE_LOCAL_Y) { tween = code ? append("moveLocalY", item.to.x, d) : LeanTween.moveLocalY(gameObject, item.to.x, d); } else if (item.action == TweenAction.MOVE_LOCAL_Z) { tween = code ? append("moveLocalZ", item.to.x, d) : LeanTween.moveLocalZ(gameObject, item.to.x, d); } else if (item.action == TweenAction.MOVE_X) { tween = code ? append("moveX", item.to.x, d) : LeanTween.moveX(gameObject, item.to.x, d); } else if (item.action == TweenAction.MOVE_Y) { tween = code ? append("moveY", item.to.x, d) : LeanTween.moveY(gameObject, item.to.x, d); } else if (item.action == TweenAction.MOVE_Z) { tween = code ? append("moveZ", item.to.x, d) : LeanTween.moveZ(gameObject, item.to.x, d); } else if (item.action == TweenAction.MOVE_CURVED) { tween = code ? append("move", item.bezierPath ? item.bezierPath.vec3 : null, d) : LeanTween.move(gameObject, item.bezierPath.vec3, d); if (item.orientToPath) { if (code) { codeBuild.Append(".setOrientToPath(" + item.orientToPath + ")"); } else { tween.setOrientToPath(item.orientToPath); } } if (item.isPath2d) { if (code) { codeBuild.Append(".setOrientToPath2d(true)"); } else { tween.setOrientToPath2d(item.isPath2d); } } } else if (item.action == TweenAction.MOVE_CURVED_LOCAL) { tween = code ? append("moveLocal", item.bezierPath ? item.bezierPath.vec3 : null, d) : LeanTween.moveLocal(gameObject, item.bezierPath.vec3, d); if (item.orientToPath) { if (code) { codeBuild.Append(".setOrientToPath(" + item.orientToPath + ")"); } else { tween.setOrientToPath(item.orientToPath); } } if (item.isPath2d) { if (code) { codeBuild.Append(".setOrientToPath2d(true)"); } else { tween.setOrientToPath2d(item.isPath2d); } } } else if (item.action == TweenAction.MOVE_SPLINE) { tween = code ? append("moveSpline", item.splinePath ? item.splinePath.splineVector() : null, d) : LeanTween.moveSpline(gameObject, item.splinePath.splineVector(), d); if (item.orientToPath) { if (code) { codeBuild.Append(".setOrientToPath(" + item.orientToPath + ")"); } else { tween.setOrientToPath(item.orientToPath); } } if (item.isPath2d) { if (code) { codeBuild.Append(".setOrientToPath2d(true)"); } else { tween.setOrientToPath2d(item.isPath2d); } } } else if (item.action == TweenAction.ROTATE) { tween = code ? append("rotate", item.to, d) : LeanTween.rotate(gameObject, item.to, d); } else if (item.action == TweenAction.ROTATE_AROUND) { if (generateCode) { codeBuild.Append(tabs + "LeanTween.rotateAround(gameObject, " + vecToStr(item.axis) + ", " + item.to.x + "f , " + d + "f)"); } else { tween = LeanTween.rotateAround(gameObject, item.axis, item.to.x, d); } } else if (item.action == TweenAction.ROTATE_AROUND_LOCAL) { if (generateCode) { codeBuild.Append(tabs + "LeanTween.rotateAroundLocal(gameObject, " + vecToStr(item.axis) + ", " + item.to.x + "f , " + d + "f)"); } else { tween = LeanTween.rotateAroundLocal(gameObject, item.axis, item.to.x, d); } } else if (item.action == TweenAction.ROTATE_LOCAL) { tween = code ? append("rotateLocal", item.to, d) : LeanTween.rotateLocal(gameObject, item.to, d); } else if (item.action == TweenAction.ROTATE_X) { tween = code ? append("rotateX", item.to.x, d) : LeanTween.rotateX(gameObject, item.to.x, d); } else if (item.action == TweenAction.ROTATE_Y) { tween = code ? append("rotateY", item.to.x, d) : LeanTween.rotateY(gameObject, item.to.x, d); } else if (item.action == TweenAction.ROTATE_Z) { tween = code ? append("rotateZ", item.to.x, d) : LeanTween.rotateZ(gameObject, item.to.x, d); } else if (item.action == TweenAction.SCALE) { tween = code ? append("scale", item.to, d) : LeanTween.scale(gameObject, item.to, d); } else if (item.action == TweenAction.SCALE_X) { tween = code ? append("scaleX", item.to.x, d) : LeanTween.scaleX(gameObject, item.to.x, d); } else if (item.action == TweenAction.SCALE_Y) { tween = code ? append("scaleY", item.to.x, d) : LeanTween.scaleY(gameObject, item.to.x, d); } else if (item.action == TweenAction.SCALE_Z) { tween = code ? append("scaleZ", item.to.x, d) : LeanTween.scaleZ(gameObject, item.to.x, d); } #if !UNITY_4_3 && !UNITY_4_5 else if (item.action == TweenAction.CANVAS_MOVE) { tween = code ? appendRect("move", item.to, d) : LeanTween.move(GetComponent <RectTransform>(), item.to, d); } else if (item.action == TweenAction.CANVAS_SCALE) { tween = code ? appendRect("scale", item.to, d) : LeanTween.scale(GetComponent <RectTransform>(), item.to, d); } else if (item.action == TweenAction.CANVAS_ROTATEAROUND) { if (generateCode) { codeBuild.Append(tabs + "LeanTween.rotateAround(rectTransform, " + vecToStr(item.axis) + ", " + item.to.x + "f , " + d + "f)"); } else { tween = LeanTween.rotateAround(GetComponent <RectTransform>(), item.axis, item.to.x, d); } } else if (item.action == TweenAction.CANVAS_ROTATEAROUND_LOCAL) { if (generateCode) { codeBuild.Append(tabs + "LeanTween.rotateAroundLocal(rectTransform, " + vecToStr(item.axis) + ", " + item.to.x + "f , " + d + "f)"); } else { tween = LeanTween.rotateAroundLocal(GetComponent <RectTransform>(), item.axis, item.to.x, d); } } else if (item.action == TweenAction.CANVAS_ALPHA) { tween = code ? appendRect("alpha", item.to.x, d) : LeanTween.alpha(GetComponent <RectTransform>(), item.to.x, d); } else if (item.action == TweenAction.CANVAS_COLOR) { tween = code ? appendRect("color", item.colorTo, d) : LeanTween.color(GetComponent <RectTransform>(), item.colorTo, d); } else if (item.action == TweenAction.TEXT_ALPHA) { tween = code ? appendRect("textAlpha", item.to.x, d) : LeanTween.textAlpha(GetComponent <RectTransform>(), item.to.x, d); } else if (item.action == TweenAction.TEXT_COLOR) { tween = code ? appendRect("textColor", item.colorTo, d) : LeanTween.textColor(GetComponent <RectTransform>(), item.colorTo, d); } else if (item.action == TweenAction.CANVAS_PLAYSPRITE) { if (generateCode) { codeBuild.Append(tabs + "LeanTween.play(rectTransform, sprites).setFrameRate(" + item.frameRate + "f)"); } else { tween = LeanTween.play(GetComponent <RectTransform>(), item.sprites).setFrameRate(item.frameRate); } } #endif else if (item.action == TweenAction.COLOR) { tween = code ? append("color", item.colorTo, d) : LeanTween.color(gameObject, item.colorTo, d); } else if (item.action == TweenAction.DELAYED_SOUND) { if (generateCode) { codeBuild.Append(tabs + "LeanTween.delayedSound(gameObject, passAudioClipHere, " + vecToStr(item.from) + ", " + d + "f)"); } else { tween = LeanTween.delayedSound(gameObject, item.audioClip, item.from, item.duration); } } else { tween = null; Debug.Log("The tween '" + item.action.ToString() + "' has not been implemented. info item:" + item); return; } // Append Extras if (generateCode) { if (delay > 0f) { codeBuild.Append(".setDelay(" + delay + "f)"); } } else { tween = tween.setDelay(delay); } if (item.ease == LeanTweenType.animationCurve) { if (generateCode) { codeBuild.Append(".setEase("); append(item.animationCurve); codeBuild.Append(")"); } else { tween.setEase(item.animationCurve); } } else { if (generateCode) { if (item.ease != LeanTweenType.linear) { codeBuild.Append(".setEase(LeanTweenType." + item.ease + ")"); } } else { tween.setEase(item.ease); } } // Debug.Log("curve:"+item.animationCurve+" item.ease:"+item.ease); if (item.between == LeanTweenBetween.FromTo) { if (generateCode) { codeBuild.Append(".setFrom(" + item.from + ")"); } else { tween.setFrom(item.from); } } if (item.doesLoop) { if (generateCode) { codeBuild.Append(".setRepeat(" + item.loopCount + ")"); } else { tween.setRepeat(item.loopCount); } if (item.loopType == LeanTweenType.pingPong) { if (generateCode) { codeBuild.Append(".setLoopPingPong()"); } else { tween.setLoopPingPong(); } } } if (generateCode) { codeBuild.Append(";\n"); } }
public static int easeIndex( LeanTweenItem item ){ if(item.easeStr.Length<=0){ // First Time setup item.easeStr = easeStrMapping[ (int)item.ease ]; if(item.ease==LeanTweenType.notUsed) item.easeStr = "linear"; } int easeIndex = -1; // easeIndex( item ) for(int j = 0; j < easeStrMapping.Length; j++){ if( item.easeStr == easeStrMapping[j] ){ easeIndex = j; // Debug.Log("found match easeIndex:"+easeIndex + " easeStrMapping[easeIndex]:"+easeStrMapping[easeIndex]); break; } } if(easeIndex<0) // nothing found set to intial easeIndex = 0; return easeIndex; }
public static void setActionIndex( LeanTweenItem item, int newIndex ){ item.action = (TweenAction)LTVisualShared.methodIntMapping[ newIndex ]; item.actionStr = LTVisualShared.methodStrMapping[ newIndex ]; }
public static int actionIndex( LeanTweenItem item ){ int actionIndex = -1; for(int j = 0; j < methodStrMapping.Length; j++){ if( item.actionStr == methodStrMapping[j] ){ actionIndex = j; // Debug.Log("found match actionIndex:"+actionIndex + " methodStrMapping[actionIndex]:"+methodStrMapping[actionIndex]); break; } } if(actionIndex<0) // nothing found set to intial actionIndex = 0; return actionIndex; }
private void buildTween(LeanTweenItem item, float delayAdd, bool generateCode){ float delay = item.delay + delayAdd; bool code = generateCode; float d = item.duration; // Debug.Log("item:"+item.action); if(item.action == TweenAction.ALPHA) { tween = code ? append("alpha", item.to.x, d) : LeanTween.alpha(gameObject, item.to.x, d); } else if(item.action == TweenAction.ALPHA_VERTEX) { tween = code ? append("alphaVertex", item.to.x, d) : LeanTween.alphaVertex(gameObject, item.to.x, d); } else if(item.action == TweenAction.MOVE) { tween = code ? append("move", item.to, d) : LeanTween.move(gameObject, item.to, d); } else if(item.action == TweenAction.MOVE_LOCAL) { tween = code ? append("moveLocal", item.to, d) : LeanTween.moveLocal(gameObject, item.to, d); } else if(item.action == TweenAction.MOVE_LOCAL_X) { tween = code ? append("moveLocalX", item.to.x, d) : LeanTween.moveLocalX(gameObject, item.to.x, d); } else if(item.action == TweenAction.MOVE_LOCAL_Y) { tween = code ? append("moveLocalY", item.to.x, d) : LeanTween.moveLocalY(gameObject, item.to.x, d); } else if(item.action == TweenAction.MOVE_LOCAL_Z) { tween = code ? append("moveLocalZ", item.to.x, d) : LeanTween.moveLocalZ(gameObject, item.to.x, d); } else if(item.action == TweenAction.MOVE_X) { tween = code ? append("moveX", item.to.x, d) : LeanTween.moveX(gameObject, item.to.x, d); } else if(item.action == TweenAction.MOVE_Y) { tween = code ? append("moveY", item.to.x, d) : LeanTween.moveY(gameObject, item.to.x, d); } else if(item.action == TweenAction.MOVE_Z) { tween = code ? append("moveZ", item.to.x, d) : LeanTween.moveZ(gameObject, item.to.x, d); } else if(item.action == TweenAction.MOVE_CURVED) { tween = code ? append("move", item.bezierPath ? item.bezierPath.vec3 : null, d) : LeanTween.move(gameObject, item.bezierPath.vec3, d); if(item.orientToPath){ if(code){ codeBuild.Append(".setOrientToPath("+item.orientToPath.ToString().ToLower()+")"); }else{ tween.setOrientToPath(item.orientToPath); } } if(item.isPath2d){ if(code){ codeBuild.Append(".setOrientToPath2d(true)"); }else{ tween.setOrientToPath2d(item.isPath2d); } } } else if(item.action == TweenAction.MOVE_CURVED_LOCAL) { tween = code ? append("moveLocal", item.bezierPath ? item.bezierPath.vec3 : null, d) : LeanTween.moveLocal(gameObject, item.bezierPath.vec3, d); if(item.orientToPath){ if(code){ codeBuild.Append(".setOrientToPath("+item.orientToPath+")"); }else{ tween.setOrientToPath(item.orientToPath); } } if(item.isPath2d){ if(code){ codeBuild.Append(".setOrientToPath2d(true)"); }else{ tween.setOrientToPath2d(item.isPath2d); } } } else if(item.action == TweenAction.MOVE_SPLINE) { tween = code ? append("moveSpline", item.splinePath ? item.splinePath.splineVector() : null, d) : LeanTween.moveSpline(gameObject, item.splinePath.splineVector(), d); if(item.orientToPath){ if(code){ codeBuild.Append(".setOrientToPath("+item.orientToPath+")"); }else{ tween.setOrientToPath(item.orientToPath); } } if(item.isPath2d){ if(code){ codeBuild.Append(".setOrientToPath2d(true)"); }else{ tween.setOrientToPath2d(item.isPath2d); } } } else if(item.action == TweenAction.ROTATE) { tween = code ? append("rotate", item.to, d) : LeanTween.rotate(gameObject, item.to, d); } else if(item.action == TweenAction.ROTATE_AROUND) { if(generateCode){ codeBuild.Append(tabs+"LeanTween.rotateAround(gameObject, "+vecToStr(item.axis)+", "+item.to.x+"f , "+d+"f)"); }else{ tween = LeanTween.rotateAround(gameObject, item.axis, item.to.x, d); } } else if(item.action == TweenAction.ROTATE_AROUND_LOCAL) { if(generateCode){ codeBuild.Append(tabs+"LeanTween.rotateAroundLocal(gameObject, "+vecToStr(item.axis)+", "+item.to.x+"f , "+d+"f)"); }else{ tween = LeanTween.rotateAroundLocal(gameObject, item.axis, item.to.x, d); } } else if(item.action == TweenAction.ROTATE_LOCAL) { tween = code ? append("rotateLocal", item.to, d) : LeanTween.rotateLocal(gameObject, item.to, d); } else if(item.action == TweenAction.ROTATE_X) { tween = code ? append("rotateX", item.to.x, d) : LeanTween.rotateX(gameObject, item.to.x, d); } else if(item.action == TweenAction.ROTATE_Y) { tween = code ? append("rotateY", item.to.x, d) : LeanTween.rotateY(gameObject, item.to.x, d); } else if(item.action == TweenAction.ROTATE_Z) { tween = code ? append("rotateZ", item.to.x, d) : LeanTween.rotateZ(gameObject, item.to.x, d); } else if(item.action == TweenAction.SCALE) { tween = code ? append("scale", item.to, d) : LeanTween.scale(gameObject, item.to, d); } else if(item.action == TweenAction.SCALE_X) { tween = code ? append("scaleX", item.to.x, d) : LeanTween.scaleX(gameObject, item.to.x, d); } else if(item.action == TweenAction.SCALE_Y) { tween = code ? append("scaleY", item.to.x, d) : LeanTween.scaleY(gameObject, item.to.x, d); } else if(item.action == TweenAction.SCALE_Z) { tween = code ? append("scaleZ", item.to.x, d) : LeanTween.scaleZ(gameObject, item.to.x, d); } #if !UNITY_4_3 && !UNITY_4_5 else if(item.action == TweenAction.CANVAS_MOVE) { tween = code ? appendRect("move", item.to, d) : LeanTween.move(GetComponent<RectTransform>(), item.to, d); } else if(item.action == TweenAction.CANVAS_SCALE) { tween = code ? appendRect("scale", item.to, d) : LeanTween.scale(GetComponent<RectTransform>(), item.to, d); } else if(item.action == TweenAction.CANVAS_ROTATEAROUND) { if(generateCode){ codeBuild.Append(tabs+"LeanTween.rotateAround(GetComponent<RectTransform>(), "+vecToStr(item.axis)+", "+item.to.x+"f , "+d+"f)"); }else{ tween = LeanTween.rotateAround(GetComponent<RectTransform>(), item.axis, item.to.x, d); } } else if(item.action == TweenAction.CANVAS_ROTATEAROUND_LOCAL) { if(generateCode){ codeBuild.Append(tabs+"LeanTween.rotateAroundLocal(GetComponent<RectTransform>(), "+vecToStr(item.axis)+", "+item.to.x+"f , "+d+"f)"); }else{ tween = LeanTween.rotateAroundLocal(GetComponent<RectTransform>(), item.axis, item.to.x, d); } } else if(item.action == TweenAction.CANVAS_ALPHA) { tween = code ? appendRect("alpha", item.to.x, d) : LeanTween.alpha(GetComponent<RectTransform>(), item.to.x, d); } else if(item.action == TweenAction.CANVAS_COLOR) { tween = code ? appendRect("color", item.colorTo, d) : LeanTween.color(GetComponent<RectTransform>(), item.colorTo, d); } else if(item.action == TweenAction.TEXT_ALPHA) { tween = code ? appendRect("textAlpha", item.to.x, d) : LeanTween.textAlpha(GetComponent<RectTransform>(), item.to.x, d); } else if(item.action == TweenAction.TEXT_COLOR) { tween = code ? appendRect("textColor", item.colorTo, d) : LeanTween.textColor(GetComponent<RectTransform>(), item.colorTo, d); }else if(item.action == TweenAction.CANVAS_PLAYSPRITE){ if(generateCode){ codeBuild.Append(tabs+"LeanTween.play(GetComponent<RectTransform>(), new UnityEngine.Sprite["+item.sprites.Length+"]).setFrameRate("+item.frameRate+"f)"); }else{ tween = LeanTween.play(GetComponent<RectTransform>(), item.sprites).setFrameRate(item.frameRate); } } #endif else if(item.action == TweenAction.COLOR) { tween = code ? append("color", item.colorTo, d) : LeanTween.color(gameObject, item.colorTo, d); } else if(item.action == TweenAction.DELAYED_SOUND) { if(generateCode){ codeBuild.Append(tabs+"LeanTween.delayedSound(gameObject, passAudioClipHere, "+vecToStr(item.from)+", "+d+"f)"); }else{ tween = LeanTween.delayedSound(gameObject, item.audioClip, item.from, item.duration); } } else { tween = null; Debug.Log("The tween '" + item.action.ToString() + "' has not been implemented. info item:"+item); return; } // Append Extras if(generateCode){ if(delay>0f) codeBuild.Append(".setDelay("+delay+"f)"); }else{ tween = tween.setDelay(delay); } if(item.ease == LeanTweenType.animationCurve){ if(generateCode){ codeBuild.Append(".setEase("); append( item.animationCurve ); codeBuild.Append(")"); }else{ tween.setEase(item.animationCurve); } }else{ if(generateCode){ if(item.ease!=LeanTweenType.linear) codeBuild.Append(".setEase(LeanTweenType."+item.ease+")"); }else{ tween.setEase(item.ease); } } // Debug.Log("curve:"+item.animationCurve+" item.ease:"+item.ease); if(item.between == LeanTweenBetween.FromTo) { if(generateCode) codeBuild.Append(".setFrom("+vecToStr(item.from)+")"); else tween.setFrom(item.from); } if(item.doesLoop){ if(generateCode) codeBuild.Append(".setRepeat("+item.loopCount+")"); else tween.setRepeat(item.loopCount); if(item.loopType==LeanTweenType.pingPong){ if(generateCode) codeBuild.Append(".setLoopPingPong()"); else tween.setLoopPingPong(); } } if(generateCode) codeBuild.Append(";\n"); }