본문 바로가기

분류 전체보기

(74)
unity 클라이언트 아이디어 addressable은 resource를 업데이트 할 수 있다. xlua는 lua코드를 실행시킬 수 있는데 xlua랑 addressable을 이용하면 클라이언트만으로 어느정도 업데이트 시킬 수 있다.
unity Sprite의 이름을 editor에서 코드로 변경하기 public void RenameSprites(string folder_name, string sprite_name) { string path = folder_name; // 원하는 폴더 string[] guids = AssetDatabase.FindAssets("t:Texture2D", new[] { path }); foreach (string guid in guids) { string assetPath = AssetDatabase.GUIDToAssetPath(guid); TextureImporter importer = AssetImporter.GetAtPath(assetPath) as TextureImporter; if (importer..
부동소수점의 이해 및 정수 정확도 보장 범위 float, double을 이해해보자. 부동 소수점은 소주점의 위치가 고정되어 있지 않고 지수와 가수로 수를 표현하는 방식이다. float라는 이름은 부동소수점 (float point)을 줄인 이름이다. double은 정확도가 float보다 대충 두배가 높아서. 이제 핵심인 지수와 가수 개념을 알아본다. (아래는 double을 기준으로) double의 구조를 살펴보면 64비트로 되어있는데 | 부호(1) | 지수(11) | 가수(52) | 이렇게 되어있다. 의미를 보면 부호 비트(S): 1비트 → 0이면 양수, 1이면 음수지수(E): 11비트 → 지수(exponent)를 저장, bias = 1023가수(M): 52비트 → 소수점 이하의 유효 숫자 이를 바탕으로 값을 계산하는 방법은 값(실수) = (-1..
Unity camera rect변경 (screen size변경) 잔상 문제 해결 private void OnPreCull(){ GL.Clear(true, true, Color.black); } 이걸 추가하면 된다고 하는데 컬링 전에 호출되는 함수인데 애뮬레이터 실행에서는 잔상이 남았다. void OnRenderObject(){ if (changing == 1) { changing++; GL.Clear(true, true, Color.black); }else if (changing == 2) { changing++; mainCamera.rect = TargetRect; } else if(changing==0) { Rect rect = new Rect(); ..
unity OnEnable이 Awake보다 빨리 불리는 현상. Awake가 더 빨리 불려야하는데 왜 OnEnable이  더 빨리 불릴까 이유는 같은 스크립트 내에서는 Awake가 더 빨리 불리나 A오브젝트의 Awake가 B오브젝트의 OnEnable보다 늦게 불릴 수 있다. Script_1.Awake()Script_1.OnEnable()Script_2.Awake()Script_2.OnEnable()Script_3.Awake()Script_3.OnEnable() 이런식으로 불리는 것이다. 그럼 어떤 스크립트를 먼저 할것인지 정하고 싶을 수 있는데 이는 Unity 에디터에서 Edit > Project Settings > Script Execution Order 메뉴를 통해 스크립트의 실행 순서를 지정할 수 있다.
c++로 서버 만들어서 파일 보내기 #include #include #include #include #include #include #include #include  int main() {    // 1. 서버 소켓 생성 및 옵션 설정    int server_fd = socket(AF_INET, SOCK_STREAM, 0);    if (server_fd == -1) {        perror("소켓 생성 실패");        return -1;    }    int opt = 1;    if (setsockopt(server_fd, SOL_SOCKET, SO_REUSEADDR, &opt, sizeof(opt)) 0) {        perror("옵션 설정 실패");        return -1;    }     // 2. 서버 ..
mysql timeout 시간 변경하기 mysql> show variables like '%timeout';+-----------------------------------+----------+| Variable_name                     | Value    |+-----------------------------------+----------+| connect_timeout                   | 10       || delayed_insert_timeout            | 300      || have_statement_timeout            | YES      || innodb_flush_log_at_timeout       | 1        || innodb_lock_wait_timeo..
unity 2d pivot private Vector2 Getpivot(Texture2D tex, int x, int y, int width, int height){ Color[] pixels = tex.GetPixels( (int)x, (int)y, (int)width, (int)height ); // 스프라이트의 첫 번째 비투명 픽셀 찾기 (아래부터 위로) int firstNonTransparentY = -1; for (int row = 0; row 0) // 알파 값이 0보다 큰 경우 { firstNonTransparentY = row; break; } ..