1
2



1
2
//배열을 리스트로
List<int> testList = testArr.ToList();
 
...
 
//리스트를 배열로
int[] testArray = testList.ToArr();
cs

역시 똑똑한 사람들이 만들어둔 물건에는 이런 간단하지만 직접만들라면 귀찮은 기능들이 기본으로 주어져서 참 좋은거 같다 !

블로그 이미지

stuban

ㅇ.ㅇ

,


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
29
30
31
32
33
34
35
36
37
38
39
40
41
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
 
/*
 상하좌우스와이프와 그냥 클릭을 구분 가능하게 함
사용할 스크립트에 MonoBehaviour 대신에 TouchGesture를 상속시켜주고
버추얼 함수들을 오버로딩해서 사용하셈
*/
public class TouchGesture : MonoBehaviour
{
    private const float SwipeDis = 10;//스와이프 허용 범위 수정하고 싶으면 이거 수정하셈
    private Vector2 StartPos;
 
    private void Update()
    {
        if (Input.GetMouseButtonDown(0))
        {
            StartPos = Input.mousePosition;
        }
        if (Input.GetMouseButtonUp(0))
        {
            Vector2 p = (Vector2)Input.mousePosition - StartPos;
 
            if (Mathf.Abs(p.x) < SwipeDis && Mathf.Abs(p.y) < SwipeDis)
                GetClick();
            else
            {
                if (Mathf.Abs(p.x) > Mathf.Abs(p.y))
                    GetSwipe(StartPos, new Vector2(Mathf.Sign(p.x), 0));
                else if (Mathf.Abs(p.x) < Mathf.Abs(p.y))
                    GetSwipe(StartPos, new Vector2(0, Mathf.Sign(p.y)));
            }
        }
    }
 
    public virtual void GetClick() { }
    public virtual void GetSwipe(Vector2 StartPos, Vector2 dir) { }
}
 
cs


'내가 만든거' 카테고리의 다른 글

길따라 로봇 road robot 제작기(BIC 전시기)  (1) 2019.09.25
등산 시뮬레이터  (0) 2018.06.23
맵 에디터 !!!!  (0) 2018.05.11
유니티 사운드 매니저  (2) 2017.08.22
마인크래프트 만들었다  (0) 2017.05.24
블로그 이미지

stuban

ㅇ.ㅇ

,

텍스트에셋을 사용해서 텍스트파일을 불러오려는데 텍스트파일의 내용이 비어있었다.

처음에는 너무 양이 많아서 안불러오는거라고 생각했으나 (100줄정도 되는 분량)


약간의 삽질끝에 파일안에 있는 한글이 문제였다는 것을 깨닳게 되었다.


방법은 UTF-8로 인코딩하기



메모장에서 다른이름으로 저장할때 밑에있는 인코딩을 UTF-8로선택하면



인스펙터에서 안보이던 글이



다시 보이게 된다.




블로그 이미지

stuban

ㅇ.ㅇ

,
1
2
3
4
5
6
7
8
List<Test> result = new List<Test>();
 
//합치기
result.AddRange(list1);
result.AddRange(list2);
 
//중복 제거
result = result.Distinct().ToList();
cs



블로그 이미지

stuban

ㅇ.ㅇ

,