Giter Site home page Giter Site logo

leantween's People

Contributors

00christian00 avatar bncastle avatar dentedpixel avatar dyddye avatar housei avatar paulis avatar scorr avatar shinriyo avatar sjvc avatar tinyruss avatar wired avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

leantween's Issues

setLoopPingPong generates garbage

I tried to replace iTween with LeanTween to avoid garbage. Sadly the loop functions of LeanTween (setLoopPingPong() etc.) produce the same amount of garbage as iTween... :/

SceneManager.onSceneLoaded does not exist in Unity5.3

The bit of code below found in LeanTween.cs (line 1382) produces a compile error in Unity 5.3 because the field being referenced does not exist. Looks like it was added in 5.4 not 5.3. Actually the 5.4b documentation on Unity's site shows the event as being SceneManager.sceneLoaded.

#if UNITY_5_3_OR_NEWER
    SceneManager.onSceneLoaded += internalOnLevelWasLoaded;
#endif

Sequence function

Will you add the sequence function?
Other tween tool always have the function.
I hope the function, or do you have already added?

LeanTween.alpha on TextMesh?

Hello,

Unfortunately the LeanTween.alpha on TextMesh doesn't work.

Can you modify your lib to enable alpha on TextMesh.color ?

Thanks.

Tween initial value set with setFrom method is not set during the frame the tween is created

The issue is that when a tween is applied on an object in his Start method (or just after it has been Instantiated) and if this tween gets his "setFrom" method called with a value that is not the current value on the object, there is a frame at which object has not the correct property value (initial prefab value instead of the tween "from" value).

Interestingly, during the frame the editor play button in pressed, If a tween is created during the Start or Awake method on an object, LeanTween.update gets called during this frame and thus the issue does not happen in this particular case.

Cancelling tweens fails after uniqueId int overflow

Hi,

The int overflow issue we've seen is still happening and i've now narrowed down the cause some more.

The issue is not that global_counter overflows but it's related to the uniqueId overflowing. It looks like that once uniqueId is over the max value for an int, cancelling a tween doesn't work, then you can easily get into a state where all the tween spaces get used up, causing an exception.

This takes about 2 hours for the installation we have, but i've made an example that does it in less than 30 seconds.

https://www.dropbox.com/s/rdboozemkzrsvrg/LeanTweenTest.zip?dl=0

In this, i've altered LeanTween.cs slightly. I've just made some of the static vars public and added a new public static var for the last generated uniqueId so it's easier to see what's going on. Once the uniqueId flips back into minus numbers you should see the exception shortly afterwards.

Thanks,
Pascal.

Expose interpolation functions via a static utility class?

Would it be feasible to expose the static interpolation functions (i.e. LeanTween.easeInOutCubic) that are currently private so that they can be used directly when desired?

Since these functions are already defined it would be very convenient if they were exposed such as LeanTweenFunctions.EaseInOutCubic.

Many thanks!

not call oncomplete on start

Hi, it seems that the latest version 2.25 and even earlier version 2.24 has the bug that does not call oncomplete on start

when I use like this for example :

Code (CSharp):
LeanTween.moveLocalX(gameObject, 5, 5).setOnComplete(Complete).setOnCompleteOnStart(true);

or

LeanTween.moveLocalX(gameObject, 5, 5).setOnComplete( () => {
Debug.Log("on complete move local X");
}).setOnCompleteOnStart(true);

OnUpdate callback with percentage

Hello.

I like to know, as a percentage, how "done" a tween is. What would be the easiest way to get this value? Specifically for a tween using .moveSpline()?

Thanks for any pointers or hints.
J

int overflow caused by global_counter

If you have a lot of tweens and run for a while, global_counter will eventually hit the max int value. When it does, removeTween stops working, the spaces in the tweens array don't get released and you very quickly run out of spaces leading to a NullReferenceException.

Can you fix so this doesn't happen?

How to fade a MeshRenderer?

Hello,

