Search Unity

DOTween (HOTween v2), a Unity tween engine

Discussion in 'Assets and Asset Store' started by Izitmee, Aug 5, 2014.

  1. DavidNLN

    DavidNLN

    Joined:
    Sep 27, 2018
    Posts:
    53
    Sorry, I was on my phone at the time of writing the post, the code looks like so:

    Code (CSharp):
    1. void OnCollisionEnter2D(Collision2D col)
    2.     {
    3.         Sequence mySequence = DOTween.Sequence();
    4.                    
    5.         mySequence
    6.         .Append(transform.DOMoveX(45, 1))
    7.     .Append(transform.DOMoveX(-45, 1));
    8.     }
    This only playes the second tween (Moves to -45)
    If I use the same code in the Start method instead, it works fine.

    I tried adding an if statement to check if the seq is already playing:
    Code (CSharp):
    1.    public class Example1 : MonoBehaviour
    2.    {
    3.      Sequence mySequence;
    4.    
    5.      void Start()
    6.     {
    7.          mySequence = DOTween.Sequence();
    8.     }
    9.                    
    10.    void onCollisionEnter2D(Collision2D collision)
    11.   {
    12.     if (!mySequence.isPlaying())
    13.     {
    14.          mySequence
    15.         .Append(transform.DOMoveX(45, 1))
    16.         .Append(transform.DOMoveX(-45, 1)).play();
    17.     }
    18.   }
    I also tried disabling the collision while the tween is playing, but nothing works.
     
  2. FuguFirecracker

    FuguFirecracker

    Joined:
    Sep 20, 2011
    Posts:
    249
    This will work:
    Set up your sequence in Start()

    .Pause() on the end.
    OR in The DoTween Utility Panel > Autoplay NONE

    and then
    Code (CSharp):
    1. void onCollisionEnter2D(Collision2D collision)
    2.   {
    3.       mySequence.Play();
    4.   }
     
    Last edited: Oct 7, 2018
  3. DavidNLN

    DavidNLN

    Joined:
    Sep 27, 2018
    Posts:
    53
    I cant set it up on start as I use data from the collision for the tween.
    I use the current position of the transform to determine where to move on collision.
     
  4. FuguFirecracker

    FuguFirecracker

    Joined:
    Sep 20, 2011
    Posts:
    249
    The code you posted does not reflect this.
    THAT code will move your GameObject to to an exact spot that is in no means influenced by the current position of said GameObject.
    Would you care to post your actual code?
     
  5. DavidNLN

    DavidNLN

    Joined:
    Sep 27, 2018
    Posts:
    53
    Sure, It's the same I just made the changes to make it a simpler use case

    Code (CSharp):
    1.    void onCollisionEnter2D(Collision2D collision)
    2.   {
    3.     if (!mySequence.isPlaying())
    4.     {
    5.          var initalX = transform.position.x;
    6.  
    7.          mySequence
    8.         .Append(transform.DOMoveX(initalX + 1, .5f))
    9.         .Append(transform.DOMoveX(initalX - 1, 1f))
    10.         .Append(transform.DOMoveX(initalX, .5f))
    11.         .Play();
    12.     }
    13.   }
    This is an issue as It seems you cant create sequences on the fly, what If I want to create my tween bases on the incoming collider position ?
     
  6. FuguFirecracker

    FuguFirecracker

    Joined:
    Sep 20, 2011
    Posts:
    249
    Pro tip for ya: Please post code that does the thing that you want it to do ... :p
    Add a SetRelative(); to the declaration in Start.
    Code (CSharp):
    1.  
    2. public class WorldsCollide : MonoBehaviour
    3.     {
    4.         private Sequence _mySequence;
    5.         private const float MOVEITX = 0.5f;
    6.  
    7.         private void Start()
    8.         {
    9.             _mySequence = DOTween.Sequence()
    10.                 .Append(transform.DOMoveX(MOVEITX, 1))
    11.                 .Append(transform.DOMoveX(-MOVEITX, 1))
    12.                 .SetRelative()
    13.                 .Pause();
    14.         }
    15.  
    16.         private void OnCollisionEnter2D(Collision2D col2D)
    17.         {
    18.             _mySequence.Play();
    19.         }
    20.     }
     
  7. FuguFirecracker

    FuguFirecracker

    Joined:
    Sep 20, 2011
    Posts:
    249
    Do you?

    There are no issues with creating a Sequence inside an OnCollision and using collision data inside the tween.

    Don't use a member variable. create the sequence in the OnCollision method
    And don't bother with a local variable... unless you're for some reason passing that tween data out somehwere ...
    For example:

    Code (CSharp):
    1.   private void OnCollisionEnter2D(Collision2D col2D)
    2.         {
    3.             DOTween.Sequence().Append(transform.DOMove(col2D.transform.position, 3))
    4.                 .Append(transform.DOMove(Vector3.zero, 3));
    5.         }
     
    Last edited: Oct 7, 2018
  8. DavidNLN

    DavidNLN

    Joined:
    Sep 27, 2018
    Posts:
    53
    Thx, I'l try this when I get home (currently at work), but again, this does not solve the core issue here, cant you create tweens inside a collision? what if I want to do something like this:
    Code (CSharp):
    1.    void onCollisionEnter2D(Collision2D collision)
    2.   {
    3.          var colliderTransform = collision.collider.gameObject.transform;
    4.          mySequence
    5.         .Append(colliderTransform.DOMoveX(5f, 1f))
    6.         .Append(colliderTransform.DORotateX(30f, 1f))
    7.         .Play();
    8.   }
    Also, I'd love to know, why does this happen, why only the last tween play if you create the sequence inside the collision function.
     
  9. FuguFirecracker

    FuguFirecracker

    Joined:
    Sep 20, 2011
    Posts:
    249
    Please see previous post
     
  10. FuguFirecracker

    FuguFirecracker

    Joined:
    Sep 20, 2011
    Posts:
    249
    I have not found this to be the case.
     
  11. DavidNLN

    DavidNLN

    Joined:
    Sep 27, 2018
    Posts:
    53
    I tried that as well, when this did not work I moved on to extracting the seq to a member variable. I cant really check it all right now, as I dont have unity in front of me at the moment.
    But I did try that.

    Also, I took the example code for sequences from the DOTween example package linked here and changed it from the Start method to the onCollisionEnter 2d method, and same result, only the last tween played on collision.


    The reason I move it to a member var was so I can check if it is already playing so wont restart it mid way, I suspected that was what creating the issue, but alas, no.
     
  12. FuguFirecracker

    FuguFirecracker

    Joined:
    Sep 20, 2011
    Posts:
    249
    That code works 100% as expected.
    Try it and see on a new scene.. Two sprites; one falls onto `tother.
    Then add|swap in the code that attempts to do what you want to do.
    Try to pin point the place where it all falls down...
     
  13. flashframe

    flashframe

    Joined:
    Feb 10, 2015
    Posts:
    399
    I presume not, but is the object you are tweening being moved by physics as part of the collision event?
     
  14. FuguFirecracker

    FuguFirecracker

    Joined:
    Sep 20, 2011
    Posts:
    249
    Yo FF! ;)

    I tested it using physics [RigidBody2D] with my little snippet and there are no issues.
    Sprite falls... hits second sprite. Plays Sequence in full... resumes with the physics (falling)
     
    flashframe likes this.
  15. indieDoroid

    indieDoroid

    Joined:
    Jan 25, 2016
    Posts:
    246

    Awesome!! Thank you
     
  16. Hubi_C

    Hubi_C

    Joined:
    Mar 14, 2018
    Posts:
    11
    Hi,

    in the documentation it says:
    A tween (Sequence or Tweener) can be nested only inside a single other Sequence, meaning you can't reuse the same tween in multiple Sequences.

    Is there any way to clone a sequence or any other way to reuse a same tween multiple sequences?
     
  17. Katori

    Katori

    Joined:
    Nov 30, 2009
    Posts:
    60
    Hi, I'm a big fan of DOTween and am trying to use it exclusively in this project, but I am having trouble getting Rigidbodies to tween. The Rigidbody has no tweening extension methods. No DOMove, DORotate, etc. I have the DOTweenModulePhysics.dll imported in my project (although Unity says "No MonoBehaviour scripts in the file") and the project compiles and runs besides this.

    I'm on Unity 2018.2.5, targeting WebGL, .NET Standard 2.0. Any ideas? Thanks.
     
  18. imtrobin

    imtrobin

    Joined:
    Nov 30, 2009
    Posts:
    1,545
    Hi, I'm trying to do a spin wheel, where I model it in 2 states.
    1. When wheel is spin, I spin at a constant rotation (e.g 360 deg per second)
    2. When I receive a reply from server, I will tween the rotation to desired rotation angle.

    Code (CSharp):
    1. DOTween.To ( value => SpinWheelRootRectTransform.eulerAngles = new Vector3 (0,0,value)
    2. ,currentRotationZ,targetAngle,timeToStop).SetEase (Ease.OutQuad);
    The question is how do I calculate the duration so the speed in state 1 is same as starting speed on state 2. When I use Speed = Distance/Time, it is wrong because it does not take into account of the deceleration, and the wheel moves slightly speed up when it enters 2.
     
  19. FuguFirecracker

    FuguFirecracker

    Joined:
    Sep 20, 2011
    Posts:
    249
    Assuming that you've Setup DOTween using the DOTween Utility Panel:
    dtUtilityPanel.png

    Please post your script. Feel free to omit superfluous methods. Do Include relevant properties and fields.
     
  20. FuguFirecracker

    FuguFirecracker

    Joined:
    Sep 20, 2011
    Posts:
    249
    Code (CSharp):
    1. .SetSpeedBased()
     
  21. FuguFirecracker

    FuguFirecracker

    Joined:
    Sep 20, 2011
    Posts:
    249
    Hmm... let me search this thread for an answer...
    Oh! Found it !

    Kidding aside...
    There are a myriad of ways to reuse tweens dependent on what you're trying to accomplish.
    Your Q is a little too broad to get a concise reply.

    The answer to "How do I reuse this tween?" is: "What do you want to do with it?"
     
  22. Katori

    Katori

    Joined:
    Nov 30, 2009
    Posts:
    60
    Yes, I have used Setup DOTween, and I was talking about Unity giving that message in your Physics DLL, not my code.

    Here is my code that throws an error. I added transform.DORotate just to illustrate that DG.Tweening is importing and works fine.
    Code (CSharp):
    1. using DG.Tweening;
    2.  
    3. public class PlayerController : MonoBehaviour
    4.     {
    5.         private bool DoHorizontalAdjust = true;
    6.         private float RotationFactor = 5f;
    7.  
    8.         private void FixedUpdate()
    9.         {
    10.             if (DoHorizontalAdjust)
    11.             {
    12.                 Rb.DORotate(new Vector3(0, Input.GetAxis("Horizontal") * Time.fixedDeltaTime * RotationFactor, 0), 0.01f, RotateMode.LocalAxisAdd);
    13.                 transform.DORotate(new Vector3(0, Input.GetAxis("Horizontal") * Time.fixedDeltaTime * RotationFactor, 0), 0.01f, RotateMode.LocalAxisAdd);
    14.             }
    15.         }
    16.     }
    And here is the error:
    Error    CS1929    'Rigidbody' does not contain a definition for 'DORotate' and the best extension method overload 'ShortcutExtensions.DORotate(Transform, Vector3, float, RotateMode)' requires a receiver of type 'Transform'


    Any help you could provide would be appreciated. Do I need to add another using for the Physics DLL or something?
     
  23. FuguFirecracker

    FuguFirecracker

    Joined:
    Sep 20, 2011
    Posts:
    249
    MY Physics DLL?
    Not YOUR code!?
    Of course... Nothing wrong with your code... ;)

    It's missing
    Code (CSharp):
    1. using UnityEngine;
    ... We can overlook that that. But I don't think the compiler will.

    And what's Rb? Where do you define this? How does FixedUpdate get a reference to Rb?
    It would appear that you did not include all pertinent fields and || properties.
    Although my hunch is the missing 'using' statement.

    I am not the Author of DOTween
     
  24. Katori

    Katori

    Joined:
    Nov 30, 2009
    Posts:
    60
    My apologies, I thought you were the author of DOTween. However, that being said, there is nothing wrong with my code. My player controller is complex and I only posted a snippet. Here is a better snippet:
    Code (CSharp):
    1. using UnityEngine;
    2. using DG.Tweening;
    3.  
    4. public class PlayerController : MonoBehaviour
    5.     {
    6.         private bool DoHorizontalAdjust = true;
    7.         private float RotationFactor = 5f;
    8.  
    9.         private Rigidbody Rb;
    10.  
    11.         private void Start(){
    12.             Rb = GetComponent<Rigidbody>();
    13.         }
    14.  
    15.         private void FixedUpdate()
    16.         {
    17.             if (DoHorizontalAdjust)
    18.             {
    19.                 Rb.DORotate(new Vector3(0, Input.GetAxis("Horizontal") * Time.fixedDeltaTime * RotationFactor, 0), 0.01f, RotateMode.LocalAxisAdd);
    20.                 transform.DORotate(new Vector3(0, Input.GetAxis("Horizontal") * Time.fixedDeltaTime * RotationFactor, 0), 0.01f, RotateMode.LocalAxisAdd);
    21.             }
    22.         }
    23.     }
    Makes no difference, the issue is that Rigidbody.DORotate (or DOMove, etc.) is not there at all.
     
  25. FuguFirecracker

    FuguFirecracker

    Joined:
    Sep 20, 2011
    Posts:
    249
    Hi Hi
    Indeed! There is nothing wrong with your code!
    That last script compiles and runs just fine.
    It works on my end... DoTween shortcuts and all...

    Something is amiss with your setup.

    I could just start guessing with things that might be wrong, but without seeing your project, the best advice I can offer is to delete all DoTween related folders and the DOTweenSettings ScriptableObject.

    Then Update, Download, Reimport, and Setup DOTween again.
    If you want to start a new blank project and just try the script you posted there... If you still have troubles, I can go over that project with you.

    Let me know if you figure it out.
     
  26. username132323232

    username132323232

    Joined:
    Dec 9, 2014
    Posts:
    443
    Is there an easy way to simulate pendulum-type rotation? For example, rotate a gameObject -30 degrees, then 30 degrees relative to the vertical (with LoopType.Yoyo). DORotate can rotate in one direction, but not symmetrically relative to the initial rotation.
     
  27. FuguFirecracker

    FuguFirecracker

    Joined:
    Sep 20, 2011
    Posts:
    249
    Recursion.

    Code (CSharp):
    1. private void SwingIt(float halfArc)
    2.     {
    3.         transform.DORotate(new Vector3(0, 0, halfArc), 3f)
    4.             .OnComplete(() => SwingIt(-halfArc));
    5.     }
     
    username132323232 likes this.
  28. imtrobin

    imtrobin

    Joined:
    Nov 30, 2009
    Posts:
    1,545
    Thanks for the reply. I have tried this before but it's not giving me right results either. I set the duration to the rotation speed but it still speeds up because it needs to stop at the correct angle.


    Code (CSharp):
    1. SetSpeedBased (the duration will representnumber of units the tween moves x second)
    2.  
    3.      float CurrentRotationSpeed = 360; // 360 deg per second
    4.  
    5.      void Update ()
    6.      {
    7.         // this is initial how fast the wheel is spinning, will be disabled when tween is active
    8.          SpinWheelTransform.eulerAngles = new Vector3 (0,0, SpinWheelTransform.eulerAngles.z - CurrentRotationSpeed * Time.deltaTime);
    9.      }
    10.  
    11. // stopping the wheel
    12. float totalRotationDistance = 360f * numberOfSpinsBeforeStop + targetAngle + SpinWheel.eulerAngles.z;
    13.  
    14. DOTween.To ( value => SpinWheelTransform.eulerAngles = new Vector3 (0,0,value),
    15.                                                          currentRotationZ,
    16.                                                          targetAngle,
    17.                                                         CurrentRotationSpeed)
    18. .SetSpeedBased ()
    19. .SetEase (Ease.OutQuad)
    20. //.SetEase (Ease.Linear) // this works but doesn't decelerate, just suddent stop when reached
     
  29. FuguFirecracker

    FuguFirecracker

    Joined:
    Sep 20, 2011
    Posts:
    249

    If I needed to spin a wheel...
    I would not use Update().

    Call a method from Start() that sets your tween in motion.
    I Always rotate in 90 degrees and then 90 degrees and then 90 degrees and then 90 degrees.
    Do this and you will always know which way your tween is rotating.

    I'll get you started:
    Code (CSharp):
    1. private void Start()
    2.     {
    3.         InitSpin();
    4.     }
    5.  
    6.     private void InitSpin()
    7.     {
    8.         // 1/4 of a second... 1/4 of a rotation
    9.         transform.DORotate(new Vector3(0, 0, 90), 0.25f)
    10.             .SetEase(Ease.InCubic)
    11.             .OnComplete(ContinueToSpin);
    12.     }
    13.  
    14.     private void ContinueToSpin()
    15.     {
    16.         transform.DORotate(new Vector3(0, 0, 90), 0.25f)
    17.             .SetLoops(-1, LoopType.Incremental)
    18.             .SetEase(Ease.Linear)
    19.             .SetRelative();
    20.     }
    21.  
    22.     public void HaltSpin()
    23.     {
    24.         // You should be able to figure this out
    25.         // You'll wanna Ease.Out
    26.         // And maybe change all methods to be SetSpeedBased
    27.        
    28.     }
     
  30. imtrobin

    imtrobin

    Joined:
    Nov 30, 2009
    Posts:
    1,545
    Hmm, I'm not seeing a difference except there is an EaseIn at the spin start. I would still have the same issue when I have to HaltSpin, because the EaseOut would have a difference spin speed from ContinueToSpin. The issue is I'm using DoTween to tween to a particular rotation angle, not tween the speed to zero (where most spin wheel implementation are doing)

    Anyway, I'm trying to use a custom AnimationCurve to smooth out the deccelearation to hide the speed change subtlely, there is still a noticeable change (to me maybe cause I'm aware of it), but it looks alot better now . Thanks.
     
  31. FuguFirecracker

    FuguFirecracker

    Joined:
    Sep 20, 2011
    Posts:
    249
    Hi.
    I did not write code specific to your use case. The intention was to show that you can control the animation by having different tweens control different stages of your movement.

    If you want to slow down your tween overtime, use TimeScale.

    Code (CSharp):
    1. using UnityEngine;
    2. using DG.Tweening;
    3.  
    4.  
    5. public class Spinner : MonoBehaviour
    6. {
    7.     private Tweener _tweener;
    8.     private const float SPEED = 500;
    9.  
    10.  
    11.     private void Start()
    12.     {
    13.         InitSpin();
    14.     }
    15.  
    16.     private void Update()
    17.     {
    18.         if (Input.GetKeyDown(KeyCode.Space))
    19.         {
    20.             WindDown(42);
    21.         }
    22.     }
    23.  
    24.     private void InitSpin()
    25.     {
    26.      
    27.         _tweener = transform.DORotate(new Vector3(0, 0, 90), SPEED)
    28.             .SetSpeedBased()
    29.             .SetEase(Ease.InCubic)
    30.             .OnComplete(ContinueToSpin);
    31.     }
    32.  
    33.     private void ContinueToSpin()
    34.     {
    35.         _tweener = transform.DORotate(new Vector3(0, 0, 90), SPEED)
    36.             .SetSpeedBased()
    37.             .SetLoops(-1, LoopType.Incremental)
    38.             .SetEase(Ease.Linear)
    39.             .SetRelative();
    40.     }
    41.  
    42.     public void WindDown(float endRotation)
    43.     {
    44.         _tweener.Kill(true);
    45.         var ts = _tweener.timeScale;
    46.         // We're gonna need simple math to decide how fast we want to decelerate
    47.         // 1/96th should be a good wind-down
    48.         _tweener = transform.DORotate(new Vector3(0, 0, 3.75F), SPEED)
    49.             .SetSpeedBased()
    50.             .SetLoops(95, LoopType.Incremental)
    51.             .SetEase(Ease.Linear)
    52.             .SetRelative()
    53.             .OnStepComplete(() =>
    54.             {
    55.                 ts -= 0.002f;
    56.                 _tweener.timeScale = ts;
    57.             })
    58.             .OnComplete(() => HaltSpin(endRotation, ts));
    59.     }
    60.  
    61.     private void HaltSpin(float endRotation, float timeScale)
    62.     {
    63.         var finalArc = 360 - Mathf.Abs(transform.eulerAngles.z) + endRotation;
    64.  
    65.         _tweener = transform.DORotate(new Vector3(0, 0, finalArc), SPEED, RotateMode.LocalAxisAdd)
    66.             .SetSpeedBased()
    67.             .SetEase(Ease.Linear)
    68.             .OnUpdate(() => _tweener.timeScale -= 0.01f);
    69.      
    70.         _tweener.timeScale = timeScale;
    71.     }
    72. }
    This code does contain some redundancies and it can be simplified, but I've left it artificially verbose such that you get an understanding of the kind of manipulations one may do.

    Modify as required, or free to completely ignore ;)
     
    Last edited: Oct 16, 2018
  32. username132323232

    username132323232

    Joined:
    Dec 9, 2014
    Posts:
    443
    What a beautiful solution! Thank you!
     
    FuguFirecracker likes this.
  33. NaleczP

    NaleczP

    Joined:
    Apr 4, 2018
    Posts:
    2
    Hello

    Is it possible to run tweens using unity job system or with any other method that would make them run in parallel to main thread ?

    In short, thing that im trying to accomplish is a loading screen with few simple tweens that won't freeze when new scene is being loaded. The thing I want to avoid is rewriting initialization scripts on all my scenes so they don't hog main thread. (let's say in some scenes, all Awake() methods take a couple of seconds to complete)

    If that's not possible is there any other method I could try using ?
     
  34. FuguFirecracker

    FuguFirecracker

    Joined:
    Sep 20, 2011
    Posts:
    249
    SceneManager.LoadSceneAsync

    The DOTween gameObject persists between scenes by means of DontDestroyOnLoad
    You can either set your tweened object to persist using this method or push your object to the new scene using SceneManager.MoveGameObjectToScene

    This is not DOTween related. You need to learn how to use the SceneManager Class and AsyncOperations

    As this is a DOTween forum, I'm not gonna do a tutorial on the SceneManager.

    If you're really stuck, PM me with the script you're trying and if I feel like avoiding my work, I'll try to help you out... :)


     
  35. FuguFirecracker

    FuguFirecracker

    Joined:
    Sep 20, 2011
    Posts:
    249
    Public service announcement:

    Stop using DOTween in Update || FixedUpdate || LateUpdate
    DOTween updates itself.

    How do you expect to tween a value between frames?
     
    username132323232 likes this.
  36. NaleczP

    NaleczP

    Joined:
    Apr 4, 2018
    Posts:
    2
    I do understand that and sadly that's is not where my problem lies. I do have a singleton loading screen that persists between scenes and scenes are loaded using SceneManager.LoadSceneAsync, but this is not the case. If I understand correctly it's because LoadSceneAsync simply doesn't block code execution in the main thread, which means rest of the code will run if there are resources available. This is the actual problem - loading scene uses 100% of core available to the main thread, so it doesn't matter if the code execution isn't being blocked - there is no computing power available to achieve anything above 0 fps (aka everything freezes until scene is basically loaded). I realise I can fix freezes by optimizing parts of the code that hog all the resources during loading, but I want to avoid doing that if it's possible.

    That's why im asking if it's possible to somehow run tweens in parallel to the main thread (ideally on different thread with different CPU core assigned), so they actually have resources to be run at anything above 0 fps.
     
  37. FuguFirecracker

    FuguFirecracker

    Joined:
    Sep 20, 2011
    Posts:
    249
    It is possible to run any* code in multiple threads, if you understand how to run code in multiple threads.
    Your asking about multi-trheaded development.

    DoTween, in off itself, contains no special use cases to allow || disallow doing this.

    "How do I write a multi-threaded application?" is way beyond the scope of "How do I use DoTween?"

    L
    oading a scene Async should not consume all available resources...
    How do you code a single scene that consumes all available CPU cycles?
    Never mind... that was rhetorical ;)

    *exceptions exits. Many.
     
  38. imtrobin

    imtrobin

    Joined:
    Nov 30, 2009
    Posts:
    1,545
    Yes, I can manipulate the timescale to decelerate correctly. It's working fine now, just need to tweak the deceleration slowdown properly. Thanks!
     
    FuguFirecracker likes this.
  39. AVK79

    AVK79

    Joined:
    Oct 18, 2016
    Posts:
    2
    Unity 2018.2.13f1

    DOVirtual.DelayedCall callback seems to fire almost immediately instead of wanted delay.
    I think this happens when when DelayedCall is called just after loading the scene such as in first Update().
    The current fix is to use DOVirtual.Float...
    So instead of
    DOVirtual.DelayedCall(delay, () => { ... });
    I use
    DOVirtual.Float(0, 1, delay, (float progress) => { })
    .OnComplete(()=>
    {
    ...
    });
    DOVirtual.Float's delay work as expected, while DelayedCall fires immediately.
    I would prefer DelayedCall fixed rather than to replace all places in code with DOVirtual.Float fix.
     
  40. evoros

    evoros

    Joined:
    Dec 2, 2015
    Posts:
    3
    Sorry for leaving this for a month, but does anyone know what N3uRo meant? Can I use extension methods if I change something to ref, or I can't? Sorry, I have a poor understanding of how lambdas work.
     
  41. CanisLupus

    CanisLupus

    Joined:
    Jul 29, 2013
    Posts:
    292
    UPDATE: According to this issue, which is similar, this may be a Unity bug (not only for Hololens, unfortunately). The solution for us was to downgrade to DOTween 1.1.710, before the big changes.

    Still, do check your contact form, since I got an error and it may still not be working. :)

    ---------------------------------------------------------------------

    Hey @Izitmee!

    I need an yearly email/message with you or so XD. I hope you are well. ;)

    I wanted your assistance (or other users') since we've updated to DOTween 1.2.135 (all modules installed) and our UWP builds are getting this in Visual Studio 2017 (15.8.8), and not compiling:

    1> Copying unprocessed assemblies...
    1> Running AssemblyConverter...
    1> Failed to fix references for method System.Type DG.Tweening.Core.Utils::GetLooseScriptType(System.String)
    1> Failed to fix references for type DG.Tweening.Core.Utils
    1> System.Exception: Failed to resolve System.AppDomain
    1> at Unity.ModuleContext.Retarget(TypeReference type, GenericContext context)
    1> at Unity.ModuleContext.Retarget(MethodReference method, GenericContext context)
    1> at Unity.FixReferencesStep.Visit(MethodDefinition method, GenericContext context)
    1> at Unity.FixReferencesStep.Visit(TypeDefinition type)
    1> at Unity.TypeDefinitionDispatcher.DispatchType(TypeDefinition type)
    1> at Unity.TypeDefinitionDispatcher..ctor(ModuleDefinition module, ITypeDefinitionVisitor visitor)
    1> at Unity.FixReferencesStep.ProcessModule()
    1> at Unity.ModuleStep.Execute()
    1> at Unity.FixReferencesStep.Execute()
    1> at Unity.Step.Execute(OperationContext operationContext, IStepContext previousStepContext)
    1> at Unity.Operation.Execute()
    1> at Unity.Program.Main(String[] args)

    Apparently the problems begin inside the Editor (although the VS project gets generated):

    Reference Rewriter found some errors while running with command --target="Temp\StagingArea\DOTween.dll" --additionalreferences="Temp\StagingArea","C:\Program Files (x86)\Windows Kits\10\UnionMetadata\10.0.17134.0\Facade","C:\Program Files (x86)\Windows Kits\10\References\10.0.17134.0(...)

    Error: method `System.Reflection.MethodBase System.Exception::get_TargetSite()` doesn't exist in target framework. It is referenced from DOTween.dll at System.Boolean DG.Tweening.Tween::OnTweenCallback(DG.Tweening.TweenCallback).
    Error: method `System.Reflection.MethodBase System.Exception::get_TargetSite()` doesn't exist in target framework. It is referenced from DOTween.dll at System.Boolean DG.Tweening.Tween::OnTweenCallback(DG.Tweening.TweenCallback`1<T>,T).
    Error: method `System.Reflection.MethodBase System.Exception::get_TargetSite()` doesn't exist in target framework. It is referenced from DOTween.dll at System.Boolean DG.Tweening.Tweener::DoStartup(DG.Tweening.Core.TweenerCore`3<T1,T2,TPlugOptions>).
    Error: method `System.Reflection.MethodInfo System.Type::GetMethod(System.String,System.Reflection.BindingFlags)` doesn't exist in target framework. It is referenced from DOTween.dll at System.Void DG.Tweening.Core.DOTweenComponent::Awake().
    Error: type `System.AppDomain` doesn't exist in target framework. It is referenced from DOTween.dll at System.Type DG.Tweening.Core.Utils::GetLooseScriptType(System.String).
    Error: type `System.AppDomain` doesn't exist in target framework. It is referenced from DOTween.dll at System.Type DG.Tweening.Core.Utils::GetLooseScriptType(System.String).
    Error: method `System.AppDomain System.AppDomain::get_CurrentDomain()` doesn't exist in target framework. It is referenced from DOTween.dll at System.Type DG.Tweening.Core.Utils::GetLooseScriptType(System.String).
    Error: type `System.AppDomain` doesn't exist in target framework. It is referenced from DOTween.dll at System.Type DG.Tweening.Core.Utils::GetLooseScriptType(System.String).
    Error: method `System.Reflection.Assembly[] System.AppDomain::GetAssemblies()` doesn't exist in target framework. It is referenced from DOTween.dll at System.Type DG.Tweening.Core.Utils::GetLooseScriptType(System.String).

    Reference rewriter: Error: method `System.Reflection.MethodBase System.Exception::get_TargetSite()` doesn't exist in target framework. It is referenced from DOTween.dll at System.Boolean

    Reference rewriter: Error: method `System.Reflection.MethodBase System.Exception::get_TargetSite()` doesn't exist in target framework. It is referenced from DOTween.dll at System.Boolean

    Reference rewriter: Error: method `System.Reflection.MethodBase System.Exception::get_TargetSite()` doesn't exist in target framework. It is referenced from DOTween.dll at System.Boolean

    Reference rewriter: Error: method `System.Reflection.MethodInfo System.Type::GetMethod(System.String,System.Reflection.BindingFlags)` doesn't exist in target framework. It is referenced from DOTween.dll

    Reference rewriter: Error: type `System.AppDomain` doesn't exist in target framework. It is referenced from DOTween.dll at System.Type DG.Tweening.Core.Utils::GetLooseScriptType(System.String).

    Reference rewriter: Error: type `System.AppDomain` doesn't exist in target framework. It is referenced from DOTween.dll at System.Type DG.Tweening.Core.Utils::GetLooseScriptType(System.String).

    Reference rewriter: Error: method `System.AppDomain System.AppDomain::get_CurrentDomain()` doesn't exist in target framework. It is referenced from DOTween.dll at System.Type

    Reference rewriter: Error: type `System.AppDomain` doesn't exist in target framework. It is referenced from DOTween.dll at System.Type DG.Tweening.Core.Utils::GetLooseScriptType(System.String).

    Reference rewriter: Error: method `System.Reflection.Assembly[] System.AppDomain::GetAssemblies()` doesn't exist in target framework. It is referenced from DOTween.dll at System.Type

    We are using Unity 2017.4.11f1. Do you have any idea of what could be going on? Anything to check in particular?

    Cheers!
    Daniel Lobo

    PS: I tried the direct contact form first, but got this error (see attachment)
     

    Attached Files:

    Last edited: Nov 6, 2018
  42. chanon81

    chanon81

    Joined:
    Oct 6, 2015
    Posts:
    125
    I couldn't find this in the documentation ... how can I get my own components/properties to show up in the DO Tween Animation inspector (DOTween Pro)?
     
  43. mflux

    mflux

    Joined:
    Oct 19, 2017
    Posts:
    7
    I searched everywhere but could not find an answer to this.

    I have DOTweenPro
    (DOTween v1.2.135)
    (DOTweenPro v1.0.075)

    I am trying to find a tween in .cs via its ID, then play it. The tween is added via Do Tween Animation component (Pro feature?) and the ID is added to the ID attribute ("Item Attached").

    Nothing works so far:

    Code (CSharp):
    1.             List<Tween> tweens = DOTween.TweensByTarget(gameObject);
    2.             if (tweens != null)
    3.             {
    4.                 tweens.ForEach((t) => Debug.Log(t.stringId));
    5.             }
    Debug log says "Null", as in, the stringId is null. This is true for .id as well.

    This also does not work

    Code (CSharp):
    1. DOTween.Play("Item Attached");
    Sometimes, tweens will also return null as well (no tweens found) even though the tween is clearly on the object.

    How do I actually get a Tween via id, and play it? Thank you!
     
  44. flashframe

    flashframe

    Joined:
    Feb 10, 2015
    Posts:
    399
    If you are using a gameobject as an ID, then you need to supply the gameobject to get the tween reference. When you set the id you decide what to use: an object, a string, an int, or whatever.

    So in your first example, you could debug gameObject.name

    If you want to use "Item Attached" as an ID, then you need to set the id to "Item Attached" when you setup your tween.
     
  45. mflux

    mflux

    Joined:
    Oct 19, 2017
    Posts:
    7
    Not gameObject.name/id, I'm talking about this ID:



    Since a gameObject can have more than one DOTween Animation components, how do you identify them apart from each other? I'm assuming using this ID field? Or is that the wrong assumption?
     
  46. flashframe

    flashframe

    Joined:
    Feb 10, 2015
    Posts:
    399
    Oh, sorry I didn't realise you were using the animation component. I don't use that, so I'm not sure of the answer. Sounds like you have the right assumption - setting the id should allow you to control each tween individually.
     
  47. FuguFirecracker

    FuguFirecracker

    Joined:
    Sep 20, 2011
    Posts:
    249
    stevenatunity and flashframe like this.
  48. Boom_Shaka

    Boom_Shaka

    Joined:
    Aug 31, 2017
    Posts:
    105
    Sorry, nooby q here (searched but couldn't find the answer): if I destroy the game object (i.e. it "dies") do I also need to kill the Tween attached to it? Will "On Disable:Kill" in the Virtual Manager work?

    Thanks in advance
     
  49. sporcehorrier

    sporcehorrier

    Joined:
    Feb 19, 2015
    Posts:
    4
    I can't get the PlayMaker Pause action to work anymore. I moved to Unity 2018.2.15 and only use actions to shake an object. For some reason the Pause action no longer works as it used to; it's ignored, and the shake continues on. I do have the latest public DOTween and the rest of it works just like before, but the Pause is apparently broken. Any tips at this stage are helpful, thanks.
     
  50. indieDoroid

    indieDoroid

    Joined:
    Jan 25, 2016
    Posts:
    246
    Hi guys,

    I'm stuck with DoPath. Getting this error about the transform.

    error CS1928: Type `UnityEngine.Transform' does not contain a member `DOPath' and the best extension method overload `DG.Tweening.ShortcutExtensions.DOPath(this UnityEngine.Transform, UnityEngine.Vector3[], float, DG.Tweening.PathType, DG.Tweening.PathMode, int, UnityEngine.Color?)' has some invalid arguments

    Code (CSharp):
    1.  
    2.  
    3. public Vector3[] _wayPointsA = new[] { new Vector3(388f, 290.8f, 0f), new Vector3(390.6f, 290.8f, 0f), new Vector3(392.2f, 288.8f, 0f), new Vector3(390.8f, 286f, 0f), new Vector3(386.5f, 282.4f, 0f) };
    4.  
    5. public Transform _transform;
    6.  
    7. public void Test()
    8. {
    9.         _transform.DOPath(_wayPointsA , _duration, PathType.CatmullRom, PathMode.Full3D,   _resolution).SetEase(Ease.InSine).SetLoops(-1, LoopType.Restart);
    10. }
    11.  
    Any advice would be highly appreciated.
    Thanks!
     
unityunity