Search Unity

  1. We've closed the job boards. If you're looking for work, or looking to hire check out Unity Connect. You can see more information here.
    Dismiss Notice
  2. Unity 2017.2 is now released.
    Dismiss Notice
  3. The Unity Gear Store is here to help you look great at your next meetup, user group or conference. With all new Unity apparel, stickers and more!
    Dismiss Notice
  4. If you're a macOS 10.13 High Sierra user take be sure to read this before updating Unity.
    Dismiss Notice
  5. Introducing the Unity Essentials Packs! Find out more.
    Dismiss Notice
  6. Want to see the most recent patch releases? Take a peek at the patch release page.
    Dismiss Notice
  7. Unity 2017.3 beta is now available for download.
    Dismiss Notice

HOTween: a fast and powerful Unity tween engine

Discussion in 'Assets and Asset Store' started by Izitmee, Jan 7, 2012.

  1. username_

    username_

    Joined:
    Sep 27, 2013
    Posts:
    9
    Hi

    I'm trying to get a path to work with constant speed. Is it supposed to be used like this?

    HOTween.To (transform, speed, new TweenParms ().
    SpeedBased (true).
    Prop ("position", hoPath.MakePlugVector3Path ().
    OrientToPath (lookAheadPercentage)).
    SpeedBased (true).
    Ease( EaseType.Linear ));

    It still does not move in a linear way.

    So what I want to achieve is movement along the path at a constant speed, even when my waypoints are not at equal distance to each other.
     
    Last edited: Jan 28, 2014
  2. dzonatan

    dzonatan

    Joined:
    Dec 19, 2013
    Posts:
    2
    Hello,

    Is there any way to preload the tweens? The thing is that when the tween (bigger one) starts for the first time the game freezes for ~0.5s.
     
  3. Izitmee

    Izitmee

    Joined:
    Jan 27, 2011
    Posts:
    3,224
    @username_: you don't need to set SpeedBased, but just the ease as Linear. If you still have this issue, can you send me a simple barebone issue that replicates the issue, so I can check it out (I'm superbusy right now, so it might take a few days).

    @dzonatan: first of all, I'd suggest calling HOTween.Init once before the first tween, so it won't be called automatically when the first one starts. Other than that, the possible reasons might be:
    - you're playing inside Unity Editor, which has a startup hiccup of 0.5 seconds most of the time, due to its Editor nature
    - you're instantiating an object or something like that before tweening, which might explain the hiccup
     
  4. RodolfoLasparri1

    RodolfoLasparri1

    Joined:
    Feb 24, 2013
    Posts:
    14
    First thanks for an amazing plugin, awesome job :)

    I'm having a problem tweening any object using local rotation. Simply making a primitive, rotating in the scene and then doing something like this to make it spin on it's local X axis:

    Code (csharp):
    1. HOTween.To (Object,1f, new TweenParms ().Prop ("localRotation", new Vector3 (50,0, 0), true).Loops (-1, LoopType.Incremental).Ease (EaseType.Linear));
    makes it rotate weirdly, not around it's regular scene local X axis

    I tried replicating the same tween using "localRotation" and "localEulerAngles" on the Hotween visual editor and I got the same results, both with Relative turned on and off, what am I doing wrong?

    thanks!
     
  5. Spikeh

    Spikeh

    Joined:
    Jun 7, 2013
    Posts:
    24
    Hi Izitme,

    I find it pretty difficult to search these forums, or even individual threads, so I apologise if this has been asked before. I'm trying to tween a method rather than a property. Is there any support for this in HotTween?

    I'm not actually doing the following, but it's the same concept (I would have to explain a lot of other things if I showed you the example!):

    So in the above example, I'm expecting the player to be tweened along the x axis for 100 units. I get the following:

    Basically, I want to call transform.position.Set(value) instead of transform.position = value. I understand there may be complications surrounding methods with multiple parameters, though I only need to apply one property atm.
     
  6. EmeralLotus

    EmeralLotus

    Joined:
    Aug 10, 2012
    Posts:
    1,294
    Out of curiosity,

    Perhaps someone can help... I'm looking for an in-game animation editor that uses one of the popular Unity Tweening packages (Hotween, Itween, LeanTween)

    Cheers.
     
  7. kleber-swf

    kleber-swf

    Joined:
    Mar 17, 2013
    Posts:
    5
    Hi!

    I'm using HOTween since ever and I can say that this is the best Unity Tweener.
    Well, I'm not making this post to tell you guys waht you already know :) I have a little problem here and want to know if there is a solution for it. Here it is:

    I have a Sequence made by other Sequences. The child Sequences are very complex so I cache them with SequenceParms.AutoKill(false). They actually change a bit every time they're called, but I cache the change too (using Tweener.ResetAndChangeParms on some of its tweeners).

    The main Sequence is cached as well, but its content may vary: the child (cached) Sequences can be added or not to the main Sequence, so, when I call mainSequence.Clear() to reset it, all the child Sequences are killed (clearly because of the risk of memory leaks).

    Here is a sample code to illustrate my problem:
    Code (csharp):
    1.  
    2. private Sequence _mainSequence = new Sequence(new SequenceParms().AutoKill(false));
    3.  
    4. private void CreateMainSequence() {
    5.     if (_mainSequence == null)
    6.         _mainSequence = new Sequence(SequenceParms);
    7.     else
    8.         _mainSequence.Clear(SequenceParms);
    9.  
    10.     for (var i = 0; i < count; i++)
    11.         _mainSequence.Insert(0f, GetComplexChildSequence(i));
    12.        
    13.     _mainSequence.Play();
    14. }
    15.  
    If I create a new Sequence every time, I need to set Sequence.AutoKill to false, otherwise the Sequences will accumulate in the memory, besides, the cached child Sequence instances remains attached to the older Sequences too making the animation broken.

    Is that a solution to this problem? I've tried to search in the source code for a way to remove the Tweeners without killing them, but I couldn't found it.

    Thanks in advance.
     
  8. Izitmee

    Izitmee

    Joined:
    Jan 27, 2011
    Posts:
    3,224
    @RodolfoLasparri1: I tested it right now, to be sure, and everything works correctly here. Maybe you're rotating the object before applying the tween? The result should be the same as if you manually move the X rotation in the Inspector.

    @Spikeh: you can only tween public non-static fields or accessors. Still, you can tween a custom variable, and call your method at each update, using the OnUpdate callback.

    @rocki: I know there are some animation editors in the Asset Store that use HOTween or other engines, but I wouldn't know what to suggest since I didn't play with them. Animator was just updated by Sinfritz and it's free, so you might want to try that: it looked very promising.

    @kleber.swf: thanks for the appreciation :) Ow, nested Sequences were never meant to be cached, and I didn't even know that would work. As of now, there's no solution to your issue, except creating new nested Sequences each time. I will think if I can implement what you ask in the future, but right now I'm supermegabusyalmostdead :D
     
  9. kleber-swf

    kleber-swf

    Joined:
    Mar 17, 2013
    Posts:
    5
    Thanks Izitmee.
    No problem, I understand :)
    For now, I'll not cache my child Sequences.

    Thanks for your feedback (and again, the best Unity tween tool)!
     
  10. Spikeh

    Spikeh

    Joined:
    Jun 7, 2013
    Posts:
    24
    Hey Izitme,

    I ended up wrapping my method in a property which I then tweened:

    public Vector2 ControllerRotation {
    set { m_Player.Rotation.Set(value); }
    get { return m_Player.Rotation.Get(); }
    }

    HOTween.To(this, 1f, new TweenParms()
    .Prop("ControllerRotation", endRotation)
    .Ease(MyAnimationCurve));

    Works a treat. I did try OnUpdate(), but it wasn't quite appropriate.
     
  11. dzonatan

    dzonatan

    Joined:
    Dec 19, 2013
    Posts:
    2
    @Izitmee: Thank you for your reply. Actually in Unity editor everything works perfectly I'm facing the performance issue on devices (Samsung Galaxy S2, Nexus 4, iPad 4). And as I sad that "mini lag" occurs only once when the game is freshly started for the first time. Every second time - it tweens perfect without any performance issues. Maybe it's because I'm using both the "Code" and "Visual editor" version at the same time? How should I use them both? Do I still need to Initialize (.Init()) the HOTween?

    Thank you!
     
  12. RodolfoLasparri1

    RodolfoLasparri1

    Joined:
    Feb 24, 2013
    Posts:
    14
    @Izitmee: thanks for the reply, I think I wasn't very clear with my question, sorry

    What I meant exactly was to tween-rotate an object around it's local axis, this is example code that does what I'm after, I would like to avoid using the Update loop if possible:

    Code (csharp):
    1.  public float localRotationY;
    2.  
    3.     void Start () {
    4.  
    5.         HOTween.To (this, 1f, new TweenParms ().Prop ("localRotationY",180f).Loops (-1, LoopType.Incremental).Ease (EaseType.Linear))
    6.     }
    7.  
    8.     void Update () {
    9.  
    10.         this.transform.rotation *= Quaternion.Euler(0f, localRotationY, 0f);
    11.     }
    thanks, you rock :cool:
     
  13. StaffanEk

    StaffanEk

    Joined:
    Jul 13, 2012
    Posts:
    355
    How do you start a tween by id name?

    I tried to search your Get Started page for the term " Id" but I get nothing. Or is there a way to use the visual editor to start a tween in any other way then by pressing play?
     
  14. kleber-swf

    kleber-swf

    Joined:
    Mar 17, 2013
    Posts:
    5
    Hi!

    Is anybody having trouble to build the game with the HOPath?
    Because I just had one and fixed it. So, I want to know if was just me or anyone else had that problem too.

    (I know that this thread is about HOTween, but there is no thread about HOPath, and it's just available here)

    Thanks.
     
  15. jogodi

    jogodi

    Joined:
    Jul 10, 2013
    Posts:
    4
    Hi!,

    I am using this tool to make the effect "fade in - fade out". The first time i make the sequence it works perfect; the second time and nexts:
    - it dosent inmediately block inputs with the texture's gameObject's collider
    - it costs to begin some seconds
    - it plays almost at double speed
    - it goes inmediately to dark after some seconds (the seconds i have mentioned before)

    My code:
    Code (csharp):
    1.  
    2. FadeTextureObject.SetActive(true);//I active the gameobject that have a black Texture attached to it
    3. UITexture target = FadeTextureObject.GetComponent<UITexture>();//i recover the black texture
    4.  
    5. Sequence secuencia = new Sequence();
    6.         secuencia.Append(HOTween.From(target, 4f, new TweenParms().Prop("alpha", 0)) );//dark in 4 seconds
    7.         secuencia.Append(HOTween.To(target, 2f, new TweenParms().Prop("alpha", 1)).OnComplete(() => {  })));//i maintain dark for 2 seconds
    8.         secuencia.Append(HOTween.To(target, 4f, new TweenParms().Prop("alpha", 0).OnComplete(() => { FadeTextureObject.SetActive(false);    })));//i leave dark in 4 seconds
    9.  
    10.         secuencia.Play();
    11.  
    Thanks in advance.
     
    Last edited: Feb 4, 2014
  16. Izitmee

    Izitmee

    Joined:
    Jan 27, 2011
    Posts:
    3,224
    Sorry for the delayed answers guys. I was crunching to finish a candyjam game (Candy Defenders, which I sadly completed only with around 40% of what I intended) and doing other jobs.

    @dzonatan: You definitely can use both, but maybe the Visual Editor is creating a mini-lag at startup, when he converts all your settings to actual tweens. You could use a trick: start a tween just for the sake of it, before doing everything else. And about HOTween.Init, you should indeed do it. But be sure it's in some class that has Priority in the Script Execution Order, so that it's called before the Visual Editor routines start up.

    @RodolfoLasparri1: oh I see what you mean now. Actually no, that's not possible. Still, you could write it without using Unity's Update but your tween's OnUpdate callback, like this (I'm adding line breaks just for readability: it's you same code plus OnUpdate):
    Code (csharp):
    1.  
    2. HOTween.To (this, 1f, new TweenParms ()
    3.    .Prop ("localRotationY", 180f)
    4.    .Loops (-1, LoopType.Incremental)
    5.    .Ease (EaseType.Linear)
    6.    .OnUpdate(() => {
    7.       target1.rotation *= Quaternion.Euler(0f, localRotationY, 0f);
    8.    })
    9. );
    10.  
    Or, you could even create a custom HOTween plugin just for that :)

    @StaffanEk: Use HOTween's static methods. In short, to start a tween via an Id, you just do
    Code (csharp):
    1.  
    2. HOTween.Play(myId);
    3.  
    @kleber.swf: sorry but I don't have an answer for that. You might try contacting Vevusio by PM, if he doesn't answer. Or since you fixed, you might see if he wants to put everything on Google Code or something like that :)
     
  17. Izitmee

    Izitmee

    Joined:
    Jan 27, 2011
    Posts:
    3,224
    @jogodi: From what I see, you're creating a Sequence that will automatically be destroyed at completion. If you want to play it again, you have to set the SequenceParms AutoKill method parameter to false. By the way, remember to place your code inside CODE tags in the future, so it's more readable ;)
     
  18. jogodi

    jogodi

    Joined:
    Jul 10, 2013
    Posts:
    4
    Thanks but: i dont want to retain that sequence, i need to create it when i need. The problem is still the same:

    i can make a sequence or do it all together: The first time i call it works perfect, the rest of the times dosent.
    Code (csharp):
    1.  
    2. //Dark in 4 seconds
    3.         HOTween.From( target, 4f, new TweenParms() .Prop("alpha", 0) .OnComplete( () =>
    4.                 {//i maintain dark for 2 seconds
    5.                    HOTween.To( target, 2f, new TweenParms() .Prop("alpha", 1) .OnComplete( () =>
    6.                             {//fade out in 4 seconds
    7.                                HOTween.To( target, 4f, new TweenParms() .Prop("alpha", 0) .OnComplete( () =>  
    8.                                 {
    9.                                     FadeTextureObject.SetActive(false);//to remove the collider that denys actions
    10.                                 }));
    11.                             }));
    12.                 }));
    13.  
     
    Last edited: Feb 4, 2014
  19. Izitmee

    Izitmee

    Joined:
    Jan 27, 2011
    Posts:
    3,224
    Oh, I see. Let me ananlyze it better. From what I see, you are starting from a dark visible texture and:
    1) making your texture dark and transparent
    2) making it dark but visible
    3) making it dark and transparent again

    The problem might be that, when you first start your sequence, your texture is dark+visible, and when it finished it's dark+transparent. So, when you create and start it again, it will be dark+transparent instead than dark+visible as in the previous sequence.
     
  20. DavidDebnar

    DavidDebnar

    Joined:
    Mar 19, 2011
    Posts:
    113
    Hi! First of all, I'm in love with your plugin. It was recommended to me the other day and couldn't stop using it since.
    Now to the darker side. I'm trying to animate a SpriteRenderer's color's alpha. I made a sequence, which holds the color animation of 4 SpriteRenderers, each at time 0. Then I manually set this sequence's position to change the alpha of all the sprites at once. This works flawlessly on WebPlayer/Standalone and in Editor. But, as soon as I make an iOS build with xCode, things go wrong. From what the xCode log says, HOTween couldn't find the 'color' property of 'SpriteRenderer' even though it works fine on other builds.

    The code is quite simple:
    Code (csharp):
    1. void Start ()
    2. {
    3.     TweenParms tweenParms = new TweenParms().Prop("color", new Color(1,1,1,0)).Ease(EaseType.EaseOutCubic);
    4.  
    5.     spriteSequence = new Sequence(new SequenceParms().Loops(-1, LoopType.Incremental));
    6.  
    7.     spriteSequence.Insert(0, HOTween.To(transform.gameObject.GetComponent<SpriteRenderer>(), 1,  tweenParms));
    8.     spriteSequence.Insert(0, HOTween.To(transform.parent.gameObject.GetComponent<SpriteRenderer>(), 1,  tweenParms));
    9.     spriteSequence.Insert(0, HOTween.To(transform.parent.parent.gameObject.GetComponent<SpriteRenderer>(), 1,  tweenParms));
    10.     spriteSequence.Insert(0, HOTween.To(transform.parent.parent.parent.gameObject.GetComponent<SpriteRenderer>(), 1,  tweenParms));
    11. }
    12.  
    13. void Update ()
    14. {
    15.     spriteSequence.position = someFloat;
    16. }
    A snippet from the ugly xCode error (Even though it's not practically an error, because HOTween itself sent the message) log (hand typed - might contain typos):
    Code (csharp):
    1.  
    2. HOTween : "myGameObject (UnityEngine.SpriteRenderer).color" is missing, static, or not public. The tween for this property will not be created.
    3. UnityEngine.Debug:Internal_Log(Int32, String, Object)
    4. UnityEngine.Debug:LogWarning(Object)
    5. Holoville.HOTween.Core.TweenWarning:Log(String, Boolean)
    6. Holoville.HOTween.Core.TweenWarning:Log(String)
    7. Holoville.HOTween.TweenParms:InitializeObject(Tweener, Object)
    8. Holoville.HOTween.Tweener:.ctor(Object, Single, TweenParms)
    9. Holoville.HOTween.HOTween:To(Object, Single, TweenParms)
    10. MyScript.Start()
    PS: I tried to modify the color directly via SpriteRenderer.color = new Color(1,1,1,Mathf.Sin(Time.time)); And it worked fine.

    Thanks,
    David
     
  21. Izitmee

    Izitmee

    Joined:
    Jan 27, 2011
    Posts:
    3,224
    Hi Dávid (and hi Frank), glad you like it :) About your issue, on iOS you should use HOTweenMicro, since I can't use the advanced (and slightly faster) Reflection methods available on other platforms. You can download it from the website: just replace the HOTween.dll/mdb/xml files with the HOTweenMicro ones, and the rest, code included, stays the same.

    EDIT: you can use HOTweenMicro for everything by the way. The regular version is slightly faster, but both are rather optimized.
     
  22. DavidDebnar

    DavidDebnar

    Joined:
    Mar 19, 2011
    Posts:
    113
    Hi, I probably should've mentioned this, but I'm using HOTweenMicro already :) Also, I'm David, but the forums messed my name up for some reason ;)
    I'm not saying that the plugin is broken, since there's a script animating the Y position of some objects via PlugVector3Y, which works just fine (iOS too). Which leads me to yet another 2 part question: I tried using PlugColor(), but it didn't work?

    Code (csharp):
    1.  The type or namespace name `PlugColor' could not be found. Are you missing a using directive or an assembly reference?
    I have both, regular and Plugins namespaces imported.

    Code (csharp):
    1. using Holoville.HOTween;
    2. using Holoville.HOTween.Plugins;
    Second question: Is it possible to create custom Plugs? I assume you probably have a base class and each Plug just inherits it, but I thought I'd ask first, since you could have certain limitations/hard coded things.
     
  23. Izitmee

    Izitmee

    Joined:
    Jan 27, 2011
    Posts:
    3,224
    Oh, too bad, Dávid looked so mysterious! :D

    Since you're using HOTweenMicro, what happens is very weird! HOTween uses simple Reflection there, so if he can't find that property it means it's really missing. It means that Unity does some weird things with SpriteRenderer when compiling with iOS, which seems very bad *_* As an alternate solution, you could change the color of the actual material (which is what Unity does under the hood when touching a sprite's color property), like this:
    Code (csharp):
    1.  
    2. // this is how it would look without a tween
    3. transform.renderer.material.SetColor("_Color", Color.red);
    4. // and here is the Prop for the tween instead
    5. // using the PlugSetColor
    6. HOTween.To(transform.renderer.material, 1f, new TweenParms()
    7.    .Prop ("color", new PlugSetColor(new Color(1,1,1,0)).Property("_Color"))
    8. );
    9.  
    You don't find PlugColor (which is different from PlugSetColor) because it's one of the core internal plugins, used by default when passing a Color value and thus without need to use it directly (see the Holoville.HOTween.Plugins.Core namespace here - all those plugins are automatic).
    EDIT: even other plugins are used automatically, but they are accessible because they can be used as/with different options.

    Second question: sure you can create custom plugins. Here is one I made as a base to modify (CustomVector3Plugin) :)
     
  24. DavidDebnar

    DavidDebnar

    Joined:
    Mar 19, 2011
    Posts:
    113
    Thanks for the help...But. No luck. It works on everything but iOS :( Shows essentially the same error, just a bit different:

    Code (csharp):
    1. HOTween : "Sprites-Default (Instance)(UnityEngine.Material).color" is missing, static, or not public. The tween for this property will not be created.
    2. UnityEngine.Debug:Internal_Log(Int32, String, Object)
    3.  
    4. UnityEngine.Debug:LogWarning(Object)
    5. Holoville.HOTween.Core.TweenWarning:Log(String, Boolean)
    6. Holoville.HOTween.Core.TweenWarning:Log(String)
    7. Holoville.HOTween.TweenParms:InitializeObject(Tweener, Object)
    8. Holoville.HOTween.Tweener:.ctor(Object, Single, TweenParms)
    9. Holoville.HOTween.HOTween:To(Object, Single, TweenParms)
    10. MyScript.Start()
     
  25. Izitmee

    Izitmee

    Joined:
    Jan 27, 2011
    Posts:
    3,224
    Then Unity is really doing something strange with those SpriteRenderers. Try writing "mainTexture" instead than "color" in the Prop. PlugSetColor is an exception to all other plugins, where the Prop field name is not really used. Still, it needs to be an existing property of the target not to break compatibility, but you can write there any of the regular Material properties.
    Just to be sure: other tweens are working, right? This with SpriteRenderer is the only one giving issue?
     
  26. DavidDebnar

    DavidDebnar

    Joined:
    Mar 19, 2011
    Posts:
    113
    After trying mainTexture and it failing, I decided to investigate. I wrote my own Reflection thing, which ran through all the components on an object (excluding Transform, because it has way too many properties to display them) and then neatly displayed them on the screen.

    This showed in the Editor (and presumably on everything else than iOS):
    [​IMG]

    And this is from iOS:
    [​IMG]

    So....Yeah. Apparently, Unity somehow hides properties from you in the iOS build.

    FYI: I used 'BindingFlags.Public | BindingFlags.Instance | BindingFlags.DeclaredOnly' which I assumed were similar, if not the same, to yours ;)
     

    Attached Files:

    Last edited: Feb 4, 2014
  27. jerotas

    jerotas

    Joined:
    Sep 4, 2011
    Posts:
    4,603
    How the heck do I do the equivalent of iTween.PunchScale?

    I tried this and got a null reference exception:

    Code (csharp):
    1. HOTween.Punch(GameTracker.Instance.ankhQtyPrefab.gameObject, UI_FONT_SCALE_TWEEN_TIME, new TweenParms(), .5f, .5f);
    I'm not sure where the parameter should go that says what to tween (scale). And I don't know what TweemParms is for. Yes I've already been to the doc website: http://www.holoville.com/hotween/hotweenAPI/index.html

    and it's not very clear to me. iTween was...but it's too slow to use.
     
  28. jogodi

    jogodi

    Joined:
    Jul 10, 2013
    Posts:
    4
    Thank you very much, it was that.

    I have solved it assigning a new color(1f,1f,1f,1f) to the texture at the last oncomplete; and now always works.
     
  29. Baroni

    Baroni

    Joined:
    Aug 20, 2010
    Posts:
    2,044
    This doesn't specify that you want to tween the scale, that's what TweenParms is for. From the docs:
    i.e.
    Code (csharp):
    1. HOTween.Punch(your transform, UI_FONT_SCALE_TWEEN_TIME, new TweenParms().Prop("localScale", new Vector3(2,2,2)), .5f, .5f);
    Note that scale is a property of transform, not gameObject (first parameter).
     
  30. Izitmee

    Izitmee

    Joined:
    Jan 27, 2011
    Posts:
    3,224
    Thanks for the answer Baroni :)

    @David: woah so Unity really does something strange there. I suppose it happens only with the new 2D-related classes, since otherwise I never had issues with iOS export. Could I ask you to check, just to be on the safe side, if your Reflection panels return the same result if you pass a regular texture renderer there instead than a sprite one?
     
  31. DavidDebnar

    DavidDebnar

    Joined:
    Mar 19, 2011
    Posts:
    113
    Sure thing. I haven't even tried making an iOS build, since this is what I got in the Editor:
    $l6LPXMQ.png

    So the reflection seems pretty inconsisten, considering the actual inspector shows this:
    $vikf741.png

    Maybe I'm just doing something wrong? Although, when trying to use the HOTween visual editor, it showed essentially the same members + some hidden members, which aren't shown in the inspector.

    Anyways, thanks for all the help. If this doesn't get resolved, I suppose I could use a wrapper for the SpriteRenderer.color property.
     
  32. Izitmee

    Izitmee

    Joined:
    Jan 27, 2011
    Posts:
    3,224
    Weird and weirder. I even asked Dmitriy Yukhanov, which I consider an incredibly skilled master coder who know everything, and he finds it very weird too.

    Hey David, could you try to replace HOTweenMicro with this new version (1.1.910), and then to animate the color property (like you initially did, without using PlugSetColor), and let me know if you still have the same log? With this mod, HOTween can animate also private properties/fields.
     
  33. DavidDebnar

    DavidDebnar

    Joined:
    Mar 19, 2011
    Posts:
    113
    Ahhh, My own version :3. I just tried, but it didn't work. I've also changed the binding flags of my reflection panel to allow private fields:
    Code (csharp):
    1. BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance | BindingFlags.DeclaredOnly
    But with no luck. I just hope I didn't mess something up on my part and am now leading everyone to bad conclusions :|, since all this feels very weird.
     
  34. StaffanEk

    StaffanEk

    Joined:
    Jul 13, 2012
    Posts:
    355
    Thanks. I decided to completely use scripts since it's apparently easier and I have everything working like I want it, (thanks for the tween engine by the way.) but it still bugs me that I can't get to use the graphical editor like I wanted. Unity simply says the following:


    Assets/Scripts/DoorTrigger.cs(22,38.): error CS0103: The name `TheIdIUsedHere' does not exist in the current context

    I did follow your advice by just doing what you told me. I think I need to do something else though.
     
  35. DavidDebnar

    DavidDebnar

    Joined:
    Mar 19, 2011
    Posts:
    113

    Well, I fixed it - for now. I wrote a wrapper for the color variable of SpriteRenderer, I could potentionally add more variables (Sprite, Material), but I don't need that at the moment.

    Code (csharp):
    1. using UnityEngine;
    2. using System.Collections;
    3.  
    4. public class SpriteWrapper : MonoBehaviour {
    5.    
    6.     public Color color
    7.     {
    8.         get
    9.         {
    10.             return m_color;
    11.         }
    12.  
    13.         set
    14.         {
    15.             if(m_color != value)
    16.             {
    17.                 m_color = value;
    18.                 spriteRenderer.color = m_color;
    19.             }
    20.         }
    21.     }
    22.     private Color m_color;
    23.     private SpriteRenderer spriteRenderer;
    24.  
    25.     void Awake ()
    26.     {
    27.         spriteRenderer = GetComponent<SpriteRenderer>();
    28.         m_color = spriteRenderer.color;
    29.     }
    30. }
    Thanks for the effort though :) You've been more help so far for me than the rest of the forums combined, so thanks again ;).
     
  36. Izitmee

    Izitmee

    Joined:
    Jan 27, 2011
    Posts:
    3,224
    @StaffanEk: if you get that error, it should mean you're defining TheIdUsedHere (which I suppose is a variable and not a string) in a different context. Show me your code (both where you define TheIdUsedHere and where you call HOTween.Play(TheIdUsedHere)) and I'll tell you what's exactly happening :)

    @David: sorry that I couldn't solve it, but I'll dig more since this is too weird :p About the wrapper, you could even do something simpler (and without a separate wrapper) using HOTween's OnUpdate callback and a custom variable to tween for your color:
    Code (csharp):
    1.  
    2. public Color myColor;
    3.  
    4. void Start()
    5. {
    6.   myColor = spriteRenderer.color;
    7.   HOTween.To(this, 1f, new TweenParms()
    8.     .Prop("myColor", Color.red)
    9.     .OnUpdate(() => spriteRenderer.color = myColor)
    10.   );
    11. }
    12.  
     
  37. fxcarl

    fxcarl

    Joined:
    Apr 8, 2010
    Posts:
    16
    @Izitmee:

    I am using both hotween and playmaker in project and got an idea to do data binding like this:

    Code (csharp):
    1.  
    2. public Object target;
    3. public string property;
    4. public string fsmVariableName;
    5.  
    6. void Update(){
    7.     HOTween.To(target,  0, property, PlayMakerGlobals.Instance.FsmVariables.GetFsmFloat(fsmVariableName).Value);
    8. }
    9.  
    10.  
    is it a good practice ?
     
  38. Izitmee

    Izitmee

    Joined:
    Jan 27, 2011
    Posts:
    3,224
    I don't use Playmaker so I'm not sure what that would do, but it seems good to me :)

    EDIT: except you're creating a new tween in each Update. You should put the tween creation routine in Start or something like that, so it's created just once.
     
  39. fxcarl

    fxcarl

    Joined:
    Apr 8, 2010
    Posts:
    16
    I'm sorry i cant understand ~ how to know i am creating a new tween or not ……

    is that means the tween cant change every frame ?


    I want give a data to a ui element, but i dont know the detail about the ui system (it made by ngui).
    And artist want me give him a way to link data and ui things avoid coding ~
    PlaymakerGlobals is a singleton, most important, it can return variables by a string (like playerperfs)

    so the code's job is copy data to some ui component property just by names:
    from playmaker variables to target property

    the data will change any time ...
     
  40. Izitmee

    Izitmee

    Joined:
    Jan 27, 2011
    Posts:
    3,224
    When you do HOTween.To, you're creating a new tween, which will run for the given time, going from the starting value of the tweened property, to the end value you write inside the parameters. So, if you call HOTween.To inside each update, you're creating a new tween every frame which is useless.

    To get a better grasp of it, try creating a simple HOTween.To that tweens a variable of your choice, inside Start, and see what happens.
     
  41. fxcarl

    fxcarl

    Joined:
    Apr 8, 2010
    Posts:
    16
    like this ? Looks good ~ Very fast ~ :D

    Code (csharp):
    1.  
    2.     public float input;
    3.     public float result;
    4.    
    5.     Tweener tweener;
    6.     TweenParms parms;
    7.  
    8.     // Use this for initialization
    9.     void Start () {
    10.         parms = new TweenParms().Prop("result", 0).Loops(1).AutoKill(false);
    11.         tweener = HOTween.To(this, 0, parms);
    12.     }
    13.    
    14.     // Update is called once per frame
    15.     void Update () {
    16.         parms.NewProp("result", input);
    17.         tweener.ResetAndChangeParms(TweenType.To, 0, parms);
    18.     }
    19.  
     
    Last edited: Feb 6, 2014
  42. Kobix

    Kobix

    Joined:
    Jan 23, 2014
    Posts:
    12
    Hey, is it possible to tween values like that?

    HOTween.To (this, 1f, "PauseBtn.size.x", 180f);
     
  43. Izitmee

    Izitmee

    Joined:
    Jan 27, 2011
    Posts:
    3,224
    @fxcarl: like that for the Start. But for the Update, if you ResetAndChangeParms at every Update it's like if you're resetting and restarting the tween completely, so it would be more efficient to just change the value you want to change directly inside Update :)

    @Kobix: the right way would be this:
    Code (csharp):
    1.  
    2. HOTween.To (this.PauseBtn.size, 1f, "x", 180f);
    3.  
    But only if "size.x" can actually be changed via code too. Otherwise, you'll have to do this:
    Code (csharp):
    1.  
    2. HOTween.To(this.PauseBtn, 1f, "size", new Vector3(sizeX, sizeY, sizeZ));
    3.  
     
  44. fxcarl

    fxcarl

    Joined:
    Apr 8, 2010
    Posts:
    16
    Are there any APIs can change tweener parms without restart it ?
     
  45. Izitmee

    Izitmee

    Joined:
    Jan 27, 2011
    Posts:
    3,224
    Nope. Re-adapting a tween to new end values while it's still running is a very complex matter, and I haven't implemented said feature.
     
  46. DavidDebnar

    DavidDebnar

    Joined:
    Mar 19, 2011
    Posts:
    113
    Hello, it's me again ;). I've ran into a tiny problem, but I thought I'd ask for your opinion anyways. I'm animating variables from a string, which is formatted in this fashion:

    value
    value:duration
    value:duration
    etc.

    Example:

    5
    10:2

    This is all nice and dandy. I got it running pretty quick, except I have a problem. What I do is iterate through each line of the string, and then Append the values into a sequence. The problem is with the first variable, 5 in this case. I'd want to first set the 5 as the initial value and then tween to 10 over 2 seconds. I didn't want to write my own Reflection thing, since HOTween already has a pretty powerful one, so I thought maybe I could abuse HOTween.To to set the variable to 5. 'Just use a duration of 0', I thought, but was I wrong.

    To sum up, when I want to just 'set', not tween to it, what should I use? It's kinda late, so maybe I'm just looking at the problem wrong :)
     
  47. Izitmee

    Izitmee

    Joined:
    Jan 27, 2011
    Posts:
    3,224
    Hey David :) I'm sorry, but I'm not sure I understood what you're asking *_* I'll try to answer but if I get it wrong, just tell me more.

    So, to just "set" a property, 0-duration tweens should work, unless I broke them with recent updates. Otherwise, you can always call myTween.Complete() to send a tween to the end. Or, in case of a Sequence, you can send it at a desired position in time by calling mySequence.GoTo(time) - and you can do that with Tweeners too.
     
  48. DavidDebnar

    DavidDebnar

    Joined:
    Mar 19, 2011
    Posts:
    113
    Hmm. So it seems like the Loop type I was using was somehow breaking it. I changed it up a bit and it now magically works ._. Also, I haven't even thought of .Complete(), now I feel stupid :sad:

    Anyways, once again, thanks for all the help and a great plugin :)
     
    Last edited: Feb 9, 2014
  49. Izitmee

    Izitmee

    Joined:
    Jan 27, 2011
    Posts:
    3,224
    Glad you solved it :)
     
  50. fxcarl

    fxcarl

    Joined:
    Apr 8, 2010
    Posts:
    16
    I found hotween project on google code, and see fast dynamic accessors are internal classes. would you like to make them public ?
    everyone will like it :D