728x90

๐ŸŽฎ Unity Study/Unity 59

[Unity] IL2CPP, Mono, JIT

C# vs C++ : GC ์žˆ์Œ ์—†์Œ ์ฐจ์ด. C#์— GC(Garbage Collector)๊ฐ€ ์ƒ๊ฒจ์„œ ์ƒ์‚ฐ์„ฑ์ด ๋” ์ข‹๋‹ค. Mono, IL2CPP, Burst : ์ฝ”๋“œ๋ฅผ ์‹คํ–‰๊ฐ€๋Šฅํ•œ ํ˜•ํƒœ๋กœ ๋ฐ”๊ฟ”์ฃผ๋Š” ์ปดํŒŒ์ผ๋Ÿฌ์ธ Scripting Backend์˜ ์ข…๋ฅ˜ Mono๋Š” IL2CPP ๋ณด๋‹ค ๋น ๋ฅด๊ณ  ํ”Œ๋žซํผ์— ๋…๋ฆฝ์ ์ž„. IL2CPP๊ฐ€ ๋” ๋ณด์•ˆ์„ฑ์ด ๋†’๊ณ  Android/iOS ํ˜ธํ™˜๊ฐ€๋Šฅ. cf) Unity ์ž์ฒด ์—”์ง„์€ C++์ด๊ณ  Script ๋Š” C#์œผ๋กœ ์ž‘์„ฑํ•˜๋Š” ๊ตฌ์กฐ. Mono : Mono๋Š” JIT(Just-In-Time) ์ปดํŒŒ์ผ์„ ์‚ฌ์šฉํ•˜๊ณ  ๋Ÿฐํƒ€์ž„ ์‹œ์ ์— ์š”์ฒญ์‹œ ์ฝ”๋“œ๋ฅผ ์ปดํŒŒ์ผ ํ•จ : 64bit ์ง€์› ์•ˆํ•จ. IL2CPP : IL2CPP๋Š” AOT(Ahead-of-Time) ์ปดํŒŒ์ผ์„ ์‚ฌ์šฉํ•˜๊ณ  ์‹คํ–‰ ์ „์— ์ „์ฒด ์• ํ”Œ๋ฆฌ์ผ€์ด์…˜์„ ์ปดํŒŒ์ผ ํ•จ. :..

[Unity] Texture Compression ๋ฐฉ์‹

* Texture ์••์ถ•์ด ํ•„์š”ํ•œ ์ด์œ ? GPU ์—์„  1Pixel ๋‹น 32Bit ๋ฅผ ์ฐจ์ง€ํ•œ๋‹ค. ํ”ํžˆ ์••์ถ•๋ฐฉ์‹์œผ๋กœ PNG๋‚˜ JPG๋ฅผ ์–ธ๊ธ‰ํ•˜๋Š”๋ฐ PNG ๋‚˜ JPG ์ด๋ฏธ์ง€ 1MB ์งœ๋ฆฌ๋ฅผ GPU์— ์˜ฌ๋ฆฌ๋ฉด 32 Bit ๋ผ์„œ 4MB ๋กœ ์˜ฌ๋ผ๊ฐ„๋‹ค. -> 4๋ฐฐ๊ฐ€ ๋˜๋Š” ๊ฒƒ. PNG ๋‚˜ JPG ๋Š” ๋””์Šคํฌ ์ €์žฅ๊ณต๊ฐ„์„ ์•„๋ผ๊ธฐ ์œ„ํ•œ ์••์ถ•๋ฐฉ์‹์ด์ง€ GPU ๊ณต๊ฐ„์„ ์•„๋ผ๊ธฐ ์œ„ํ•œ ์••์ถ•๋ฐฉ์‹์ด ์•„๋‹ˆ๋‹ค. GPU ์—์„œ ์‚ฌ์šฉํ•˜๋Š” ์••์ถ•๋ฐฉ์‹์„ ์‚ฌ์šฉํ•ด์•ผ GPU ์‚ฌ์šฉ๊ณต๊ฐ„์„ ์ ˆ์•ฝํ•  ์ˆ˜ ์žˆ๋Š”๊ฑฐ๋‹ค. ์ฆ‰, ๋น ๋ฅธ ๋””์ฝ”๋”ฉ, ๋žœ๋ค ์•ก์„ธ์Šค, ์ธ์ฝ”๋”ฉ ์ƒํƒœ๋กœ ๋ฉ”๋ชจ๋ฆฌ์— ์กด์žฌ, ์‚ฌ์ด์ฆˆ ์ ˆ์•ฝ(๋ฉ”๋ชจ๋ฆฌ, ์ €์žฅ์žฅ์น˜) ๋“ฑ์„ ์œ„ํ•ด GPU๋ฅผ ์œ„ํ•œ Texture Compression์ด ํ•„์š”ํ•˜๋‹ค. * ๊ฐ€๋ณ€ ๋น„์œจ ์••์ถ• vs ๊ณ ์ • ๋น„์œจ ์••์ถ• 1. ๊ฐ€๋ณ€ ๋น„์œจ ์ธ์ฝ”๋”ฉ //์••์ถ•์€ ๊ธฐ๋ณธ์ ์œผ๋กœ ๊ฐ€๋ณ€ ๋น„..