When I try to fade out a Mesh Rederer I got this error message:
Material doesn't have a color property '_Color'
UnityEngine.Material:get_color()
LeanTween:update() (at Assets/Plugins/LeanTween/LeanTween.cs:1456)
LeanTween:Update() (at Assets/Plugins/LeanTween/LeanTween.cs:1348)

Here my code:
LeanTween.alpha (gameObject, 0f, 1f).setLoopType (LeanTweenType.pingPong);

And a screenshot of my game object components

screenshot_1

Thanks.

Sphere Routing

What is the tween to work on the sphere when there is a position on the sphere surface, let say point A, to another sphere surface point B. What is the quick easy way to get the tween easing done?

Some tweens randomly will not be scheduled

Hey again dented,

So... we have instances where scheduled TweenAlpha calls will not schedule tweens properly. The reproduction case is relatively complicated in our app and I'm not sure what is happening that makes this issue happen, so I'm sorry this report isn't very detailed heh.

The basic overview is that it seems like, after a certain sequence of tweens is played in our certain other tweens stop behaving properly. Specifically, a call to LeanTween.alphaText just does not do anything at randoms after playing a lot of tweens in our game. There are no exceptions, and no errors to accompany it, so I'm not sure why it's failing.

I've emailed you a video which should make this issue clearer. I'd prefer not to make this public, as it shows a little bit of the innards of a project we've have out on the App Store, but please feel free to contact me via email if you need more details.

Color tweening allocate memory at runtime

Hi,
I noticed you now use the GetComponent inside the update method when doing a color tween.
I don't think it was there before. The getcomponent it's slow and allocate memory so it shouldn't be there, it should be cached at tween start. I am talking of this code at line 655:
`#if !UNITY_3_5 && !UNITY_4_0 && !UNITY_4_0_1 && !UNITY_4_1 && !UNITY_4_2
SpriteRenderer ren = trans.gameObject.GetComponent();
if(ren!=null){
ren.color = toColor;
colorRecursiveSprite( trans, toColor);
}else

endif`

Also the conditional compilation is wrong as it include one extra bracket.

C# LeanTween.delayedCall and emptyHash

First off - thank you for putting LeanTween out there!

I found one issue with the d0f4021 commit regarding delayedCall. I got this error message after updating my LeanTween.cs file:

BroadcastMessage play has no receiver!
UnityEngine.GameObject:BroadcastMessage(String)
LeanTween:update() (at Assets/Plugins/LeanTween.cs:948)
LeanTween:Update() (at Assets/Plugins/LeanTween.cs:504)

Changing the return of the function starting on line 1874 to

public static int delayedCall(GameObject gameObject, float delayTime, string callback)
{
    //return delayedCall( gameObject, delayTime, callback, emptyHash );
    return delayedCall( gameObject, delayTime, callback, new Hashtable() );
}

seems to have fixed it. I haven't had time to look too much into things but I suspect there might be an issue re-using the static emptyHash variable like that.

maybe some advice for improvement

hi, when I saw the LeanTween, I was so exciting! Thank you for your work.
But I have some advice for improvement:
1.how about use generic type LTDescr, such as LTDescr or LTDescr ,because there are some GetComponent in LeanTween update life function , it will call some overhead,so if it can use Generic in LTDescr it can reduce the unity overhead and make LTDescr member field small and clear.
2.define some group recursive enum type for LeanAction, such as CanvasGroup for tweening alpha, but not textAlphaRecursive.
3.support serialize for LTDescr, it can make LeanTween edit tween property in Editor.

I am hoping what are you thinking about these, thank you!

Add "params" keyword to object[] parameters

Adding the "params" keyword to those methods with object[] parameters would provide an easier way for using those methods.

As example, the scaleY method:

public static int scaleY(GameObject gameObject, float to, float time,
 object[] optional);

could be replaced with

public static int scaleY(GameObject gameObject, float to, float time, 
params object[] optional);

I find myself more comfortable writing:

LeanTween.scaleY(go, y, 1.0f, "ease", easeType); // With "params"

than

LeanTween.scaleY(go, y, 1.0f, new object[] { "ease", easeType }); // With object[]

