diff --git a/Assets/Plugins/Demigiant/DOTweenPro/DOTweenAnimation.cs b/Assets/Plugins/Demigiant/DOTweenPro/DOTweenAnimation.cs index c7e7b21..6580554 100644 --- a/Assets/Plugins/Demigiant/DOTweenPro/DOTweenAnimation.cs +++ b/Assets/Plugins/Demigiant/DOTweenPro/DOTweenAnimation.cs @@ -1,4 +1,4 @@ -// Author: Daniele Giardini - http://www.demigiant.com +// Author: Daniele Giardini - http://www.demigiant.com // Created: 2015/03/12 15:55 using System; @@ -8,7 +8,7 @@ using UnityEngine; #if true // UI_MARKER using UnityEngine.UI; #endif -#if false // TEXTMESHPRO_MARKER +#if true // TEXTMESHPRO_MARKER using TMPro; #endif @@ -355,7 +355,7 @@ namespace DG.Tweening tween = ((tk2dBaseSprite)target).DOColor(endValueColor, duration); break; #endif -#if false // TEXTMESHPRO_MARKER +#if true // TEXTMESHPRO_MARKER case TargetType.TextMeshProUGUI: tween = ((TextMeshProUGUI)target).DOColor(endValueColor, duration); break; @@ -398,7 +398,7 @@ namespace DG.Tweening tween = ((tk2dBaseSprite)target).DOFade(endValueFloat, duration); break; #endif -#if false // TEXTMESHPRO_MARKER +#if true // TEXTMESHPRO_MARKER case TargetType.TextMeshProUGUI: tween = ((TextMeshProUGUI)target).DOFade(endValueFloat, duration); break; @@ -423,7 +423,7 @@ namespace DG.Tweening break; } #endif -#if false // TEXTMESHPRO_MARKER +#if true // TEXTMESHPRO_MARKER switch (targetType) { case TargetType.TextMeshProUGUI: tween = ((TextMeshProUGUI)target).DOText(endValueString, duration, optionalBool0, optionalScrambleMode, optionalString); diff --git a/Assets/Plugins/Demigiant/DOTweenPro/DOTweenTextMeshPro.cs b/Assets/Plugins/Demigiant/DOTweenPro/DOTweenTextMeshPro.cs index 935bbee..cdfd47d 100644 --- a/Assets/Plugins/Demigiant/DOTweenPro/DOTweenTextMeshPro.cs +++ b/Assets/Plugins/Demigiant/DOTweenPro/DOTweenTextMeshPro.cs @@ -1,11 +1,11 @@ -// Author: Daniele Giardini - http://www.demigiant.com +// Author: Daniele Giardini - http://www.demigiant.com // Created: 2015/03/27 19:02 // // License Copyright (c) Daniele Giardini. // This work is subject to the terms at http://dotween.demigiant.com/license.php -#if false // MODULE_MARKER +#if true // MODULE_MARKER using System; using System.Globalization; using System.Collections.Generic; diff --git a/Assets/Plugins/Demigiant/DOTweenPro/Editor/DOTweenAnimationInspector.cs b/Assets/Plugins/Demigiant/DOTweenPro/Editor/DOTweenAnimationInspector.cs index 69f753d..0ac6e9a 100644 --- a/Assets/Plugins/Demigiant/DOTweenPro/Editor/DOTweenAnimationInspector.cs +++ b/Assets/Plugins/Demigiant/DOTweenPro/Editor/DOTweenAnimationInspector.cs @@ -1,4 +1,4 @@ -// Author: Daniele Giardini - http://www.demigiant.com +// Author: Daniele Giardini - http://www.demigiant.com // Created: 2015/03/12 16:03 using System; @@ -15,7 +15,7 @@ using DOTweenSettings = DG.Tweening.Core.DOTweenSettings; #if true // UI_MARKER using UnityEngine.UI; #endif -#if false // TEXTMESHPRO_MARKER +#if true // TEXTMESHPRO_MARKER using TMPro; #endif @@ -120,7 +120,7 @@ namespace DG.DOTweenEditor { DOTweenAnimation.AnimationType.Text, new[] { typeof(tk2dTextMesh) } } }; #endif -#if false // TEXTMESHPRO_MARKER +#if true // TEXTMESHPRO_MARKER static readonly Dictionary _TMPAnimationTypeToComponent = new Dictionary() { { DOTweenAnimation.AnimationType.Color, new[] { typeof(TextMeshPro), typeof(TextMeshProUGUI) } }, { DOTweenAnimation.AnimationType.Fade, new[] { typeof(TextMeshPro), typeof(TextMeshProUGUI) } }, @@ -141,7 +141,7 @@ namespace DG.DOTweenEditor #if false // TK2D_MARKER "Text", #endif -#if false // TEXTMESHPRO_MARKER +#if true // TEXTMESHPRO_MARKER "Text", #endif #if true // UI_MARKER @@ -613,7 +613,7 @@ namespace DG.DOTweenEditor } } #endif -#if false // TEXTMESHPRO_MARKER +#if true // TEXTMESHPRO_MARKER if (_TMPAnimationTypeToComponent.ContainsKey(_src.animationType)) { foreach (Type t in _TMPAnimationTypeToComponent[_src.animationType]) { srcTarget = targetGO.GetComponent(t); diff --git a/Assets/Resources/DOTweenSettings.asset b/Assets/Resources/DOTweenSettings.asset new file mode 100644 index 0000000..62ebbaf --- /dev/null +++ b/Assets/Resources/DOTweenSettings.asset @@ -0,0 +1,54 @@ +%YAML 1.1 +%TAG !u! tag:unity3d.com,2011: +--- !u!114 &11400000 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 0} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 16995157, guid: a811bde74b26b53498b4f6d872b09b6d, type: 3} + m_Name: DOTweenSettings + m_EditorClassIdentifier: + useSafeMode: 1 + safeModeOptions: + logBehaviour: 2 + nestedTweenFailureBehaviour: 0 + timeScale: 1 + unscaledTimeScale: 1 + useSmoothDeltaTime: 0 + maxSmoothUnscaledTime: 0.15 + rewindCallbackMode: 0 + showUnityEditorReport: 0 + logBehaviour: 0 + drawGizmos: 1 + defaultRecyclable: 0 + defaultAutoPlay: 3 + defaultUpdateType: 0 + defaultTimeScaleIndependent: 0 + defaultEaseType: 6 + defaultEaseOvershootOrAmplitude: 1.70158 + defaultEasePeriod: 0 + defaultAutoKill: 1 + defaultLoopType: 0 + debugMode: 0 + debugStoreTargetId: 1 + showPreviewPanel: 1 + storeSettingsLocation: 0 + modules: + showPanel: 0 + audioEnabled: 1 + physicsEnabled: 1 + physics2DEnabled: 1 + spriteEnabled: 1 + uiEnabled: 1 + textMeshProEnabled: 0 + tk2DEnabled: 0 + deAudioEnabled: 0 + deUnityExtendedEnabled: 0 + epoOutlineEnabled: 0 + createASMDEF: 0 + showPlayingTweens: 0 + showPausedTweens: 0 diff --git a/Assets/Resources/DOTweenSettings.asset.meta b/Assets/Resources/DOTweenSettings.asset.meta new file mode 100644 index 0000000..ec882cc --- /dev/null +++ b/Assets/Resources/DOTweenSettings.asset.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 62d0e6972be5fb6448d02abc8a47cfb6 +NativeFormatImporter: + externalObjects: {} + mainObjectFileID: 11400000 + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Scripts/Project/UI/UI_Panel/UI_CustomSessionPanel.cs b/Assets/Scripts/Project/UI/UI_Panel/UI_CustomSessionPanel.cs index 29c51f2..6efdc28 100644 --- a/Assets/Scripts/Project/UI/UI_Panel/UI_CustomSessionPanel.cs +++ b/Assets/Scripts/Project/UI/UI_Panel/UI_CustomSessionPanel.cs @@ -1,3 +1,4 @@ +using DG.Tweening; using System; using System.Collections; using TMPro; @@ -8,6 +9,10 @@ public class UI_CustomSessionPanel : BasePanel { private string triggerID; public Action callBack; + private TextMeshProUGUI UItext; + private string fullText; + private float typingSpeed = 0.05f; + /// /// 初始化,state 0 激活另一个操作 /// @@ -16,6 +21,8 @@ public class UI_CustomSessionPanel : BasePanel this.triggerID = triggerID; callBack += _callBack; GetControl("ClientText_DialogBox").text = clientTalk /*"好的"*/; + UItext.text = GetControl("ClientText_DialogBox").text; + StartTypewriterEffect(); } //} @@ -33,5 +40,10 @@ public class UI_CustomSessionPanel : BasePanel break; } } - + void StartTypewriterEffect() + { + // 使用DoTween的DOText方法实现打字机效果 + UItext.DOText(fullText, fullText.Length * typingSpeed) + .SetEase(Ease.Linear); + } } diff --git a/Assets/Scripts/Project/UI/UI_Panel/UI_PlayerSessionPanel.cs b/Assets/Scripts/Project/UI/UI_Panel/UI_PlayerSessionPanel.cs index 4d73e28..99a0ce8 100644 --- a/Assets/Scripts/Project/UI/UI_Panel/UI_PlayerSessionPanel.cs +++ b/Assets/Scripts/Project/UI/UI_Panel/UI_PlayerSessionPanel.cs @@ -1,3 +1,4 @@ +using DG.Tweening; using System; using System.Collections; using System.Collections.Generic; @@ -9,6 +10,9 @@ public class UI_PlayerSessionPanel : BasePanel { private string triggerID; public Action callBack; + private TextMeshProUGUI UItext; + private string fullText; + private float typingSpeed = 0.05f; /// /// ʼ,state 0 һ /// @@ -17,6 +21,8 @@ public class UI_PlayerSessionPanel : BasePanel this.triggerID = triggerID; callBack += _callBack; GetControl("PlayerText_DialogBox").text = clientTalk /*"õ"*/; + UItext.text = GetControl("PlayerText_DialogBox").text; + StartTypewriterEffect(); } //} @@ -34,4 +40,10 @@ public class UI_PlayerSessionPanel : BasePanel break; } } + void StartTypewriterEffect() + { + // ʹDoTweenDOTextʵִֻЧ + UItext.DOText(fullText, fullText.Length * typingSpeed) + .SetEase(Ease.Linear); + } }