[Unity] Scriptable Object ์‚ฌ์šฉ๋ฒ•, ์žฅ์ 

* Scriptable Object? ํŒŒ์ผ๋กœ ์ €์žฅํ•  ์ˆ˜ ์žˆ๋Š” ๊ตฌ์กฐ์ฒด๋ผ๊ณ  ์ƒ๊ฐํ•˜๋ฉด ์ดํ•ดํ•˜๊ธฐ ์‰ฝ๋‹ค. Script๋ฅผ ์—์…‹์œผ๋กœ ๋งŒ๋“ค์–ด์„œ ๊ฐ’์„ ์ €์žฅ ๋ฐ ๊ด€๋ฆฌํ•  ์ˆ˜ ์žˆ๊ธฐ ๋•Œ๋ฌธ์ด๋‹ค. ํŠนํžˆ ์—์…‹์œผ๋กœ ๋งŒ๋“ค๊ณ  AssetBundle์ด๋‚˜ Addressable Asset์œผ๋กœ ๊ด€๋ฆฌํ•˜๋ฉด ๋ฐ์ดํ„ฐ ์ˆ˜์ •์‹œ ๋นŒ๋“œ&๋ฐฐํฌ๊ฐ€ ํ•„์š” ์—†๊ธฐ ๋•Œ๋ฌธ์— ๊ทธ ํšจ์œจ์ด ๊ทน๋Œ€ํ™” ๋œ๋‹ค.(Scriptable Object ์žฅ์ ) * Scriptable Object ์‚ฌ์šฉ๋ฒ• 1. ์ •์˜ ๋ฐ ์—์…‹ ์ƒ์„ฑ using UnityEngine; [CreateAssetMenu(fileName = "Data", menuName = "ScriptableObjects/SpawnManagerScriptableObject", order = 1)] public class SpawnManager..

[Unity] Editor Programming

ํ…์ŠคํŠธ์˜ ํฐํŠธ๋ฅผ ์ผ๊ด„์ ์œผ๋กœ ๋ฐ”๊ฟ”์•ผ ํ•  ๋•Œ, ํŠน์ • ๊ฐ์ฒด๋ฅผ ๋ชจ๋‘ ์ง€์›Œ์•ผํ•  ๋•Œ ๋“ฑ๋“ฑ ๋ฌด์˜๋ฏธํ•œ ๋ฐ˜๋ณต์ž‘์—…์„ ์ˆ˜ํ–‰ํ•ด์•ผ ํ•˜๋Š” ๊ฒฝ์šฐ๊ฐ€ ์žˆ๋‹ค. ์ด๋Ÿด ๋•Œ Editor Programming์„ ์‚ฌ์šฉํ•œ๋‹ค๋ฉด ๋น ๋ฅด๊ณ  ์‰ฝ๊ณ  ์ •ํ™•ํ•˜๊ฒŒ ๋ณ€๊ฒฝ์ด ๊ฐ€๋Šฅํ•˜๋‹ค. ๋” ํšจ์œจ์ ์ธ ๊ฐœ๋ฐœ์„ ์œ„ํ•ด์„œ๋Š” ํ•„์ˆ˜๋‹ค ! 1. ์ƒ๋‹จ ๋ฉ”๋‰ด ์ƒ์„ฑํ•˜๊ณ  ๋นˆ Editor ํ™”๋ฉด ๋งŒ๋“ค๊ธฐ using UnityEditor; public class MyEditorWindow : EditorWindow { [MenuItem("MyTool/Open MyTool %g")] static void Open() { var window = GetWindow(); window.title = "MyTool"; } } ์ƒ๋‹จ์— MyTool ๋ฉ”๋‰ด๋ฅผ ๋งŒ๋“ค๊ณ  ๋ฉ”๋‰ด๋ฅผ ์—ด๋ฉด Open MyTool ๋ฉ”๋‰ด๊ฐ€ ์ƒ์„ฑ๋œ๋‹ค..