I'm utterly ignorant about the performance penalties that could result from this or other reasons for discouraging the use of "params", so please feel free to embarrass me publicly :)

LeanTween.value with float always tweening towards zero.

Running in Unity 5 beta 14. Using the latest version of LeanTween from the Unity Asset Store (2.19)

If the setOnUpdate method is used, the output value always tweens from the "from" value to zero, and ignores the "to" value. If the method is passed in the original call to LeanTween.value() it works correctly.

The same results occurred when using Vector3 values instead of floats as well.

E.g.

This code works correctly (m_EditPanel is a RectTransform)

LeanTween.value(m_EditPanel.gameObject, (float pos) =>
    {
        Debug.Log("On Update Off : " + pos);
        var min = m_EditPanel.anchorMin;
        min.x = pos;
        m_EditPanel.anchorMin = min;
        var max = m_EditPanel.anchorMax;
        max.x = pos + 0.658f;
        m_EditPanel.anchorMax = max;
    }, 0.342f, 1f, 0.5f).setEase(LeanTweenType.easeOutSine);

And this is the code that tweens towards zero.

LeanTween.value(m_EditPanel.gameObject, 0.342f, 1f, 0.5f).setEase(LeanTweenType.easeOutSine).setOnUpdate((float pos) =>
    {
        Debug.Log("On Update Off : " + pos);
        var min = m_EditPanel.anchorMin;
        min.x = pos;
        m_EditPanel.anchorMin = min;
        var max = m_EditPanel.anchorMax;
        max.x = pos + 0.658f;
        m_EditPanel.anchorMax = max;
    });

Library in DLL

Since I have no idea how to produce the dll files in monodeveloper and use it as the library for other projects. Are there any chances that you will able to compile a dll file for us to use in handy?

Project Loading Error on Unity 4.3.2f1

Hi.
I downloaded this package from here itself and tried to load the project in Unity3D 4.3.2f1. As it asked me to upgrade the project I clicked on yes. After that, even though I was able to open the scenes, nothing was happening. The GameObjects were showing up but with missing script references and broken prefabs...
screenshot 7

Weird Bouncing

Im using LeanTween.moveX();

When it executes the buttons ease in, then they snap around for maybe half a second. Do you know why this is happening? Thanks in advance!

Cancelling tween after finished, if another tween started in the meantime, LeanTween.cancel() cancels the new one instead.

Hi,
Long time user of LeanTween here, love the lib and use it in our game.
So far we didn't rely much on cancelling tweens, and even when we did, we just used .cancel(gameObject), so we didn't have any issues.
However, in some new code we had to cancel one-shot tweens, so we started using LTDescr.cancel(), by keeping a reference of the LTDescr when starting the tween. We want to cancel the tween if it's in progress and do nothing if it's finished.
However, if a tween finishes, and another starts in the meantime, when we call .cancel(id) or LTDescr.cancel(), the new tween gets cancelled instead. The reference's values get replaced, because the values in the array are directly getting manipulated and a new LTDescr is not created, so even .toggle is getting set to the new tween's value. The only thing we can do is use onComplete to circument the issue, but that will get tedious if we have to use it everywhere.
Any better solutions to this one?

Alpha tween does not work with multiple materials

The alpha tween does not work with multiple materials. I can imagine that with the current code, it would be impossible to inherit the current value of both materials but I can accept that and just keep 1 (Or supply it yourself).

else if((TweenAction)tweenAction==TweenAction.ALPHA)
{
    foreach(Material mat in trans.gameObject.renderer.material)
    {
        mat.color = new Color(  mat.color.r,
                                mat.color.g,
                                mat.color.b,
                                val);
    }

}

Maybe it would also be a good idea to unzip and place the C# file in another branch so we can suggest changes and supply pull requests for it.

DLL is outdated

Hello!

I updated leantween to latest through Unity's Asset Store. I needed alphaCanvas, so I was quite happy.
No problem if I use LeanTween scripts, but for many reason (including compile time), I would rather use the DLL. Except the DLL is outdated, and alphaCanvas does not exist in it.

