2018.04.11 수업내용 (NGUI, DoTween)
Unity3D 2018. 5. 15. 21:45반응형
NGUI 기본 사용법
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 | using System.Collections; using System.Collections.Generic; using UnityEngine; using Holoville.HOTween; public class Title : MonoBehaviour { public UI.UITitle uiTitle; public UI.UILoginPopup uiLoginPopup; public UIPanel panelDim; private void Awake() { this.Init(); } private void Init() { this.panelDim.gameObject.SetActive(false); this.uiLoginPopup.gameObject.SetActive(false); } // Use this for initialization void Start () { this.uiTitle.btnStart.onClick.Add(new EventDelegate(() => { this.ShowLoginPopup(true); })); this.uiLoginPopup.btnLogin.onClick.Add(new EventDelegate(() => { Debug.Log("로그인"); })); this.uiLoginPopup.btnClose.onClick.Add(new EventDelegate(() => { this.ShowLoginPopup(false); })); } // Update is called once per frame void Update () { } private void ShowLoginPopup(bool active) { if (active) { this.uiLoginPopup.transform.localScale = Vector3.zero; this.panelDim.gameObject.SetActive(active); this.uiLoginPopup.gameObject.SetActive(active); TweenParms parms = new TweenParms(); parms.Prop("localScale", new Vector3(1.1f, 1.1f, 1.1f)); parms.Ease(EaseType.EaseOutQuad); parms.OnComplete((e) => { HOTween.To(this.uiLoginPopup.transform, 0.1f, new TweenParms().Prop( "localScale", Vector3.one)); }); HOTween.To(this.uiLoginPopup.transform, 0.1f, parms); } else { TweenParms parms = new TweenParms(); parms.Prop("localScale", new Vector3(1.1f, 1.1f, 1.1f)); parms.Ease(EaseType.EaseOutQuad); parms.OnComplete((e) => { HOTween.To(this.uiLoginPopup.transform, 0.1f, new TweenParms().Prop( "localScale", Vector3.zero).OnComplete(()=> { this.uiLoginPopup.transform.localScale = Vector3.one; this.panelDim.gameObject.SetActive(active); this.uiLoginPopup.gameObject.SetActive(active); }) ); }); HOTween.To(this.uiLoginPopup.transform, 0.1f, parms); } } } | cs |
1 2 3 4 5 6 7 8 9 10 11 12 13 | using System.Collections; using System.Collections.Generic; using UnityEngine; namespace UI { public class UITitle : MonoBehaviour { public UIButton btnStart; } } | cs |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 | using System.Collections; using System.Collections.Generic; using UnityEngine; namespace UI { public class UILoginPopup : MonoBehaviour { public UIButton btnLogin; public UIButton btnClose; } } | cs |
DoTween 사용 해보세요 개 꿀 ~
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 | private void ShowLoginPopup(bool active) { if (active) { this.panelDim.gameObject.SetActive(active); this.uiLoginPopup.transform.localScale = Vector3.zero; this.uiLoginPopup.gameObject.SetActive(active); this.uiLoginPopup.transform.DOScale(new Vector3(1.1f, 1.1f, 1.1f), 0.2f).OnComplete(() => { this.uiLoginPopup.transform.DOScale(new Vector3(1, 1, 1), 0.1f).OnComplete(() => { }); }); } else { this.panelDim.gameObject.SetActive(false); this.uiLoginPopup.gameObject.SetActive(active); this.uiLoginPopup.transform.localScale = Vector3.one; } } | cs |
반응형
'Unity3D' 카테고리의 다른 글
유니티 에디터 확장 입문(번역글) (0) | 2018.05.15 |
---|---|
2018.04.24 수업내용 (UnityWebRequest, 에뮬레이터 실행, Logcat) (0) | 2018.05.15 |
2018.03.28 수업내용 (데이터 저장, 불러오기) (0) | 2018.05.15 |
Multiplayer and Networking (0) | 2018.05.15 |
AssetBundle Usage Patterns (0) | 2018.05.15 |