[Unity] Advanced InputField ์‚ฌ์šฉ๋ฒ•

* Asset ๋‹ค์šด๋กœ๋“œ * ๋„ค์ž„์ŠคํŽ˜์ด์Šค ์ถ”๊ฐ€ using AdvancedInputFieldPlugin; * ์„ ์–ธ [SerializeField] private AdvancedInputField inputField; * ์‚ฌ์šฉ //inputfield ์— ์ž…๋ ฅ๋œ ๋ฌธ์ž ๊ฐ€์ ธ์˜ค๊ธฐ inputField.GetText(); //inputfield ์— ๋ฌธ์ž ์ž…๋ ฅํ•˜๊ธฐ inputField.SetText(""); * ์†์„ฑ * ๊ณต์‹ Github ๋งํฌ https://github.com/development-fennecx/AdvancedInputField GitHub - development-fennecx/AdvancedInputField: This plugin provides a more Advanced Input Field tha..

[Unity] UGUI - Anchor(๊ธฐ์ค€), Pivot(๋‚˜)

๋งจ๋‚  ํ—ท๊ฐˆ๋ฆฌ๋Š” anchor์™€ pivot ๊ฐœ๋…์„ ์ •๋ฆฌํ•ด๋ณด์ž. * ์•ต์ปค(Anchor) : UI ์œ„์น˜๋ฅผ ๊ณ„์‚ฐํ•  ๋•Œ ์‚ฌ์šฉํ•  ๊ธฐ์ค€์ ์˜ ์œ„์น˜๋ฅผ ๋‚˜ํƒ€๋ƒ„. : Pos X ์™€ Pos Y ๊ฐ’์€ ์•ต์ปค(๊ธฐ์ค€์ )์— ๋Œ€ํ•ด ์ง€์ •๋˜๋Š” ๊ฐ์ฒด์˜ Position ๊ฐ’์ด๋‹ค. : ์„ธ๋ชจ๋ชจ์–‘ 4๊ฐœ๋กœ ์ƒ๊ธด๊ฒƒ์ด ์•ต์ปค์˜ ์œ„์น˜๋ฅผ ๋‚˜ํƒ€๋‚ธ๋‹ค. : Anchor Min ์€ ์”ฌ ๋ทฐ์—์„œ ์™ผ์ชฝ ํ•˜๋‹จ ์•ต์ปค ํ•ธ๋“ค์— ํ•ด๋‹นํ•˜๋ฉฐ, Anchor Max ๋Š” ์˜ค๋ฅธ์ชฝ ์ƒ๋‹จ ํ•ธ๋“ค์— ํ•ด๋‹น : ์™ผ์ชฝ์•„๋ž˜ ๊ผญ์ง€์ ์ด (0, 0) / ์˜ค๋ฅธ์ชฝ์œ„ ๊ผญ์ง€์ ์ด (1, 1) * ํ”ผ๋ฒ—(Pivot) : ๊ฐ์ฒด์˜ ์ค‘์‹ฌ. ์ฆ‰, ์ž์‹ ์˜ ๊ธฐ์ค€์ ์€ ์–ด๋””๋กœ ์„ค์ •ํ•  ๊ฒƒ์ธ์ง€๋ฅผ ์˜๋ฏธํ•จ. : UI ์œ„์น˜๋ฅผ ๊ณ„์‚ฐํ•  ๋•Œ ๊ธฐ์ค€์ ๊ณผ์˜ ๊ฑฐ๋ฆฌ๋ฅผ ๊ณ„์‚ฐํ•  ์ ์˜ ์œ„์น˜. : ํŒŒ๋ž€ ๋„๋„› ๋ชจ์–‘์œผ๋กœ ์ƒ๊ธด ๊ฒƒ์ด ์œ„์น˜๋ฅผ ์•ˆ๋‚ด ํ•จ. P.S) transfor..

[Unity LifeCycle] ์œ ๋‹ˆํ‹ฐ ์ƒ๋ช…์ฃผ๊ธฐ

