unity(51)
-
0429 조이스틱으로 캐릭터 움직이기
조이스틱은 유니티 에셋에서 가져왔음 'JoyStick Pack' using UnityEngine; public class JoyStickTest : MonoBehaviour { //VariableJoystick은 에셋에 포함된 스크립트임 public VariableJoystick variableJoystick; public Transform hero; public float moveSpeed=1f; // Start is called before the first frame update void Start() { } // Update is called once per frame void Update() { Debug.LogFormat("{0}", variableJoystick.Direction); var ..
2021.04.29 -
0429 데이터 연동으로 해당 프리팹 불러오기
using System.Collections.Generic; using UnityEngine; using Newtonsoft.Json; using System.Linq; public class Test : MonoBehaviour { public GameObject GaugeGo; public Hero hero; public UIButton btn; public GameObject labelPrefab; public UIPanel panel; private Dictionary dicCharDatas; private Dictionary dicPrefabs = new Dictionary(); // Start is called before the first frame update void Start() { t..
2021.04.29 -
0428 월드 좌표를 로컬 좌표로 변환하기(+ DOTween)
ui상의 보스 체력을 나타내는 게이지를 월드 좌표 안에 있는 캐릭터의 머리 위에 띄우려고 한다. using UnityEngine; public class Hero : MonoBehaviour { public Transform hudGaugeTrans; public Transform hudDamageTrans; public GameObject gaugeGo; // Start is called before the first frame update void Start() { Debug.LogFormat("{0}", UICamera.mainCamera); } // Update is called once per frame void Update() { Vector3 overlay = NGUIMath.WorldToL..
2021.04.28 -
0427 NGUI Scroll View+(데이터 연동)
using UnityEngine; public class NGUITestScrollView : MonoBehaviour { public GameObject prefab; public UIGrid grid; // Start is called before the first frame update void Start() { for (int i = 0; i < 10; i++) { var go = Instantiate(this.prefab, this.grid.transform); } grid.Reposition(); } 데이터 연동 using UnityEngine; public class UIListItem : MonoBehaviour { public UIButton btnPurchase; public GameO..
2021.04.27 -
0426 NGUI 버튼, 슬라이더, 스프라이트, 텍스트, input Field
UI 스프라이트를 화면에 배치하는 방식은 UGUI와 비슷하나 훨씬 간편화 되어있다. UI Root가 저절로 생김. 그 이후 NGUI에 속하는 모든 오브젝트는 UIRoot 안에서 만들어야 한다. (tag는 UI로 맞춰줌) 버튼 만들기 더보기 버튼 스크립트를 작성 후 빈 오브젝트에 부착, 컴포넌트 어싸인 using UnityEngine; using UnityEngine.UI; public class ButtonTest : MonoBehaviour { public UIButton btn; // Start is called before the first frame update void Start() { this.btn.onClick.Add(new EventDelegate(() => { Debug.Log("cli..
2021.04.26 -
0423 ugui scroll view 3D+데이터 테이블 연동2 (RayCast Target)
문제는 3D 오브젝트를 스크롤에 넣고 마스크를 씌우면 3D 오브젝트엔 마스크가 적용되질 않는다. Raycast Target 설명 더보기 사용자와 상호작용을 하도록 할 것인지 말 것인지 설정할 때 사용한다. Raycast target : Should this be considered a target for raycasting? using UnityEngine; using UnityEngine.UI; public class LobbyScene : MonoBehaviour { public GameObject listItemPrefab; public Transform contents; void Start() { for (int i = 0; i < 10; i++) { GameObject prefab = Insta..
2021.04.23