본문 바로가기
728x90

전체 글239

[Unity UI] 1일차 Button ! UI는 순서대로 쌓여 화면에 출력됨( Hierachy 순서 중요) ! btnBlue는 Main에서 직접 이벤트를 관리, btnYellow와 btnGreen은 Button들을 관리하는 UIButtons에서 이벤트를 관리하는 방법으로 코드를 작성하였다. UIButtons using System.Collections; using System.Collections.Generic; using UnityEngine; using UnityEngine.UI; public class UIButtons : MonoBehaviour { public enum eBtnTypes { Yellow, Green } public Button[] arrBtns; public Button btnBlue; public System.Ac.. 2023. 2. 6.
[CS] Process, Thread, Coroutine Process 프로세스 Heap에 메모리 할당 프로그램이 실행되어 메모리에 적재되면 실행되는 프로그램 인스턴스 Thread 스레드 Stack에 메모리 할당 프로세스 내에서 실행되는 작업 단위 병렬성 : 하나의 프로세스에서 여러 스레드가 병렬 작업 가능 Coroutine 코루틴 동시성 : 여러 프레임에서 코드를 비동기적(비순차적)으로 실행 비동기 : 어떤 요청을 보낸 뒤, 그 요청의 결과값이 오기까지 멈추지 않고 또 다른 일을 수행하는 것 Thread vs Coroutine Thread와 Coroutine 모두 동시성 프로그래밍을 위함 Thread는 OS가 관여, Stack에 메모리 적재 Coroutine은 Programmer가 관여 ( OS가 관여 x), Heap에 메모리 적재 2023. 2. 6.
[Unity] Object Pooling 오브젝트 풀링_최적화, Garbage Collector 반복해서 오브젝트를 생성하고 파괴하는 방법은 많은 Garbage Collector를 발생시키며, CPU의 순간적인 성능 소모 및 프레임 저하를 불러옴 이러한 문제를 해결하기 위하여 Object Pooling 기법을 사용! Object Pooling 오브젝트의 생성/파괴 대신 Pool을 만들어 오브젝트를 활성화/비활성화 하며 관리 이러한 오브젝트들은 메모리 내에 계속 남아있기 때문에, CPU 성능 소모 ↓ 메모리 사용량 ↑ Garbage Collertor? 메모리 관리 방법. Heap에서 객체의 위치를 기억하는 참조변수가 모두 사라지면 정리되지 않은 메모리 garbage 발생 garbage가 메모리 공간이 부족할 정도로 쌓이면 Garbage Collection( GC )기능에 의해 삭제(해제) ! 시스템에.. 2023. 2. 6.
[Unity2D] Shooting Game 구조 만들기 연습 DontDestroyOnReoad : Scene이 바뀌어도 제거되지 않음 ! Scene 만들면 가장 먼저 Scene이름의 Empty, Script 만들기 ! lifetime transform.SetParent(transform) Camera.main.orthographicSize -> bullet.transform.position.y가 카메라 사이즈를 넘어가면 사라지게 활용 App using System.Collections; using System.Collections.Generic; using UnityEngine; using UnityEngine.SceneManagement; public class App : MonoBehaviour { private string version = "Version .. 2023. 2. 3.
[Unity3D] Coroutine 활용 예제 using System; using System.Collections; using System.Collections.Generic; using UnityEngine; public class Masaki : MonoBehaviour { Coroutine routine; Animator anim; Rigidbody rbody; Vector3 dir; Vector3 hitPoint; public float walkSpeed = 1.0f; void Start() { anim = this.GetComponent(); rbody = this.GetComponent(); this.routine = StartCoroutine(Move()); //코루틴 함수 시작 } //코루틴 (이벤트 함수) IEnumerator Mo.. 2023. 2. 2.
[Unity 3D / 유니티 교과서] 7장 예제 Bamsongi MainCamera 선택 후 Ctrl + Shift + F : Scene에서 바라보는 화면을 Game View에 출력되도록 Camera 위치 이동 Prefab Position을 (0, 0, 0)으로 변경 (reset) 후 등록하기 : 등록한 위치에서 인스턴스가 생성되기 때문 Prefab -우클릭 - Prefab - Unpack : 프리팹을 일반 오브젝트로 변경 BamsongiController using System.Collections; using System.Collections.Generic; using UnityEngine; public class BamsongiController : MonoBehaviour { private Rigidbody rbody; private ParticleSystem.. 2023. 2. 1.
[BOJ C#] 4796 캠핑 처음에 쉬워보여서 구조 자체는 빨리 짰지만 함정이 있던 문제. +오타, \n 조심 using System; using System.Text; using System.IO; namespace _4796 { class Program { static void Main() { StreamReader sr = new StreamReader(Console.OpenStandardInput()); StreamWriter sw = new StreamWriter(Console.OpenStandardOutput()); StringBuilder sb = new StringBuilder(); int caseN = 0; int result = 0; while (true) { if (caseN > 0) { sb.AppendForm.. 2023. 2. 1.
[Unity 2D / 유니티 교과서] 6장 예제 ClimbCloud Rigidbody : 중력, 마찰 힘 계산 (강체) -물리 영향을 무시 : Body Type - Kinematic (기본 Dynamic) -회전을 방지 : Constraints - Freeze Rotation z활성 Collider : 충돌 판정 OnTriggerEnter2D(Colider2D) : SceneManager 자주 사용하게 될 Find method -복수형에 주의! 단수형은 처음 찾은 대상을 반환, 복수형은 배열을 반환 FindGameObjectsWithTag(태그이름) FindObjectsOfType(타입이름) using System.Collections; using System.Collections.Generic; using UnityEngine; using UnityEngine.Scen.. 2023. 2. 1.
[Unity 2D] Mecanim (애니메이션 상태 시스템) 연습 처음에 SetInteger를 호출할수 없어 이유를 한참 찾았는데, Animator 타입을 Animation으로 자꾸 잘못 적었다. 항상 자세히 보기!! Animator.SetInteger(Parameter이름, Transition에 설정한 상태); Transition은 Has Exit Time, Fixed Duration 해제, 0으로 설정 : 키를 눌렀을 경우에만 transition이 일어나도록 Idle, Walk가 아닌 한번만 재생할 애니메이션은 Inspector의 Loop Time 해제 using System.Collections; using System.Collections.Generic; using UnityEngine; public class CucumberController : MonoBeh.. 2023. 2. 1.
[Unity 2D / 유니티 교과서] 5장 예제 + 이동범위 제한 Mathf.Clamp(value, min, max)를 사용하여 x좌표 이동범위 제한 using System.Collections; using System.Collections.Generic; using UnityEngine; public class PlayerController : MonoBehaviour { public float radius; // Start is called before the first frame update void Start() { } // Update is called once per frame void Update() { float posX = Mathf.Clamp(transform.position.x, -8.0f, 8.0f); if (Input.GetKeyDown(KeyC.. 2023. 1. 31.
[BOJ C#] 10162 전자레인지 using System; namespace _10162 { class Program { static void Main(string[] args) { int a = 300; int b = 60; int c = 10; int t = int.Parse(Console.ReadLine()); if (t % 10 != 0) Console.WriteLine("-1"); else { int clickA = t / a; t = t % a; int clickB = t / b; t = t % b; int clickC = t / c; Console.WriteLine("{0} {1} {2}", clickA, clickB, clickC); } } } } 2023. 1. 31.
[Unity 2D / 유니티 교과서] 5장 예제 PlayerController using System.Collections; using System.Collections.Generic; using UnityEngine; public class PlayerController : MonoBehaviour { public float radius; // Start is called before the first frame update void Start() { } // Update is called once per frame void Update() { if (Input.GetKeyDown(KeyCode.RightArrow)) { this.transform.Translate(3, 0, 0); } else if (Input.GetKeyDown(KeyCode.L.. 2023. 1. 31.
728x90