Notice
Recent Posts
Recent Comments
Link
일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | ||||||
2 | 3 | 4 | 5 | 6 | 7 | 8 |
9 | 10 | 11 | 12 | 13 | 14 | 15 |
16 | 17 | 18 | 19 | 20 | 21 | 22 |
23 | 24 | 25 | 26 | 27 | 28 |
Tags
- 레이캐스트
- 깃허브
- ARProgect
- Euler
- github
- 1인개발
- ExtensionMethod
- 인터페이스
- AR세팅
- 리듬게임
- 게임
- 로케트
- callbyreference
- callbyvalue
- AR게임
- raycast
- 게임개발
- 소규모프로젝트
- 확장메서드
- 병맛게임
- Unity
- 리듬게임에디터
- ar
- 짐벌락
- 유니티
- C#
- AR Foundation
- 델리게이트
- 게임제작
- Quaternion
Archives
- Today
- Total
Ssssong += Dev
[유니티, C#] 깊은 복사 ConvertAll 본문
List<T>.ConvertAll<TOutput>(Converter<T,TOutput>) 메서드 (System.Collections.Generic)
현재 List<T>의 요소를 다른 형식으로 변환하고 변환된 요소를 포함하는 목록을 반환합니다.
docs.microsoft.com
List의 각 요소를 한꺼번에 다른 형식으로 변환하여 복사할 수 있다.
같은 형식으로도 복사가 가능하므로 .ConvertAll(s=>s) 이렇게 깊은 복사를 하는 데 사용할 수 있다.
아래는 AR공던지기의 골대, 공 습득 조건 충족 여부를 검사하는 레시피이다.
조건으로 들어가 있는 리스트를 복제하여 일치하는 값을 하나씩 지우며 검사하였다.
[System.Serializable]
public class Recipe
{
public List<string> parts = new List<string>();
public List<string> tempList;
public bool IsCheck(List<string> resultInputList)
{
List<string> tempList = parts.ConvertAll(s=>s);
foreach (string temp in resultInputList)
{
if (tempList.Contains(temp))
{
tempList.Remove(temp);
}
}
return (bool)(tempList.Count == 0);
}
}
'개발 > 공부' 카테고리의 다른 글
[유니티] 충돌 검사 짤팁 (0) | 2022.06.14 |
---|---|
[유니티, C#] foreach, 콜렉션 (0) | 2022.06.14 |
[C#] 추상클래스와 인터페이스 (0) | 2022.06.13 |
[유니티] 스크립트 직렬화 (0) | 2022.06.08 |
[유니티] Stencil buffer (0) | 2022.05.27 |