1. Editor ๊ด€๋ จ Editor ๋ชจ๋“œ์—์„œ ๊ฐ’์ด ๋ณ€๊ฒฝ๋  ๋•Œ ๋ฐ”๋กœ ๋ฐ˜์˜๋œ๋‹ค. Script์—์„œ ๋ณ€์ˆ˜๋ฅผ ํ• ๋‹นํ•˜๊ณ  ๋‹ค์‹œ Editor๋กœ ๋Œ์•„์˜ค๋ฉด ๋กœ๋”ฉ์ด ๋ฐœ์ƒํ•˜๊ณ  public ์œผ๋กœ ์„ ์–ธํ–ˆ๋‹ค๋ฉด Inspector ์ฐฝ์—์„œ ๋ณ„๋„์˜ ์‹คํ–‰๊ณผ์ • ์—†์ด ํ™•์ธ ๊ฐ€๋Šฅํ•˜๋‹ค. Reset(): Object๋ฅผ ์ƒ์„ฑํ•˜๊ณ  Inspector ์ฐฝ์—์„œ Reset ํ•  ๋•Œ ์‹คํ–‰๋œ๋‹ค. Object์˜ ๊ฐ’์€ ์ดˆ๊ธฐ๊ฐ’์œผ๋กœ ์„ค์ •ํ•  ๋•Œ ์‚ฌ์šฉ๋œ๋‹ค. 2. Initialization ๊ด€๋ จ : ์ดˆ๊ธฐํ™” ํ•จ์ˆ˜๋“ค์ด ์—ฌ๋Ÿฌ๊ฐ€์ง€ ์กด์žฌํ•˜๋ฉฐ ์ˆœ์„œ์— ๋”ฐ๋ผ์„œ ์ ์ ˆํ•œ ๋ฐฐ์น˜๊ฐ€ ํ•„์š”ํ•˜๋‹ค. : ์”ฌ์ด ์‹œ์ž‘ํ•  ๋•Œ ํ•œ๋ฒˆ๋งŒ ํ˜ธ์ถœ๋œ๋‹ค. Awake(): Play ๋ชจ๋“œ์—์„œ Scene์ด ์‹œ์ž‘๋˜๊ณ  Prefab์˜ ์ธ์Šคํ„ด์Šคํ™” ์งํ›„์— ํ˜ธ์ถœ๋œ๋‹ค. ์‹œ์ž‘ ์‹œ ํ•œ ๋ฒˆ๋งŒ ํ˜ธ์ถœ๋˜๋ฉฐ Object๊ฐ€ ๋น„ํ™œ์„ฑํ™” ๋˜์–ด ์žˆ์–ด๋„ ํ˜ธ์ถœ๋œ๋‹ค...

[Unity] Scrollrect ์ปดํฌ๋„ŒํŠธ๋กœ Scrollview ๋งŒ๋“ค๊ธฐ

[๊ธฐ๋ณธ๊ฐœ๋…] Unity์—์„œ ์ œ๊ณตํ•˜๋Š” ์Šคํฌ๋กค ์‚ฌ๊ฐ ์˜์—ญ(Scroll Rect) Component๋กœ ์ฝ˜ํ…์ธ ๋ฅผ ์Šคํฌ๋กคํ•˜๋Š” ๊ธฐ๋Šฅ์„ ๋งŒ๋“ค ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค. Scroll Rect์˜ ๊ธฐ๋ณธ ์†์„ฑ์€ ๋‹ค์Œ๊ณผ ๊ฐ™์Šต๋‹ˆ๋‹ค. - ํ”„๋กœํผํ‹ฐ ํ”„๋กœํผํ‹ฐ ๊ธฐ๋Šฅ ์„ค๋ช… Content ์ปค๋‹ค๋ž€ ์ด๋ฏธ์ง€์™€ ๊ฐ™์€, ์Šคํฌ๋กค๋  UI ์š”์†Œ์˜ ์‚ฌ๊ฐ ํŠธ๋žœ์Šคํผ์— ๋Œ€ํ•œ ์ฐธ์กฐ์ž…๋‹ˆ๋‹ค. Horizontal ์ˆ˜ํ‰ ์Šคํฌ๋กค๋ง์„ ํ™œ์„ฑํ™”ํ•ฉ๋‹ˆ๋‹ค. Vertical ์ˆ˜์ง ์Šคํฌ๋กค๋ง์„ ํ™œ์„ฑํ™”ํ•ฉ๋‹ˆ๋‹ค. Movement Type ์ œํ•œ ์—†์Œ, ํƒ„์„ฑ ์žˆ์Œ ๋˜๋Š” ์œ„์น˜ ํ•œ์ •. ํƒ„์„ฑ ์žˆ์Œ์ด๋‚˜ ์œ„์น˜ ํ•œ์ • ์˜ต์…˜์„ ์‚ฌ์šฉํ•˜๋ฉด ์ฝ˜ํ…์ธ ๊ฐ€ ์Šคํฌ๋กค ์‚ฌ๊ฐ ์˜์—ญ ๋ฒ”์œ„ ๋‚ด์— ๋จธ๋ฌผ๊ฒŒ ๋ฉ๋‹ˆ๋‹ค. ํƒ„์„ฑ ์žˆ์Œ ๋ชจ๋“œ๋ฅผ ์‚ฌ์šฉํ•˜๋ฉด ์ฝ˜ํ…์ธ ๊ฐ€ ์Šคํฌ๋กค ์‚ฌ๊ฐ ์˜์—ญ ๊ฐ€์žฅ์ž๋ฆฌ์— ๋‹ฟ์œผ๋ฉด ํŠ•๊ธฐ๊ฒŒ ๋ฉ๋‹ˆ๋‹ค. Elasticity ํƒ„์„ฑ ์žˆ์Œ ๋ชจ๋“œ์—์„œ ์‚ฌ์šฉํ• ..

