Coder Social home page Coder Social logo

Comments (10)

dentedpixel avatar dentedpixel commented on July 17, 2024

Hey, Thanks for alerting me to this. I haven't played around with the new 2d options too much so I hadn't realized that didn't work.

It's now fixed in the latest version on Github. Let me know if any other 2d-centric things don't work...

I am glad you like it! TweenMax is the best, I did model a lot of how I do things after that great library :)

from leantween.

BenoitFreslon avatar BenoitFreslon commented on July 17, 2024

Unfortunately I can't "fade in" a gameobject but I can "fade out".

This script doesn't work:

gameObject.GetComponent<SpriteRenderer>().color = new Color(1f,1f,1f,0f); LeanTween.alpha(gameObject,1f,5f);

from leantween.

dentedpixel avatar dentedpixel commented on July 17, 2024

Good catch, I was tweening the *.material.color value and not the *.color like you are doing in your script. I think the way you are doing it is more appropriate, so I committed a change to fix that. If you test the latest it should work...

from leantween.

BenoitFreslon avatar BenoitFreslon commented on July 17, 2024

Awesome ;).

Thanks.

from leantween.

gresolio avatar gresolio commented on July 17, 2024

Thanks for the great tween plugin :) One more question to this necro issue: does "LeanTween.alpha(RectTransform)" work with "UnityEngine.UI.RawImage" component? I am using LeanTween 2.34 (Jul 25, 2016) and unfortunately cannot get it work with RawImage. But everything is just fine with the usual Image component.

from leantween.

dentedpixel avatar dentedpixel commented on July 17, 2024

Unfortunately, it does not. You can however tween the value with LeanTween.value, like:

LeanTween.value( gameObject, 1f, 0.5f, 1f).setOnUpdate( (float val)=>(){
UnityEngine.UI.RawImage r = gameObject.getComponent<UnityEngine.UI.RawImage>();
Color c = r.color;
c.a = val;
r.color = c;
});

I didn't get a chance to test this, but it should work...

And thanks! I am glad you like the plugin :)

from leantween.

gresolio avatar gresolio commented on July 17, 2024

Of course LeanTween.value is very versatile and can be used in this case as well. Actually that's exactly what I did, but without lambda expression, in dedicated function. It would be nice to add "RawImage" component support to the LeanTween (like "Image" component). Because currently it is impossible to write "one line tween" to change alpha of the "RawImage". I mean it is somehow inconsistent, that usual "Image" is supported, but "RawImage" is not. Anyway thanks :)

from leantween.

dentedpixel avatar dentedpixel commented on July 17, 2024

Indeed, it would be pretty easy to add, but I am just worried because to add it will incur a performance penalty for anyone looking to use alpha. Since I think 99% of the time people are just looking to tween a normal image, I would rather avoid the performance penalty for that 99% of the time. Unless people use RawImage a lot? I haven't had to use it myself, so I am not too aware of how much people use it...

from leantween.

gresolio avatar gresolio commented on July 17, 2024

I agree, it is a quite rare case, and if it's not worth it (because of a performance penalty), then no need to support it.

I'm curious, so one more question: why "LeanTween.alpha" requires RectTransform to tween UI component's alpha? It make sense if one need to tween values in RectTransform (pos, rot, scale, etc), but alpha value has no relation to a RectTransform. As I can see from Unity.UI sources, all visual components inherits from UnityEngine.UI.Graphic class, so it would be more logical (and type-safe) to pass component itself as an argument:

LeanTween.alpha(UnityEngine.UI.Graphic uiComponent, float to, float time)
instead of
LeanTween.alpha(RectTransform rectTrans, float to, float time)

Any component in Unity is always attached to a GameObject, and GameObject always has a Transform component attached to it. So if LeanTween internally requires GameObject or Transform, they can be easily retrieved from the passed component.

from leantween.

dentedpixel avatar dentedpixel commented on July 17, 2024

That was just to keep it consistent with all the other Canvas related
tweening methods, this way I can take shortcuts to only check for alpha
stuff related to a canvas object. It might have made more sense to pass a
graphics component like you said, but it was to keep more inline with the
other Canvas methods that I made it that way...

On Sun, Sep 4, 2016 at 4:48 PM, XANDER [email protected] wrote:

I agree, it is a quite rare case, and if it's not worth it (because of a
performance penalty), then no need to support it.

I'm curious, so one more question: why "LeanTween.alpha" requires
RectTransform to tween UI component's alpha? It make sense if one need to
tween values in RectTransform (pos, rot, scale, etc), but alpha value has
no relation to a RectTransform. As I can see from Unity.UI sources
https://bitbucket.org/Unity-Technologies/ui/src/8f0a27711670/UnityEngine.UI/UI/Core/?at=5.3,
all visual components https://docs.unity3d.com/Manual/comp-UIVisual.html
inherits from UnityEngine.UI.Graphic class, so it would be more logical
(and type-safe) to pass component itself as an argument:

LeanTween.alpha(UnityEngine.UI.Graphic uiComponent, float to, float time)
instead of
LeanTween.alpha(RectTransform rectTrans, float to, float time)

Any component in Unity is always attached to a GameObject, and GameObject
always has a Transform component attached to it. So if LeanTween internally
requires GameObject or Transform, they can be easily retrieved from the
passed component.


You are receiving this because you modified the open/close state.
Reply to this email directly, view it on GitHub
#6 (comment),
or mute the thread
https://github.com/notifications/unsubscribe-auth/ADWwwUk4p08qTgZr-sEJnkYFma5zXNYWks5qmy6ygaJpZM4BavId
.

Twitter - http://twitter.com/DentedPixel
Facebook - http://www.facebook.com/DentedPixel
Website - http://dentedpixel.com

from leantween.

Related Issues (20)

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.