728x90
728x90
Line Renderer 라인 렌더러 설정하기 using System.Collections; using System.Collections.Generic; using UnityEngine; public class Line : MonoBehaviour { public Transform target; public Color c1 = Color.yellow; LineRenderer LR; void Start() { LR = GetComponent(); LR.widthMultiplier = 0.1f; //선 너비 LR.startColor = c1; //선 시작점 색 LR.endColor = c1; //선 끝점 색 } void Update() { if (Input.GetMouseButton(0)) { LR.SetP..
https://docs.unity3d.com/kr/2019.3/ScriptReference/Ray.html UnityEngine.Ray - Unity 스크립팅 API Representation of rays. docs.unity3d.com 유니티 Ray/RaycastHit 설정하기 using System.Collections; using System.Collections.Generic; using UnityEngine; public class Ray : MonoBehaviour { public Transform PointObj; Ray ray; RaycastHit hit; // Update is called once per frame void Update() { if(Input.GetMouseButton..
유니티 씬 전환하는 방법 유니티 개발을 하다보면 Scene을 이동해야 하는 경우가 반드시 존재한다. 기본적인 마우스 클릭 만으로 씬을 전환하는 간단한 방법을 구현했다. 가장 먼저 해주어야 할 세팅은 File - Build Setting에서 전환시킬 씬들을 업로드해주는 것이다. 씬들을 드래그앤드롭으로 가져오기만 하고, 따로 build는 해줄 필요 없다. Create Empty를 생성 해 ChgScene 스크립트를 작성하여 연결해주면 된다. using System.Collections; using System.Collections.Generic; using UnityEngine; using UnityEngine.SceneManagement; public class ChgScene : MonoBehaviour..
UI Layout Group 종류 유니티에서 UI 작업을 하다보면 여러 이미지들을 통합해서 관리해야 하는 상황이 있다. 이 때 Layout Group을 설정한다면 쉽게 관리하고 수정할 수 있게 된다. UI Layout Group은 Vertical, Horizontal, Grid 총 3개로 나뉘며 하이라키창에서 add component에서 가져올 수 있다. Vertical Layout Group 세로로 하위 요소들을 정렬한다 Padding Left, Right, Top, Bottom 값을 가지며, Layout Group을 추가한 UI 게임 오브젝트와 하위 요소들 사이의 간격을 조절하는 값 Spacing 하위 요소들 사이의 간격 값 Child Alignment 하위 요소들을 배치할 때 정렬 기준 Contro..
슬라이더 UI 한계시간 설정 방법 using System.Collections; using System.Collections.Generic; using UnityEngine; using UnityEngine.UI; public class slider1 : MonoBehaviour { private Slider sd; private float TimeRemain = 100f; void Start() { sd = GetComponent(); } void Update() { TimeRemain -= Time.deltaTime; sd.value = TimeRemain; if (TimeRemain
유니티 오브젝트 자동 스폰 방법 오브젝트가 중력이 적용되어 지면에 닿으면 튀게 하는 효과 : 마우스 왼쪽 클릭 - Physical Material - bounciness(1) using System.Collections; using System.Collections.Generic; using UnityEngine; public class Spawner : MonoBehaviour { public GameObject BallPrefab; public float minDelay = 0.1f; public float maxDelay = 1f; public float DestroyDelay = 5f; private IEnumerator coroutine; void Start() { coroutine = Spaw..