본문 바로가기
728x90

유니티40

Unity & C# ~ Property 프로퍼티 최종 수정 : 22.09.23 참조 : https://stackoverflow.com/questions/3847832/understanding-private-setters understanding private setters I don't understand the need of having private setters which started with C# 2. Having a setter method for me is letting the user to set some variables in that class. In doing so, we will not expo... stackoverflow.com //int 자리에 자료형 대입 public int parameters { get; set; } pu.. 2022. 4. 27.
Atlas에 들어있는 Sprite Load 참조 https://docs.unity3d.com/ScriptReference/U2D.SpriteAtlas.html using UnityEngine.U2D; class { SpriteAtlas _sprite = null; void LoadAtlasFunc() { _sprite = Resources.Load("path"); //path = 아틀라스 경로 및 이름 //예) Assets/Resources/Atlas/ResourceAtlas => "Atlas/ResourceAtals" Sprite _exSprite = _sprite.GetSprite("name"); //name = atlas에 저장된 확장자를 제외한 이미지 파일명 //예) imageExample.png => "imageExample" } } 2022. 4. 22.
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.
SMALL