Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

LeanTween - A tweening engine that is up to 5x faster than competing engines!

Discussion in 'Assets and Asset Store' started by dentedpixel, Dec 3, 2012.

  1. EmeralLotus

    EmeralLotus

    Joined:
    Aug 10, 2012
    Posts:
    1,459
    I think you've Nailed it !!

    https://www.dropbox.com/sh/ana46qk0ympfzqb/k0tZ2gCQgN

    I just exported one of the examples in the zipped file and it's working.

    For some reason, some of the other example files in the zipped file are missing scripts or assets and not working even in the editor. Perhaps you can give me another zipped file with all of the examples working and I can test all of them.

    btw, what changes did you make to make this the ONLY officially working tween engine that works on Flash.
     
  2. dentedpixel

    dentedpixel

    Joined:
    Jul 15, 2012
    Posts:
    683
    Fantastic! I just reformatted any Hashtable that was in the format:
    PHP:
    LeanTween.rotategameObjectVector3(90,90,320), 1.0, {"ease":LeanTweenType.punch"onComplete":punchTest});
    To something a little more verbose, like:

    PHP:
    var hash:Hashtable = new Hashtable();
        
    hash.Add("ease"LeanTweenType.punch);
        
    hash.Add("onComplete"punchTest);
        
    LeanTween.rotateZgameObject3201.0hash);
    You are getting missing objects because I removed those other scripts, but you should be able to port them over, if you just follow the same procedure. I will work on getting this updated soon and resubmitted to the Asset Store :)

    Thanks again for your help!
     
  3. EmeralLotus

    EmeralLotus

    Joined:
    Aug 10, 2012
    Posts:
    1,459
    Super Cool,

    You didn't make any changes to LeanTween.cs ? the reason I ask is I had to copy over the new LeanTween.cs from the zipped file to the old LeanTween 3.5 project in order for it to work.
     
  4. dentedpixel

    dentedpixel

    Joined:
    Jul 15, 2012
    Posts:
    683
    I did not, I guess it must work with the C Sharp version as is (after you modify the example classes that call LeanTween).

    Could you tell me the error you get with LeanTween.js so I can get that version working as well? Thanks!
     
  5. EmeralLotus

    EmeralLotus

    Joined:
    Aug 10, 2012
    Posts:
    1,459
    I did the following test:

    1. Start with a fresh LeanTween project example 3.5
    2. deleted all examples except for the examplePunch scene.
    3. Replaced examplePunch.js with the one from the your LeanTweenFlash
    4. Export but got errors, complaining about the hash in LeanTween.cs
    5. Deleted entire LeanTween Plugin folder
    6. Copied over the LeanTween Plugin folder from LeanTweenFlash zip
    7. Works.

    8. Deleted entire LeanTween Plugin folder
    9. Imported LeanTween from Unity Asset Store.
    10. Same errors.

    11. Deleted entire LeanTween Plugin folder
    12. Copied over the LeanTween Plugin folder from LeanTweenFlash zip
    13. Works.
     
  6. dentedpixel

    dentedpixel

    Joined:
    Jul 15, 2012
    Posts:
    683
    Very strange, well I guess the important part is that it works. I will do a difference tonight to see what changes it could have been (I didn't think I changed anything in that file, but who knows).

    Could you send me a screenshot of the exact errors with the LeanTween.js file? I would like to get that working as well...

    Thanks!
     
  7. dentedpixel

    dentedpixel

    Joined:
    Jul 15, 2012
    Posts:
    683
    I just did a difference between the three versions of LeanTween.cs that you mentioned and all of them were identical. So I think some other factor may be at play here...

    Regardless I am glad it is working now just to get the LeanTween.js version to work and I will resubmit it, to the Asset Store.
     
  8. EmeralLotus

    EmeralLotus

    Joined:
    Aug 10, 2012
    Posts:
    1,459
  9. SteveJ

    SteveJ

    Joined:
    Mar 26, 2010
    Posts:
    3,085
    I'm having some problems with punch. It seems to ignore the vector information it's given. For example:


    Code (csharp):
    1.  
    2. Hashtable tweenOptions = new Hashtable();
    3. tweenOptions.Add("ease",LeanTweenType.punch);        
    4. LeanTween.moveY(gameObject, -0.1f, 2.0f, tweenOptions);
    5.  

    Regardless of the float value (-0.1f in the example code), it always moves the same distance.
     
  10. SteveJ

    SteveJ

    Joined:
    Mar 26, 2010
    Posts:
    3,085
    Also, something that works like iTween's RotateAdd function would be great.
     
  11. dentedpixel

    dentedpixel

    Joined:
    Jul 15, 2012
    Posts:
    683
    It seems like you might be using an older version of the LeanTween.js file, since those are errors that I fixed.

    I have had success getting it to compile with Unity 3.5 Preview version of Flash! You can see the results here:

    https://dl.dropbox.com/u/10227043/LeanTween/PunchExample.html

    Also here is the code that I used:
    https://www.dropbox.com/s/bh4qgbzo0w6r8se/LeanTweenFlash.zip

    I assume if it works in the earlier version of the Flash builder it will work in Unity 4.0 as well...
     
  12. dentedpixel

    dentedpixel

    Joined:
    Jul 15, 2012
    Posts:
    683
    Thanks for bringing this to my attention SteveJ, you are right it seems to be moving the same distance regardless. I am looking into this now...
     
  13. EmeralLotus

    EmeralLotus

    Joined:
    Aug 10, 2012
    Posts:
    1,459
    I spoke to SWS (simple waypoint system) about including LeanTween as an additional tweening library and he said that he doesn't know enough LeanTween. Perhaps someone knows how to get LeanTween working with SWS. The integration will aide in the adoption of LeanTween because SWS and Playmaker are being used by many developers.
     
  14. dentedpixel

    dentedpixel

    Joined:
    Jul 15, 2012
    Posts:
    683
    That's a good idea Rocki, I don't know enough about either unfortunately. I did reach out to the authors of Playmaker awhile ago but I never heard back from them.

    Did that new version work for you with the Flash Builder in Unity 4.0? I am planning on resubmitting this new version to the Asset Store soon...
     
  15. Alex-Chouls

    Alex-Chouls

    Joined:
    Mar 24, 2009
    Posts:
    2,651
    Hi, I must have missed your email somehow - sorry! We'd love to see Lean Tween actions!

    Most third party developers make their own Playmaker actions since they're pretty easy to write, but we're happy to help :)

    And of course we'll help promote the integration. We find that this kind of cross promotion works quite well...
     
    Last edited: Apr 5, 2013
  16. dentedpixel

    dentedpixel

    Joined:
    Jul 15, 2012
    Posts:
    683
    No worries Alex. That's great, I didn't realize one could write their own Play Maker actions, I will definitely look into that for the next release.

    Of course if anybody more familiar with Playmaker could help me write some actions, that would also be a big help.
     
    Last edited: Apr 5, 2013
  17. EmeralLotus

    EmeralLotus

    Joined:
    Aug 10, 2012
    Posts:
    1,459
    Yes the JS version of LeanTween.js in the TweenFlash.zip worked great on Flash unity 4.1.2

    What I was trying to say is that the LeanTween.CS in the same TweenFlash.zip version was giving errors. This is what I did
    I unzipped LeanTween.cs version, deleted the LeanTween.js version. When I tried to export, I got this. https://dl.dropbox.com/u/48378123/LeantweenCSerror.tiff
     
  18. dentedpixel

    dentedpixel

    Joined:
    Jul 15, 2012
    Posts:
    683
    Oh great, I am glad the Javascript version is working for you at least. I didn't do the port to the C# version, so I am a little unfamiliar with it, but it seems to be failing on some code that tries to retrieve a reference to a function in the c

    PHP:
    Type t Type.GetType("LeanTween");
    //MethodInfo method = t.GetMethod(tweenFunc);
    val = (float)t.InvokeMember(tweenFuncBindingFlags.InvokeMethod BindingFlags.Public | BindingFlags.Static, nullnull, new object[] { tween.from.xtween.to.xratioPassed });
    That's some crazy code! :) I'll reach out to the author of this code to see if he can aid in making in "Flash friendly." Or if anyone other C# experts have any ideas, I would appreciate it.
     
  19. dentedpixel

    dentedpixel

    Joined:
    Jul 15, 2012
    Posts:
    683
    Hi Steve, I fixed the issue you were having. A new version should be up in the Asset Store soon, but if you can't wait until then you can get the latest on Github: https://github.com/dentedpixel/LeanTween/tree/master/Assets/Plugins
     
  20. EmeralLotus

    EmeralLotus

    Joined:
    Aug 10, 2012
    Posts:
    1,459
    Yep, this is definitely Crazy code.

    If this C# code cannot be changed to not use Reflection then another possible solution is to use the LeanTween.js version when exporting to Flash and LeanTween.cs for other platforms.

    For those who are interested, here is a successful LeanTween project with only the C# examples using LeanTween.js that exports to Flash.
    https://dl.dropbox.com/u/48378123/LeanTweenFlashFixed.zip

    More importantly, there are many other projects that are having problems exporting to Flash because they are using C# and Reflection. By converting the section of CS code into JS, it might also fix the problem.
     
  21. dentedpixel

    dentedpixel

    Joined:
    Jul 15, 2012
    Posts:
    683
    Looks good Rocki! Just a note about the LeanTween.cs version, this version is only necessary for people who use Visual Studio and C#. Evidently people will compile their reusable code into a DLL file, and you can only do this if all your assets are also in C# (I can't say the exact process since I don't use Visual Studio myself).

    Otherwise everyone should be able to use the LeanTween.js file for both C# and Javascript projects.
     
  22. Demigiant

    Demigiant

    Joined:
    Jan 27, 2011
    Posts:
    3,239
    Hey dentedpixel! Rocki just wrote me about the JS version working in Flash, so I came here to check it out. Just as a heads up, that C# code that is causing issues seems quite weird, and could probably be changed so that it completely avoids Reflection (by using a Func type for tweenFunc, instead than a string - or better, by creating a personalized Func delegate, since I'm almost sure Func is not supported in mscorlib), so that even the C# version will work with Flash ;)
     
    Last edited: Apr 6, 2013
  23. dentedpixel

    dentedpixel

    Joined:
    Jul 15, 2012
    Posts:
    683
    Hey Izitmee! Cross tweening library collaboration I love it :) That is a good suggestion, I think that could solve the problem. I'll give it a try right now...

    Thanks!
     
  24. Demigiant

    Demigiant

    Joined:
    Jan 27, 2011
    Posts:
    3,239
    Eheh, tweenhighfive! :D
     
  25. EmeralLotus

    EmeralLotus

    Joined:
    Aug 10, 2012
    Posts:
    1,459
    This is True Tween Power.

    You Two Tween Guys Rock and Roll.
     
  26. BTStone

    BTStone

    Joined:
    Mar 10, 2012
    Posts:
    1,422
    You guys should hook up and create he one and only Tweening-Solution :D
     
  27. dentedpixel

    dentedpixel

    Joined:
    Jul 15, 2012
    Posts:
    683
    Okay! Now both LeanTween.cs and LeanTween.js are Flash export compatible (at least in Unity 3.5, it should be the same in higher versions). You can get the latest at Github: https://github.com/dentedpixel/LeanTween . I am going to resubmit the package to Unity Asset Store, so it should also be live in a couple of days...

    Thanks everyone for all their help to get this library Flash compatible!
     
  28. dentedpixel

    dentedpixel

    Joined:
    Jul 15, 2012
    Posts:
    683
    Here is a full demo of LeanTween running in Flash, all of LeanTween's features are supported.

    View attachment 50247

    There has also been an update to make it easier for C# users to pass optional parameters (and to make it easier to provide Flash compatibility in Javascript).

    No longer do you have to construct a hash table before calling the tween (which can often take up many lines of code and cause unnecessary line bloat), you can now just pass an array to the optional parameter like:

    PHP:
    LeanTween.moveX(10f1.0f, new object[]{"ease"LeanTweenType.easeInOutCirc} );
    You can also do the same in Javascript (which makes it compatible with Flash Publishing), like:

    PHP:
    LeanTween.moveX(10f1.0f, ["ease"LeanTweenType.easeInOutCirc] );
    You can see more examples at the documentation page.
     
  29. dentedpixel

    dentedpixel

    Joined:
    Jul 15, 2012
    Posts:
    683
    Warning: There is a bug with the current version in the Asset Store, that causes LeanTween.delayedCall, and LeanTween.value to not always being called.

    I have submitted a new version to the Unity Asset Store that fixes this, but until they approve it you can get the latest on GitHub: https://github.com/dentedpixel/LeanTween

    Sorry about that!
     
  30. dentedpixel

    dentedpixel

    Joined:
    Jul 15, 2012
    Posts:
    683
    Nice! Fastest turnaround ever from the Asset Store. The new bug-free version is up in the Asset Store (well bug-free as far as I know).
     
  31. AbgaryanFX

    AbgaryanFX

    Joined:
    Jan 9, 2010
    Posts:
    167
    is there way to compare versions ? :)
     
  32. dentedpixel

    dentedpixel

    Joined:
    Jul 15, 2012
    Posts:
    683
    I am sorry do you mean compare different versions of LeanTween or compare LeanTween to different animation engines?

    I did a comparison between the different engines (iTween, HOTween and LeanTween) awhile back, if you are looking to compare the different engines speed.
     
  33. AbgaryanFX

    AbgaryanFX

    Joined:
    Jan 9, 2010
    Posts:
    167
    I mean how can I find the version info(number) to check if leantween in my current project is latest or not
     
  34. BTStone

    BTStone

    Joined:
    Mar 10, 2012
    Posts:
    1,422
    Is it possible to tween an object directly to another object? :)
     
  35. dentedpixel

    dentedpixel

    Joined:
    Jul 15, 2012
    Posts:
    683
    Sorry I don't have the version number listed in the code (I should start doing that). You should just update to the latest, that's really the only way you will know...
     
  36. dentedpixel

    dentedpixel

    Joined:
    Jul 15, 2012
    Posts:
    683
  37. dentedpixel

    dentedpixel

    Joined:
    Jul 15, 2012
    Posts:
    683
    LeanTween now supports the ability to rotate and fade gui elements. This can be accomplished with remarkably little code compared to other solutions out there.

    Javascript example of fading a button on click:
    PHP:
    if(GUI.Button(buttonRect.rect“Alpha”))
     
    LeanTween.alphabuttonRect0.01.0, [] );
    GUI.color.1.0// Reset to normal alpha
    $PressToPlay.png

    Download examples and see fading and rotating a GUI button in action here.
     
  38. AbgaryanFX

    AbgaryanFX

    Joined:
    Jan 9, 2010
    Posts:
    167
    and the other question :)

    http://clip2net.com/s/4ZQm7y

    Why your* script not removing these gameobjects, are they necessary ?
     
    Last edited: May 1, 2013
  39. dentedpixel

    dentedpixel

    Joined:
    Jul 15, 2012
    Posts:
    683
    Well there shouldn't be two "~LeanTween" objects.... but yes, one of them is necessary to perform the required functions. It shouldn't get in the way though, and it is not visible or apparent to the end user.

    I'd be curious to see how you got two ~LeanTween objects to show up...
     
  40. AbgaryanFX

    AbgaryanFX

    Joined:
    Jan 9, 2010
    Posts:
    167
  41. dentedpixel

    dentedpixel

    Joined:
    Jul 15, 2012
    Posts:
    683
    Oh awesome, I never knew about those hide flags. Thanks for the tip. I will implement that. But I am still super curious as to how you have managed to get multiple ~LeanTween's to show up. Could you send over a code sample? This should be fixed as well... there should only ever be one.
     
  42. DannyB

    DannyB

    Joined:
    Jun 20, 2012
    Posts:
    214
    Hey,

    This is a great alternative to iTween (no disrespect to this great "mother of unity tweening" plugin).
    I do love iTween, but for some reason, I always find myself using something else... maybe its this AddComponent spikes business that I don't like.

    But, I really wish it was more C# friendly. Currently, after removing the JS file and using the C# one, I am getting some warnings about unused variables and "assigned but not used" variables. I guess I can fix it on my own, but I really don't like poking around someone else's work

    Is there an updated (newer than asset store) version?

    In any case, I want to say thanks for providing a promising tweening library.
     
  43. AbgaryanFX

    AbgaryanFX

    Joined:
    Jan 9, 2010
    Posts:
    167
    Add this line to your code and check why GO doesn't removed from hierarchy after stop playing in editor. I'm using c# version.
    http://clip2net.com/s/51zH6k
     
  44. dentedpixel

    dentedpixel

    Joined:
    Jul 15, 2012
    Posts:
    683
    Thanks DannyB, you can disrespect iTween a little right? No code can be that sacred ;).

    Have you tried just using the Javascript version with your C# code? It should work perfectly well, the only reason I include a C# version is that some people compile their code to DLL's in Visual Studio (which evidently doesn't work when you have Javascript code).

    The C# version is a bit behind the Javascript version, it is a lot of work to keep up both, but I hope to get them both on the same page soon (but like I said 90% of the time you should be able to use the Javascript version).
     
  45. dentedpixel

    dentedpixel

    Joined:
    Jul 15, 2012
    Posts:
    683
    Thanks Artyom, I will add that. But I am still worried why it is showing up twice at all, that is a bug, and I would like to fix it. If you could share any code that reproduces this I would appreciate it...
     
  46. DannyB

    DannyB

    Joined:
    Jun 20, 2012
    Posts:
    214
    Heh... :)

    I have tried with the JS version, don't remember what I didn't like about it.
    In general I lean towards avoiding putting JS plugins in my otherwise C# project...

    I realize maintaining both is a pain though, but perhaps change strategy to "C# first"?
    As I understand the Unity ecosystem, JS is mostly used for people who just try it out for the first couple of months, and then a good percentage of them switch to C#, but I may be wrong.
     
  47. DanielQuick

    DanielQuick

    Joined:
    Dec 31, 2010
    Posts:
    3,137
    There's no reason for you to be worried about which language plugins are written in as long as you place them in your plugins folder (so they're compiled first). JavaScript is used by many, not just beginners.

    @dentedpixel Fantastic work, I'm using LeanTween in my current project.
     
  48. dentedpixel

    dentedpixel

    Joined:
    Jul 15, 2012
    Posts:
    683
    Thanks @DanielQuick. I totally agree, I know it's a topic of much heated debate (C# versus Javascript), but I certainly prefer Javascript myself, it can be much faster to write and you can make it just as efficient if not more (if you know what you are doing). Not that there aren't some awesome C# coders out there. I think the best argument I have heard for it, is that you can tap into some of the charms of the Visual Studio platform, when using C#.
     
  49. DannyB

    DannyB

    Joined:
    Jun 20, 2012
    Posts:
    214
    Wait.... Visual Studio has charms?
     
  50. dentedpixel

    dentedpixel

    Joined:
    Jul 15, 2012
    Posts:
    683
    Lol, well I have heard people talk favorably of it, I haven't been persuaded that is worth running a virtual machine (I am on a Mac), but others have found it worthwhile.