51 lines
		
	
	
		
			1.4 KiB
		
	
	
	
		
			C#
		
	
	
	
			
		
		
	
	
			51 lines
		
	
	
		
			1.4 KiB
		
	
	
	
		
			C#
		
	
	
	
| using System;
 | |
| using System.Collections.Generic;
 | |
| using UnityEngine;
 | |
| using UnityEngine.UI;
 | |
| using DG.Tweening;
 | |
| 
 | |
| public class HUDJumpText : HUDBase
 | |
| {
 | |
|     [SerializeField] Text mTxtJumpText;
 | |
|     private RectTransform mRectJumpText;
 | |
| 
 | |
|     protected override void OnAwake()
 | |
|     {
 | |
|         base.OnAwake();
 | |
| 
 | |
|         if (mRectJumpText == null)
 | |
|         {
 | |
|             mRectJumpText = mTxtJumpText.GetComponent<RectTransform>();
 | |
|         }
 | |
|     }
 | |
| 
 | |
|     protected override void OnDestroy()
 | |
|     {
 | |
|         base.OnDestroy();
 | |
| 
 | |
|         mRectJumpText.DOKill();
 | |
|         mTxtJumpText.DOKill();
 | |
|     }
 | |
| 
 | |
|     public void ShowText(string pTxt, Color pColor, int pSize = 50)
 | |
|     {
 | |
|         if (mRectJumpText == null)
 | |
|         {
 | |
|             mRectJumpText = mTxtJumpText.GetComponent<RectTransform>();
 | |
|         }
 | |
| 
 | |
|         mTxtJumpText.text = pTxt;
 | |
|         mTxtJumpText.color = pColor;
 | |
|         mTxtJumpText.fontSize = pSize;
 | |
| 
 | |
|         mRectJumpText.sizeDelta = new Vector2(mTxtJumpText.preferredWidth * 2, mTxtJumpText.preferredHeight * 2);
 | |
| 
 | |
|         mRectJumpText.anchoredPosition = Vector2.zero;
 | |
|         //mRectJumpText.localScale = Vector3.zero;
 | |
| 
 | |
|         mRectJumpText.DOJumpAnchorPos(Vector2.up * 100, 10, 1, 0.3f).SetEase(Ease.InCubic);
 | |
|         //mRectJumpText.DOScale(Vector3.one, 0.5f).SetEase(Ease.InCubic);
 | |
|         mRectJumpText.DOAnchorPosY(200, 0.3f).SetDelay(0.3f);
 | |
|         mTxtJumpText.DOFade(0f, 0.3f).SetDelay(0.3f).onComplete = Destroy;
 | |
|     }
 | |
| } |