스프라이트 크기만큼 월드좌표 가져오는것

유니티 C# 2022. 11. 10. 11:13

출처: https://forum.unity.com/threads/check-the-x-and-y-length-of-a-sprite.229949/

 

Check the X and Y length of a sprite

Hi, is it possible to check the X and Y length of a sprite? Thanks

forum.unity.com

    sprite.bounds.extents.x; //Distance to the right side, from your center point (오른쪽)
    -sprite.bounds.extents.x //Distance to the left side (왼쪽)
    sprite.bounds.extents.y //Distance to the top (위)
    -sprite.bounds.extents.y //Distance to the bottom (아래)

 

위의 수치값은 스프라이트 크기의 절반값이므로 해당 스프라이트의 중앙값 + 해당값들을 더해주면 월드상 좌표가 나오는 상황

 

sprite.bounds.size 도 있음.

리스트문 for문 foreach문 스피드 테스트

유니티 C# 2022. 5. 6. 17:22

테스트 코드

 

오천만번반복 * 10번반복 결과

딕셔너리 for문 foreach문 스피드 테스트

유니티 C# 2022. 5. 6. 17:16

테스트용 코드

 

5천만반복스피드 * 10번 반복 결과

Int.Parse는 방식, 언박식이 있는가? 보너스: 방식, 언박싱 VS 구문분석

유니티 C# 2022. 4. 20. 16:27

출처: https://stackoverflow.com/questions/1570512/does-int-parse-uses-boxing-unboxing-or-type-casting-in-c

결과적으로 Parse는 방식, 언박싱이 없다고 합니다.

하지만 해당 스택오버플로우에 말을 따르면 구문분석은 높은 비용이 들어 방식, 언박싱과 차이가 안난다고 해서 테스트해봤습니다.

 

IDE: Rider

밑 사진은 언어 버전입니다.

유니티 버튼클릭 투명부분 안되게 하는것

유니티 C# 2021. 7. 6. 20:53

원본 이미지의 세팅

1. Mesh Type을 FullRect로 세팅

2. Advanced세팅중 Read/Write Enabled를 체크

3. 해당 그림은 아틀라스에 포함되어있으면 안됩니다.

4. 코드상에서 Image.alphaHitTestMinimumThreshold = 0.001f 조절(해당 수치값을 조절함으로써 투명값 클릭 영역을 세팅 할 수 있습니다.)