728x90 Unity44 Enum FlagsAttribute : enum을 비트 필드(플래그 집합)으로 처리하기 https://docs.microsoft.com/ko-kr/dotnet/api/system.flagsattribute?view=netframework-4.8 FlagsAttribute 클래스 (System) 열거형을 비트 필드 즉, 플래그 집합으로 처리할 수 있음을 나타냅니다. docs.microsoft.com 유니티에서 enum에 복수의 값을 받아서 처리할 때 사용 [Flags] public enum Type { None = 0, Type0 = 1, Type1 = 2, Type2 = 4, All = int.MaxValue } Type typeValue = Type.None; void Awake() { SetType(Type.Type0 | Type.Type2); SetType(Type.Type1); Se.. 2022. 4. 6. string 변수에 색상 넣기 string message = "Message : " + "메세지"; color = green 값에 다른 값을 넣으면 색상이 변경됨. ex) , 등 2022. 3. 29. 스크롤이 리스트가 가운데를 기점으로 움직이게 하기 GameObject prefab; ScrollRect scrollRect; RectTransform content; RectTransform viewport; List dataList = new List(); float defaultItemSize = 10; int currentIndex = 0; void Create() { GameObject obj = Instantiate(prefab); dataList.Add(obj) obj.GetComponent().SetParent(content); content.GetComponent().sizeDelta += new Vector2(0, defaultItemSize); } void MoveTo() { MoveTo(currentIndex); } void Move.. 2022. 3. 22. VideoPlayer 재생 영상 사이즈 아는 법 public VideoPlayer _video; public RawImage _texture; public void VideoPlayFunc(string _url) { _video.url = _url; StartCoroutine(SizeCheck()); } IEnumerator SizeCheck() { _video.Prepare(); while(!_video.isPrepared) { yield return null; } _video.Play(); _texture.texture = _video.texture; Debug.Log(_texture.textrue.width); } 2022. 3. 18. 1개의 Color Gradient를 구간으로 나누기 [SerializeField] Color color1; [SerializeField] Color color2; Color[] colors; float smoothness = 0; public void Function(int _length) { colors = new Color[_length + 1]; for(int i = 0; i < colors.Length; i++) { smoothness += 1f / colors.Length; colors[i] = Color.Lerp(color1, color2, smoothness); } } -참고영상 https://youtu.be/rj5wdmOY-8U 2022. 3. 17. Unity & C# ~ using 문 * 최초 작성일 : 2022.02.17 * 최종 수정일 : 2022.02.17 using문은 using문을 사용한 메서드의 닫는 중괄호에 도달하면 해당 파일이 삭제(dispose)됨. //예제 using (var file = new System.IO.StreamWriter("WriteLines2.txt")) { int skippedLines = 0; foreach (string line in lines) { if (!line.Contains("Second")) { file.WriteLine(line); } else { skippedLines++; } } return skippedLines; } // file is disposed here (불러온 파일이 삭제) 2022. 2. 17. 이전 1 ··· 4 5 6 7 8 다음 SMALL