1
0
mirror of https://github.com/Cardidi/dotween-upm-fork.git synced 2025-12-20 01:06:02 +08:00

Fixed StringPlugin (DOText) not calculating SpeedBased duration correctly in case of rich text

This commit is contained in:
Demigiant 2015-12-05 10:38:00 +01:00
parent 9d99649725
commit 28cf80f3cd
55 changed files with 88 additions and 3 deletions

1
.gitignore vendored
View File

@ -21,6 +21,7 @@ ExternalPluginsTestsAndExamples*
*.Unity*/Assets/-tk2d*
*.Unity*/Assets/Console*Pro*
*.Unity*/Assets/Text*Mesh*Pro*
*.Unity*/Assets/CodeStage
.vs
*HOPoolOperator*
*HOTools*

View File

@ -10,4 +10,9 @@ public class TempPro : MonoBehaviour
{
if (Input.GetKeyDown(KeyCode.Space)) anime.DORestart(true);
}
public void OnCreated()
{
Debug.Log("Tween created > " + anime.tween);
}
}

View File

@ -0,0 +1,22 @@
using UnityEngine;
using UnityEngine.UI;
using System.Collections;
using DG.Tweening;
public class RichText : BrainBase
{
public float duration = 6;
public bool speedBased = true;
public ScrambleMode scrambleMode;
public Text txtRichA, txtA;
IEnumerator Start()
{
yield return new WaitForSeconds(0.6f);
TweenParams tp = new TweenParams().SetEase(Ease.Linear);
tp.SetSpeedBased(speedBased);
txtRichA.DOText("This is a <color=#ff0000>colored <color=#00ff00>text</color></color> and normal text", duration, true, scrambleMode).SetAs(tp);
txtA.DOText("This is a colored text and normal text", duration, true, scrambleMode).SetAs(tp);
}
}

View File

@ -0,0 +1,12 @@
fileFormatVersion: 2
guid: 423ce3c43b35c2b4da118113d92a8d71
timeCreated: 1449307086
licenseType: Free
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

Binary file not shown.

View File

@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 054d4febe89456b4ea2e1f9ee294a824
timeCreated: 1449307077
licenseType: Free
DefaultImporter:
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,16 @@
using UnityEngine;
using System.Collections;
using DG.Tweening;
public class ShakeInverse : MonoBehaviour
{
public Transform trans;
IEnumerator Start()
{
yield return new WaitForSeconds(0.6f);
Tween t = trans.DOShakePosition(4, 2).SetAutoKill(false);
t.Complete();
t.PlayBackwards();
}
}

View File

@ -0,0 +1,12 @@
fileFormatVersion: 2
guid: dc24d72cc01112842b4a52a27d12b95a
timeCreated: 1448968725
licenseType: Free
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

Binary file not shown.

View File

@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 8e0097dc8e625664cbc7b40704b6ea45
timeCreated: 1448968716
licenseType: Free
DefaultImporter:
userData:
assetBundleName:
assetBundleVariant:

View File

@ -1,2 +1,2 @@
m_EditorVersion: 5.2.2f1
m_EditorVersion: 5.2.3f1
m_StandardAssetsVersion: 0

View File

@ -32,7 +32,7 @@ namespace DG.Tweening
public class DOTween
{
/// <summary>DOTween's version</summary>
public static readonly string Version = "1.1.115";
public static readonly string Version = "1.1.120";
///////////////////////////////////////////////
// Options ////////////////////////////////////

View File

@ -59,7 +59,8 @@ namespace DG.Tweening.Plugins
public override float GetSpeedBasedDuration(StringOptions options, float unitsXSecond, string changeValue)
{
float res = changeValue.Length / unitsXSecond;
// float res = changeValue.Length / unitsXSecond;
float res = (options.richTextEnabled ? options.changeValueStrippedLength : changeValue.Length) / unitsXSecond;
if (res < 0) res = -res;
return res;
}

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.