Unity&C# 9

data path

읽기 전용 데이터 경로 string assetsPath = Application.dataPath; 런타임 시에는 외부 파일이나 저장소 경로에 접근할 때 Application.persistentDataPath를 사용하는 것이 일반적 string dataPath = Application.persistentDataPath; 외부 파일(예: 사용자의 문서 폴더에 있는 파일)의 경로를 얻을 때는 System.Environment string documentsPath = System.Environment.GetFolderPath(System.Environment.SpecialFolder.MyDocuments); string filePath = Path.Combine(documentsPath, "MyFile.txt"..

Unity&C#/Unity 2023.09.25

[에러] Package Manager 외부 패키지 등록이 안돼요.

[Package Manager Window] Cannot perform upm operation: Unable to add package [repository.name.git]: [repository.name.git#urp] does not point to a valid package. No package manifest was found. [NotFound]. UnityEditor.EditorApplication:Internal_CallUpdateFunctions () 분명 여기 +를 누르고 ~ git ~을 누르고 나오는 창에 ~.git을 입력하면 패키지가 설치가 되어야하는데 안된다. 이럴땐 Project 폴더에 Packages -> Manifest.json을 수정해서 넣어주면 된다. scopedReg..

Unity&C# 2023.05.02

[기본] 참조(얕은 복사)

Class Class A{ public B b; } Class B{ public int c; } Class Main{ public main(){ B b = new B(); // B를 메모리에 할당 -> heap의 MB공간을 차지한다고 가정 A a = new A(); // A를 메모리에 할당 -> heap의 MA공간을 차지한다고 가정 a.b = b; // A의 b는 MB를 참조함 } }예제 using System; using System.Collections.Generic; using System.Linq; using System.Text.RegularExpressions; namespace Rextester { public class Program { public static void Main(strin..

Unity&C#/C# 2022.09.20

[C#문법] Dictionary

초기화 Dictionary dic = new Dictionary(); Dictionary dic = new Dictionary(){{key,value},{key,value}} 값할당 dic[key] = value dic.Add(key,value) foreach foreach(dtype key in dic.Keys){} foreach(dtype value in dic.value){} foreach(KeyValuePair kvp in dic){ Debug.log(kvp.Key); Debug.log(kvp.Value); } 복사 생성자 인수에 복사하고 싶은 오브젝트 지정 var dic2 = new Dictionary(dic); 기능 bool dic.Remove(key) 해당 key,value쌍 제거 dic.R..

Unity&C#/C# 2022.08.31