Skip to content

cpp-bender/DOTween-Data-Wrapper

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

28 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

DOTween-Data-Wrapper

Table Of Contents

Details

Introduction

A component-based DOTween data wrapper (DDW), built specifically to make life easier for developers.

Normal DOTween Usage

    using UnityEngine;
    using DG.Tweening;
 
    public class DOTweenGenericWay : MonoBehaviour
    {
        private Tween tween;

        private void Start()
        {
            tween = transform.DOMoveX(5f, 1f)
                .SetDelay(.2f)
                .SetEase(Ease.OutSine)
                .SetAutoKill(true)
                .SetRecyclable(true)
                .Play();
        }
    }
  • The example above shows how to do tweening using one of the DOTween's functions. Even though DOTween is a great tweening library, I believe I can make it much more easier for the developers.

DDW DOTween Usage

Recommended Way

   using UnityEngine;
   using DG.Tweening;

   public class DDWSolution : MonoBehaviour
   {
       public BaseTweenData baseTweenData;

       private Tween tween;

       private void Start()
       {
           tween = baseTweenData.GetTween(gameObject).Play();
       }
   }
  • With the DDW (DOTween Data Wrapper), you don't need to know your tween type (MoveTween, RotateTween, ScaleTween, etc.). You just need a "BaseTweenData" object to get the data you need in order to do tweening. At this moment, you migth ask a question "How in the earth would it know what tween type I want it to tween?". It is simple indeed. You tell it how to tween in the editor like below.

example_1

Note the following

  • In order to use GetTween function, you need to pass in a gameObject. There is also a way where you don't need to pass in any argument.

DDW Other DOTween Usage

Not Recommended Way

   using UnityEngine;
   using DG.Tweening;
   
   public class TestCubeController : BaseTestController
   {
       public MoveTweenData tweenData;

       private Tween tween;

       private void Start()
       {
           tween = transform.DOMove(tweenData.EndValue, tweenData.Duration)
               .SetDelay(.2f)
               .SetEase(Ease.OutSine)
               .SetAutoKill(true)
               .SetRecyclable(true)
               .Play();
       }
}

If you don't feel confident with the gameObject you have to pass in, you might want to use DDW as shown above. Note that, In order to use DDW like that, you need a "XXXTwenData" object (in this case, it's MoveTweenData) not a BaseTweenData. You also make sure that you no longer will change the tween data in the editor with a different tween data anymore such as ScaleTweenData,RotateTweenData, etc.

Components

Supports the following components

  • Transform
  • Mesh Renderer

Transform

1 - Move Tween

  • DOMove
  • DOMoveX/DOMoveY/DOMoveZ
  • DOLocalMove
  • DOLocalMoveX/DOLocalMoveY/DOLocalMoveZ

2 - Rotate Tween

  • DORotate
  • DOLocalRotate
  • DORotateQuaternion
  • DOLocalRotateQuaternion

3 - Scale Tween

  • DOScale
  • DOScaleX/DOScaleY/DOScaleZ

Mesh Renderer

1 - Material

  • DOColor

Examples

Example 1

Example.1.mp4

Example 2

Example.2.mp4

Final Words

About

Light DOTween wrapper to make life easier for devs

Resources

Stars

Watchers

Forks

Packages

No packages published

Languages