본문 바로가기

Unity3

[UNITY, C#] unitywebrequest downloadProgress 값이 일정하게 증가하지 않는 경우 해결 Unity에서 호출한 API의 response에 대한 progressBar를 구현할 때, UnityWebRequest의 downloadProgress를 사용하게 된다. downloadProgress를 활용하여 아래와 같이 progressBar의 %를 계산하여 보여주는 함수가 있다. public IEnumerator ShowDownloadProgress(UnityWebRequest www) { while (!www.isDone) { if(LoadingScreen.instance != null) LoadingScreen.Fill(www.downloadProgress); Debug.Log(string.Format("Downloaded: {0}%", www.downloadProgress)); yield retu.. 2024. 2. 15.
[Unity] Play mode에서만 material 색상 바꾸는법 유니티 개발 시 play mode에서 gameObject에 적용된 material color를 바꾸면 일반적으로 생각하는 것과 다르게 변경된 값이 play mode를 끄더라도 material에 적용된다. ( Editor에서 적용, 빌드 실행 시 적용되지 않음) 이 때문에 나도 모르게 material의 color가 바뀌어있어 당황한 적이 있는데, 이를 해결하기 위한 방법이 있다. 아래 예제는 slider로 material color의 알파 값을 바꾸는 코드이다. public class TransparencyManager : MonoBehaviour { [SerializeField] private Slider slider = default; [SerializeField] private Material mat.. 2024. 1. 30.
[Unity] NullReferenceException: SerializedObject of SerializedProperty has been Disposed. 에러 발생 유니티 에디터에서 개발 중에 play mode를 꺼도 NullReferenceException: SerializedObject of SerializedProperty has been Disposed. 에러가 지속적으로 발생했다. 에러 스택을 유심히 살펴봐도 딱히 어디가 문제인지 찾을 수가 없었는데, play mode가 종료되었음에도 계속 발생하는 에러가 의심스러워 에디터를 껏다가 켜보니 아주 잘 실행되었다. 나 말고도 고통받은 사람이 많은 걸 보니 유니티의 고질적인 버그 중 하나인 것 같다. 2024. 1. 30.