본문 바로가기

분류 전체보기

(5)
[Unity] 자주쓰는 유니티 오픈소스 에셋(Git) 🔹 UI Particle System 더보기 UI에서 파티클을 쉽게 쓸수 있게 도와주는 오픈소스. 링크 : https://github.com/mob-sakai/ParticleEffectForUGUI 🔹 UI Soft Mask 더보기 Unity에서 기본 제공해주는 기본 Mask 보다 다양한 Mask 기능을 제공. 링크 : https://github.com/mob-sakai/SoftMaskForUGUI 🔹 NevMeshPlus 더보기 Unity의 NavMesh의 기능을 2D(TileMap,SpriteRenderer 등) 에도 사용할수 있게 확장해주는 에셋. 링크 : https://github.com/mob-sakai/SoftMaskForUGUI 🔹 Awesome Unity Open Source 더보기 Uni..
[Unity] LineRenderer 를 활용해 화살표 그리기! State.IO 라는 게임에서 유저의 터치 드래그에 따라 화살표가 그려지고 움직이는 기능을 구현 해보겠습니다. using UnityEngine; public class ArrowDrawer : MonoBehaviour { LineRenderer arrowLine = null; Vector3 drawStartPos; Vector3 drawEndPos; private void Start() { arrowLine = GetComponent(); } private void Update() { if (Input.GetMouseButtonDown(0)) { Ray ray = Camera.main.ScreenPointToRay(Input.mousePosition); Debug.DrawRay(Camera.main.tr..
[Unity] 반지름 R인 원 위에 일정 간격(각도)의 위치 얻기. using UnityEngine; public class CubeCreator : MonoBehaviour { [SerializeField] GameObject _cubePrefab = null; void Start() { CreateCubes(); } public void CreateCubes() { int radius = 5; //반지름 int angle = 30; //간격 각도 int loop = 360 / angle; //반복 횟수 = 360 / 각도 int currentAngle = 0; for (int i = 0; i < loop; i++) { Vector3 pos = new Vector3(Mathf.Cos(currentAngle * Mathf.Deg2Rad) * radius, Mathf.Si..
[Unity]3D 오브젝트를 UI 위치로 이동시키기. using System.Collections; using UnityEngine; public class MovingObject : MonoBehaviour { [SerializeField] RectTransform _targetUI = null; float speed = 0.2f; void Start() { MoveToUI(_targetUI); } public void MoveToUI(RectTransform targetUI) { if (RectTransformUtility.ScreenPointToWorldPointInRectangle(targetUI, targetUI.position, Camera.main, out Vector3 targetPos)) { StartCoroutine(Move(targetP..
[Unity] 숫자 단위(K,M,B) 로 바꾸기 입력 숫자를 단위에 따라 변환. K - 1,000 M - 1,000,000 B - 1,000,000,000 using System.Collections; using System.Collections.Generic; using UnityEngine; public class NumberTest : MonoBehaviour { // Start is called before the first frame update void Start() { Debug.Log("1,000 => " + ChangeNumber("1000")); Debug.Log("123,456 => " + ChangeNumber("123456")); Debug.Log("1,000,000 => " + ChangeNumber("1000000")); D..