Unity/유니티 프로그래밍 맨텀 2019. 7. 29. 11:06
내가 사용하는 사운드/오디오 매니저. Dictionary로 클립 파일명을 검색해서 실행함. 빈 오브젝트에 AudioSource 하나 넣고, 하위 오브젝트 하나 만들어서 BGM용 AudioSource 하나 넣으면 된다. 랜덤 사운드 호출은 아래와 같이 파일명에 index를 붙여놓고 sound_0 sound_1 sound_2 PlaySound("sound_" + Random.Range(0, 3)); 와 같이 호출하면 된다. using UnityEngine; using System.Collections; using System.Collections.Generic; [RequireComponent(typeof(AudioSource))] public class SoundManager : Singleton { #r..
Unity/유니티 프로그래밍 맨텀 2019. 6. 30. 00:13
싱글톤으로 만들어서 사용. 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283using System.Collections;using System.Collections.Generic;using UnityEngine;using UnityEngine.UI; public class TransitionManager : MonoBehaviour{ public Image _Image; Color blackColor = Color.black; Color offColor = Color.clea..
Unity/유니티 프로그래밍 맨텀 2019. 6. 6. 19:38
유니티 C# 프로그래밍에서 List를 다룰 때 List의 요소들을 다루는 일은 꽤나 코딩이 길어 질 수 있다. 하지만 LINQ를 사용한다면 꽤나 코드를 간결화 가능하다. #. 첫번째 : List 에서 현재 위치와 2f 보다 멀리 떨어져 있는 요소 필터링하기 public List positionList; //원본 Vector 리스트 public List filter_positionList; // 필터 후 담을 Vector 리스트 // for문을 사용한 경우 public void NormalFuntion() { for (int i = 0; i 2f) ..
Unity/유니티 프로그래밍 맨텀 2019. 5. 29. 23:45
물리 오류가 나는 경우 대부분은 물리 연산이 들어가는 캐릭터 이동을 FixedUpdate가 아니라 Update에서 처리한 경우. FixedUpdate에서 처리하면서 Time.deltatime을 Time.fixedDeltatime으로 고쳐써준다. 혹은 코루틴의 경우 null 이 아니라 new WaitForFixedUpdate()를 리턴해주자. 1234567891011121314151617 protected override IEnumerator SprinterCoroutine() { while (true) { _Rigidbody.MovePosition(transform.position + transform.forward * Spd * Time.fixedDeltaTime); yield return new Wa..
Unity/유니티 프로그래밍 맨텀 2019. 5. 23. 13:55
start() 나 update(), lateUpdate() 등 기본 함수가 한개라도 구현되어있지 않으면 체크박스가 나타나지 않습니다. 비어있더라도 start()가 구현되어있다면 나옵니다.
Unity/유니티 프로그래밍 맨텀 2019. 2. 3. 01:19
EventSystems 는 IPointer 인터페이스 사용하려다가 남은것. 마우스 드래그 영역을 따로 정해줄거면 IPointer로 처리해야함. 1. 전처리문을 사용한 안드로이드, PC 플랫폼 분리 (구식방법) using System.Collections; using System.Collections.Generic; using UnityEngine; using UnityEngine.EventSystems; public class mCameraController : MonoBehaviour{ Vector3 FirstPoint; Vector3 SecondPoint; float xAngle; float yAngle; float xAngleTemp; float yAngleTemp; public Transform ..