[Unity] TextMeshPro ํฐํŠธ์ถ”๊ฐ€ ๋ฐ ํ•œ๊ธ€์ž…๋ ฅ

1. ์›ํ•˜๋Š” ํฐํŠธ ๋‹ค์šด๋กœ๋“œํ•ด์„œ Asset ํด๋”์— ์˜ฎ๊ฒจ๋†“๊ธฐ. https://hangeul.naver.com/font ๋„ค์ด๋ฒ„ ๊ธ€๊ผด ๋ชจ์Œ ๋„ค์ด๋ฒ„๊ฐ€ ๋งŒ๋“  150์—ฌ์ข…์˜ ๊ธ€๊ผด์„ ํ•œ๋ฒˆ์— ๋งŒ๋‚˜๋ณด์„ธ์š” hangeul.naver.com 2. Unity์—์„œ Window > TextMeshPro > Font Asset Creator ํด๋ฆญ ํ›„ ์…‹ํŒ… ๊ฐ’ ์ž…๋ ฅ. 1) SourceFontFile : ๋‹ค์šด๋ฐ›์€ ํฐํŠธ 2) Sampling Point Size : ์ž๋™ ์…‹ํŒ… or ์‚ฌ์ด์ฆˆ ์ง€์ • 3) Padding : ๊ธ€์ž ํŒจ๋”ฉ๊ฐ’ 4) PackingMethod : Fast 5) Atlas Resolution : ์‚ฌ์ด์ฆˆ ๋„‰๋„‰ํ•˜๊ฒŒ 4096์œผ๋กœ 6) CharacterSet : CustomRange 7) Character Sequence์— ๋ฒ”์œ„ ์ž…๋ ฅ ..

[Unity .gitignore] Unity .gitignore ํŒŒ์ผ ๋งŒ๋“ค๊ธฐ

Unity ํ”„๋กœ์ ํŠธ๋ฅผ ๋งŒ๋“ค๋ฉด ์ž๋™์œผ๋กœ ์ƒ์„ฑ๋˜๋Š” ํŒŒ์ผ๋“ค์ด ์žˆ๋‹ค. ์•„๋ž˜ 6๊ฐœ. TempLibraryAssetsProjectSettingsLogsPackages ์ด ๋•Œ, Assets, ProjectSettings, Packages ํŒŒ์ผ๋งŒ ์žˆ์œผ๋ฉด ๋‹ค๋ฅธ ํŒŒ์ผ๋“ค์€ meta ํŒŒ์ผ๊ณผ cash ์— ์˜ํ•ด ์•Œ์•„์„œ ๋งŒ๋“ค์–ด ์ง„๋‹ค.์ฆ‰, ๋‹ค๋ฅธ ํด๋”๋ฅผ Git์— ์˜ฌ๋ฆฌ๋ฉด ์„œ๋ฒ„ ์šฉ๋Ÿ‰๋งŒ ์ฐจ์ง€ํ•  ๋ฟ ํ•„์š”๊ฐ€ ์—†๋‹ค๋Š” ๋œป! .gitignore ํŒŒ์ผ์„ ๋งŒ๋“ค์–ด์„œ ์—†์• ๋ฒ„๋ฆฌ์ž~1. Github ์‚ฌ์ดํŠธ์—์„œ ์ œ๊ณตํ•˜๋Š” .gitignore ํŒŒ์ผ ๋ชฉ๋ก์—์„œ Unity.gitignore ํŒŒ์ผ ๋‹ค์šด๋กœ๋“œ or ๋‚ด์šฉ ๋ณต์‚ฌhttps://github.com/github/gitignore GitHub - github/gitignore: A collection of useful..

728x90