Could you please update the DLL and push it on the store again? Or maybe put up a small tutorial on how to make the DLL ourselves from the script files in the package?

Thanks

Tweens of duration 0 have no effect

When duration of a tween is set to 0, tweened properties are not set to final value. It should set immediately the final values on the target gameobject.

Example code errors

Hi, I was taking a look at this plugin but I couldn't give it a try. The example codes give me a bunch of errors, all of the same style:

Assets/LeanTween/LeanTweenExamples/Scripts/EventListenersScatteredJS.js(30,20): BCE0018: The name 'LTEvent' does not denote a valid type ('not found').

Google says it's related to a missing import or something with the compilation order of standard folders. But I don't really know what's going on.

Any idea?

Thanks

LTSpline constructor causes frameskips

Running Version 2.32.

The LTSpline constructor causes huge frameskips. I was losing 6 frames for a 6 point spline.

Here's my code:

Profiler.BeginSample("Spline start");
LeanTween.moveSpline(gameObject, splinePoints, 0.6f)
    .setOrientToPath2d(true);
Profiler.EndSample();

splinePoints is a randomly generated array that contains values like:
[(0.0, 5.0, 0.0), (0.0, 5.0, 0.0), (-0.3, 4.8, 0.0), (-0.9, 7.4, 45.0), (-2.3, 9.5, 90.0), (-2.3, 9.5, 90.0)]
[(0.0, 5.0, 0.0), (0.0, 5.0, 0.0), (-0.4, 4.8, 0.0), (-1.6, 7.0, 45.0), (-2.3, 9.5, 90.0), (-2.3, 9.5, 90.0)]

I profiled the code. Here's the breakdown:

Leantween takes 1119.44 ms to spin up a spline from a coroutine.
Of that time. 85.6% is spent in a function called LTSpline.interp(), which for my points was called ~140,000 times. Most of the time is spent in simple math functions for interp, but I'm concerned that it's being called that many times.

The problem is with how you calculate precision when minSegment is between 0.0 and 1.0. Let's say minSegment was 0.01, and totalDistance was 2.0.

float minPrecision = minSegment / SUBLINE_COUNT = .01/50 = .002;
int precision = (int)Ceil(totalDistance / minPrecision) * DISTANCE_COUNT
                    = Ceil( 2 / .002) * 50 = 1000 * 50 = 50,000

In other words, the smaller a distance the object has to travel once you have segments between [0.0 and 1.0], the more precise LT thinks it needs to be. That doesn't make sense to me, because at those distances, you wouldn't even notice the precision.

I'd recommend adding in a MAX_PRECISION as a quick patch, but you probably want to change the calculation so that it decreases when going from 1.0 --> 0.0.

Out of available spaces for tweening

My code below is working as expected, but it's throwing this error. I tried to raise init() numbers to 500k but errors persist. Any advice?

LeanTween - You have run out of available spaces for tweening. To avoid this error increase the number of spaces to available for tweening when you initialize the LeanTween class ex: LeanTween.init( 800 );

void Newspaper()
{
    LeanTween.value(Dialogs[3].gameObject, (v) =>
    {
        Dialogs[3].alpha = v;
    }, 0, 1, 0.2f);

    LeanTween.scale(NewspaperObject, new Vector3(1.15f, 1.15f, 1.15f), 0.6f);

    LeanTween.rotateAround(NewspaperObject, Vector3.forward, -360f, 0.3f).setOnComplete(() =>
    {
        LeanTween.rotateAround(NewspaperObject, Vector3.forward, -360f, 0.4f).setOnComplete(() =>
        {
            LeanTween.scale(NewspaperObject, new Vector3(1f, 1f, 1f), 0.1f);
            var btnBack = Dialogs[4].GetComponentInChildren<Button>();
            btnBack.interactable = true;
            LeanTween.value(Dialogs[4].gameObject, (v) =>
            {
                Dialogs[4].alpha = v;
            }, 0, 1, 0.3f).setDelay(1);

        });

    });

}

OnUpdate still being called after pause

