84 lines
		
	
	
		
			1.8 KiB
		
	
	
	
		
			C#
		
	
	
	
			
		
		
	
	
			84 lines
		
	
	
		
			1.8 KiB
		
	
	
	
		
			C#
		
	
	
	
| using System;
 | |
| using System.Collections;
 | |
| using System.Collections.Generic;
 | |
| using UnityEngine;
 | |
| using UnityEngine.UI;
 | |
| using DG.Tweening;
 | |
| 
 | |
| public class GuideStep : MonoBehaviour
 | |
| {
 | |
|     public Action<int, bool> DelStepDone;
 | |
| 
 | |
|     public float FinishDelay = -1;
 | |
|     public int ExcuteCount = 1;
 | |
|     public bool AutoNext = true;
 | |
| 
 | |
|     //[SerializeField] GameObject mGobClick;
 | |
|     [SerializeField] Button mBtnOp;
 | |
| 
 | |
|     //private RectTransform mRect;
 | |
|     private int mIndex;
 | |
| 
 | |
|     private void Awake()
 | |
|     {
 | |
|         //mRect = GetComponent<RectTransform>();
 | |
| 
 | |
|         if (mBtnOp != null)
 | |
|         {
 | |
|             UIUtils.BindBtn(mBtnOp, FinishStep);
 | |
|         }
 | |
|     }
 | |
| 
 | |
|     public void InitStep(int pIndex)
 | |
|     {
 | |
|         mIndex = pIndex;
 | |
|         ShowStep(false);
 | |
|     }
 | |
| 
 | |
|     public void StartStep(Vector3 pScreen = default)
 | |
|     {
 | |
|         ShowStep(true);
 | |
| 
 | |
|         //if (pScreen != default)
 | |
|         //{
 | |
|         //    Vector2 position;
 | |
|         //    if (RectTransformUtility.ScreenPointToLocalPointInRectangle(mRect, pScreen, null, out position))
 | |
|         //    {
 | |
|         //        mGobClick.GetComponent<RectTransform>().localPosition = position;
 | |
|         //    }
 | |
|         //}
 | |
| 
 | |
|         if (FinishDelay > 0)
 | |
|         {
 | |
|             CancelInvoke("FinishStep");
 | |
|             Invoke("FinishStep", FinishDelay);
 | |
|         }
 | |
| 
 | |
|         DOTweenAnimation tAni = GetComponentInChildren<DOTweenAnimation>();
 | |
|         if (tAni != null)
 | |
|         {
 | |
|             tAni.DOPlay();
 | |
|         }
 | |
|     }
 | |
| 
 | |
|     public void FinishStep()
 | |
|     {
 | |
|         ExcuteCount--;
 | |
| 
 | |
|         if (ExcuteCount <= 0)
 | |
|         {
 | |
|             DelStepDone?.Invoke(mIndex, AutoNext);
 | |
|             ShowStep(false);
 | |
|         }
 | |
|         else
 | |
|         {
 | |
|             DelStepDone?.Invoke(mIndex, false);
 | |
|         }
 | |
|     }
 | |
| 
 | |
|     private void ShowStep(bool pShow)
 | |
|     {
 | |
|         gameObject.SetActive(pShow);
 | |
|     }
 | |
| }
 |