반응형

커스텀 애니메이션커브를 담은 스크립(HnineCurves.cs)을 만들고 AnimationCurve를 적당한 이름으로 선언해 줍니다.

인스펙터에 가보면 이처럼 에디트할 수있는 창을 띄울 수 있겠죠.

클릭해서 원하는 모양의 이지값을 아래처럼 만들어 줍니다.

이렇게 만든 커브를 다음과 같이 DOTween에 사용할 수 있습니다.

반응형
반응형
using UnityEngine;
using System.Collections;
using UnityEngine.UI;
using DG.Tweening;
using UnityEngine.SceneManagement;

public delegate void ProgressDelegate(float progress);

public class LoadSceneAsyncProgress : MonoBehaviour {
	public Image ProgressBar;
	public CanvasGroup CG_Loading;

	void Start() {
		CG_Loading.DOFade (0.5f, 0.5f).SetEase (Ease.Linear).SetLoops (-1, LoopType.Yoyo);
		StartCoroutine(LoadSceneAsyncByName("FamilyHomeVI_SR", OnLoadLevelProgressUpdate));

	}
	
	public static IEnumerator LoadSceneAsyncByName(string nextLevel, ProgressDelegate progressDelegate) {
		AsyncOperation async = SceneManager.LoadSceneAsync(nextLevel);
	
		while (!async.isDone) {
			progressDelegate (async.progress);
			async.allowSceneActivation = async.progress > 0.8;
			yield return null;
		}
	}

	private void OnLoadLevelProgressUpdate(float progress) {
		ProgressBar.fillAmount = progress;
		Debug.Log ("async.progress: " + progress);
	}
}

참조 : https://gist.github.com/crowjdh/26272392e425063cbd69586cd542a46d

 

Getting progress while loading scene in Unity using SceneManager.LoadSceneAsync.

Getting progress while loading scene in Unity using SceneManager.LoadSceneAsync. - UnityLoadSceneAsyncProgress.cs

gist.github.com

참조 : https://docs.unity3d.com/ScriptReference/AsyncOperation-progress.html

 

Unity - Scripting API: AsyncOperation.progress

Return an operation's progress. (Read Only) This returns how close the operation is to finishing. The operation is finished when the progress float reaches 1.0 and isDone is called. If you set allowSceneActivation to false, progress is halted at 0.9 until

docs.unity3d.com

 

반응형
반응형

using UnityEngine; 
using UnityEngine.EventSystems; 
using DG.Tweening;   

public class WheelHandler : MonoBehaviour, IPointerDownHandler, IPointerUpHandler, IDragHandler { 	 	
    RectTransform ImgRectTransform;   	
    
    void Start () { 		
        ImgRectTransform = GameObject.Find("Canvas/Wheel/ImageR").GetComponent(); 	
    } 	 	
    
    public void OnPointerDown(PointerEventData e){ 		
        rotateImage(e.position); 	
    } 	 	
    
    public void OnPointerUp(PointerEventData e){ 		
        rotateImage(e.position); 	
    } 	 	
    
    public void OnDrag(PointerEventData e){ 		
        rotateImage(e.position); 	
    } 	 	
    
    protected void rotateImage( Vector2 value ){ 		
        float _x = value.x - Screen.width/2; 		
        float _y = value.y - Screen.height/2; 		
        float _R; 		 		
        if(_x > 0){ 			
            _R = (Mathf.Atan(_y/_x) * Mathf.Rad2Deg); 		
        }
        else
        { 			
            _R = (Mathf.Atan(_y/_x) * Mathf.Rad2Deg) + 180; 		
        } 		 		
        
        ImgRectTransform.DORotate(new Vector3(0f,0f,_R),0.1f,RotateMode.Fast); 		 	
    } 
} 

 

반응형

+ Recent posts