If I use setOnUpdate on a Tween and later pause the tween, whatever I specified in setOnUpdate still gets called (sending the same value). Perhaps this is intended but this seems weird to me. Shouldn't setOnUpdate be called only if there's an actual update and the tween is active? It's easy to work around but

Can't cancel a tween by id

Hello,

First of all, great plugin! I'm using it intensively in our game.
It seems the removeTween function can't process the new backId.
Could you take a look?

Thank you

UnityEngine.UI on Unity5 beta

The new UnityEngine.UI is not yet released on Unity5 beta, generating compiling erros. So the #if UNITY_4_6 || UNITY_5_0 parts can be temporary changed to #if UNITY_4_6 until Unity5 released.

Tag releases

I'm using git submodules to import the current stable release of leantween into my project. Can you please tag your stable releases (as you did with 2.32)? I've been missing the tags for 2.33 and now 2.34. Cheers!

Color Tween for SpriteRenderer

I've noticed that Leantween is missing color tweens for spriterenderers

so just add this at Line 2234 :)

var sprRen = trans.gameObject.GetComponent<SpriteRenderer>();
if (sprRen != null) {
    sprRen.color = toColor;
}

Cheers and thanks for this great tween library! :)

LeanTween.reset() NPE

Hello, and thanks for this great library!

Following your suggestion in #80, I've added unconditional LeanTween.reset() at the start of each scene, but now facing some NullPointerExceptions:

public static void reset(){
    for (int i = 0; i <= tweenMaxSearch; i++){
        tweens[i].toggle = false; // This line
    }
    tweens = null;
    Destroy(_tweenEmpty);
}

I think there should either be a check in the beginning of the function to make sure a reset is necessary. Personally, I would simply never make tweens null, and set it to empty array/list instead.

Best,

No license

Great library, thanks for sharing.

I'm thinking about adding it to my project, but I noticed you didn't include a license yet. Having no license means that - legally - your code can't be reproduced or derived, not sure if that's what you intended. [1] For a quick fix I would suggest simply pasting something like

This project is licensed under the terms of the MIT license.

at the end of the readme, or including a license file. Most repos on github use the MIT license because it's permissive, allowing code to be used in proprietary projects while retaining the original copyright. [2]

[1] https://help.github.com/articles/open-source-licensing
[2] https://github.com/blog/1964-open-source-license-usage-on-github-com

LeanTween.count

An idea.
LeanTween.count(int)( gameObject:GameObject callOnUpdate:Action<> time:float from:int to:int )

I want to run a function, ten times in 5 seconds.

Strange behaviour on easeInOutBack ease type in Unity 5.3

All was going well until I tried this (Unity 5.3.1):

LeanTween.moveY (menuPanel, 1200f, 0.5f)
            .setEase (LeanTweenType.easeInOutBack);

The goal is to have the menu panel move down slightly before shooting up out of the screen. The easeInOutBack seemed the correct type (based on Easing Cheatsheet - http://easings.net/).

menuPanel is a GameObject UI Panel of which I declare as public and assign in the inspector.

Instead it goes a little crazy, bouncing up and down sporadically whilst moving a bit - it's almost if the tween is on it's own timescale.

Has anyone observed this behaviour before? I'm not quite sure if it's an issue with the newer Unity or most likely my implementation?

Request to Break out LeanAudio and LeanTest into their own files

I would like to put LeanAudio and LeanTest into their own files separate from LeanTween. This would allow only including the pieces needed for a particular project. It would also make the code easier to navigate as LeanTween.cs is at this point pretty big.

not support convasgroup?

use 2.30 version download from assetstore.unity3d.com.
LeanTween.alpha(convasgroup_menus, 1, 1);

isTweening crash

If there's no tweens running and I call LeanTween.isTweening(gameObject) it crashes because the for loop is
for(int i = 0; i <= tweenMaxSearch; i++) {
so if tweenMaxSearch is 0, which it is, it runs the next line of code
if (tweens[i].toggle && tweens[i].trans==trans)
causing it to fall over as there are no tweens in the array.
maybe changing it to
for(int i = 0; i < tweenMaxSearch; i++) {
will fix it?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.