[Unity] null ์ฒดํฌ
ยท
๐Ÿ“ Game/โœ Unity
1. UnityEngine.Object == null๊ฐœ๋ฐœ ์‹œ ๊ฐ์ฒด๊ฐ€ ์‹ค์ œ๋กœ ์กด์žฌํ•˜๋Š”์ง€ ํ™•์ธํ•˜๊ธฐ ์œ„ํ•ด == null ์ฒดํฌ๋ฅผ ์ž์ฃผ ์‚ฌ์šฉํ•˜๊ณค ํ•œ๋‹ค. ๊ณผ์—ฐ ์ด ๋ฐฉ๋ฒ•์ด ์ตœ์„ ์ผ๊นŒ? 2. fake null"UnityEngine.Object == null์—์„œ์˜ null์ด ์ง„์งœ null์ด ์•„๋‹ˆ๋‹ค! ์ฆ‰, fake null์ด๋‹ค"๋ผ๋Š” ๋ง์ด ์กด์žฌํ•œ๋‹ค. ์™œ ๊ทธ๋Ÿด๊นŒ? ์›์ธ์€ ์œ ๋‹ˆํ‹ฐ์—์„œ์˜ null๊ณผ System์—์„œ์˜ null์˜ ์ฐจ์ด์ด๋‹ค. ์ด ์ฐจ์ด๋ฅผ ์•Œ์•„๋ณด๊ธฐ ์œ„ํ•ด ๋‹ค์Œ๊ณผ ๊ฐ™์ด ์ฝ”๋“œ๋ฅผ ์‹คํ–‰ํ•˜๋ฉด, UnityEngine.Object์™€ System.Object์˜ null ์ฒดํฌ ๊ฐ’์ด ๋‹ค๋ฅธ ๊ฒƒ์„ ํ™•์ธํ•  ์ˆ˜ ์žˆ๋‹ค. var obj = new GameObject();yield return null; Destroy(obj);yield return nu..
[Unity] ์ฝ”๋“œ ๋‚ด ํž™ ๋ฉ”๋ชจ๋ฆฌ ์ตœ์ ํ™”
ยท
๐Ÿ“ Game/โœ Unity
์ฝ”๋“œ ๋‚ด ํž™ ๋ฉ”๋ชจ๋ฆฌ ์ตœ์ ํ™” ํ”„๋กœ๊ทธ๋žจ์„ ๋งŒ๋“ค ๋•Œ ํž™ ๋ฉ”๋ชจ๋ฆฌ ์˜์—ญ์€ ํ”„๋กœ๊ทธ๋ž˜๋จธ๊ฐ€ ํ•ญ์ƒ ์‹ ๊ฒฝ ์จ์•ผ ๋˜๋Š” ์ค‘์š”ํ•œ ๋ฉ”๋ชจ๋ฆฌ ์˜์—ญ์ด๋‹ค. ์œ ๋‹ˆํ‹ฐ์—์„œ ํž™ ๋ณ€์ˆ˜๊ฐ€ ์ƒ์„ฑ๋  ๋•Œ ์—ฌ์œ  ๋ฉ”๋ชจ๋ฆฌ๊ฐ€ ์ถฉ๋ถ„ํ•˜์ง€ ์•Š๋‹ค๋ฉด GC์„ ์ˆ˜ํ–‰ํ•œ๋‹ค. ํ•˜์ง€๋งŒ GC์€ ๊ฝค๋‚˜ ๋ฌด๊ฑฐ์šด ์ž‘์—…์ด๊ธฐ ๋•Œ๋ฌธ์— ์ด ์ˆœ๊ฐ„ ํ”„๋ ˆ์ž„ ๋“œ๋กญ์ด ๋ฐœ์ƒํ•œ๋‹ค. ์ด๋ฅผ ๊ฐœ์„ ํ•˜๊ธฐ ์œ„ํ•ด ์ตœ๊ทผ์—๋Š” Inscremental GC ๊ธฐ๋Šฅ์ด ์—…๋ฐ์ดํŠธ๋˜๊ธด ํ•˜์˜€์ง€๋งŒ, ๊ทธ๋ž˜๋„ GC์˜ ๋Œ€์ƒ์ด ๋˜๋Š” ํž™ ํ• ๋‹น์„ ์ตœ๋Œ€ํ•œ ๋งŒ๋“ค์ง€ ์•Š๋Š” ๊ฒƒ์ด ์ข‹๋‹ค. 1) ์ž์ฃผ ์‚ฌ์šฉ๋˜๋Š” ์ฐธ์กฐ ๋ณ€์ˆ˜๋Š” ์บ์‹ฑํ•˜๊ธฐ private Button btn; void Start() { btn = GetComponent(); } public void MyMethod() { //Button btn = GetComponent(); // ํ•จ์ˆ˜ ํ˜ธ์ถœ์‹œ ๋งˆ๋‹ค ํž™ ..
[Unity] Mathf.Lerp() ํ•จ์ˆ˜
ยท
๐Ÿ“ Game/โœ Unity
Lerp 1. ๊ฐœ๋… ์„ ํ˜• ๋ณด๊ฐ„(Linear Interpolation)์€ ๋‘ ์ (a, b) ์‚ฌ์ด์˜ ๊ฐ’(c)์„ ๊ตฌํ•˜๊ธฐ ์œ„ํ•ด ๋‘ ์ ์„ ์—ฐ๊ฒฐํ•œ ์ง์„ ์„ ๋งŒ๋“ค์–ด ์‚ฌ์ด ๊ฐ’(t)์„ ๊ณ„์‚ฐํ•˜๋Š” ๋ฐฉ๋ฒ•์ด๋‹ค. Mathf.Lerp(float a, float b, float t) ์—ฌ๊ธฐ์„œ t๋Š” percet(0 ~ 1)์˜ ๊ฐœ๋…์ด๊ธฐ ๋•Œ๋ฌธ์— t = 0์ด๋ฉด a, t = 1์ด๋ฉด b์™€ ๊ฐ™๋‹ค. 2. ์œ ๋‹ˆํ‹ฐ ํ™œ์šฉ 1) ๋ถ€๋“œ๋Ÿฌ์šด ์›€์ง์ž„ ๋ถ€๋“œ๋Ÿฌ์šด ์›€์ง์ž„์„ ํ‘œํ˜„ํ•˜๊ธฐ ์œ„ํ•ด Update()์—์„œ ๋‘ ์  ์‚ฌ์ด์˜ ๊ตฌ๊ฐ„์„ ์ง€์†์ ์œผ๋กœ ์ด๋™์‹œ์ผœ ํ™œ์šฉํ•  ์ˆ˜ ์žˆ๋‹ค. Update() ํ•จ์ˆ˜๊ฐ€ ํ˜ธ์ถœ๋˜๋Š” ๋งค ํ”„๋ ˆ์ž„๋งˆ๋‹ค ์œ„์น˜๋Š” ๊ณ„์† ์›€์ง์ผ ๊ฒƒ์ด๊ณ  ๋ชฉํ‘œ ์ง€์ ์— ๊ทผ์ ‘ํ• ์ˆ˜๋ก ๋”์šฑ ๋ถ€๋“œ๋Ÿฌ์šด ์›€์ง์ž„์„ ๋‚˜ํƒ€๋‚ด๊ฒŒ ๋œ๋‹ค. void Update() { a = Mathf.Lerp(a, b, 0...
[Unity] ํ™œ์šฉ ๊ฐ€๋Šฅํ•œ AI ์ฝ”๋”ฉ ์„œ๋น„์Šค 2ํŽธ
ยท
๐Ÿ“ Game/โœ Unity
ํ™œ์šฉ ๊ฐ€๋Šฅํ•œ AI ์ฝ”๋”ฉ ์„œ๋น„์Šค 2. Github Copilot Github Copilot์€ ์ž๋™ ์ฝ”๋“œ ์™„์„ฑ ์ธ๊ณต์ง€๋Šฅ์ด๋‹ค. ๊นƒํ—ˆ๋ธŒ์— ์žˆ๋Š” ์ˆ˜๋งŽ์€ ๋ ˆํฌ์ง€ํ† ๋ฆฌ๋“ค์„ ํ•™์Šตํ•˜์—ฌ ์ฃผ์„์ด๋‚˜ ํ•จ์ˆ˜๋ฅผ ์ž๋™์œผ๋กœ ์™„์„ฑํ•ด ๋‹จ์ˆœํ•˜๊ณ  ๋ฒˆ๊ฑฐ๋กœ์šด ์ž‘์—…๋“ค์„ ์ž๋™ํ™”ํ•  ์ˆ˜ ์žˆ๋‹ค. https://github.com/features/copilot?utm_source=youtube&utm_medium=social&utm_campaign=unitylive-jan_unitytips_aicoding GitHub Copilot · Your AI pair programmer GitHub Copilot works alongside you directly in your editor, suggesting whole lines or entire function..
[Unity] ํ™œ์šฉ ๊ฐ€๋Šฅํ•œ AI ์ฝ”๋”ฉ ์„œ๋น„์Šค 1ํŽธ
ยท
๐Ÿ“ Game/โœ Unity
ํ™œ์šฉ ๊ฐ€๋Šฅํ•œ AI ์ฝ”๋”ฉ ์„œ๋น„์Šค 1ํŽธ 1. ChatGPT ChatGPT๋ฅผ ์ด์šฉํ•˜์—ฌ ์œ ๋‹ˆํ‹ฐ C# ์Šคํฌ๋ฆฝํŠธ๋ฅผ ์งœ๋„๋ก ํ™œ์šฉํ•  ์ˆ˜ ์žˆ๋‹ค. https://openai.com/blog/chatgpt?utm_source=youtube&utm_medium=social&utm_campaign=unitylive-jan_unitytips_aicoding Introducing ChatGPT We’ve trained a model called ChatGPT which interacts in a conversational way. The dialogue format makes it possible for ChatGPT to answer followup questions, admit its mistakes, challenge inc..
[Unity] ๋ชจ๋ฐ”์ผ ๊ฒŒ์ž„ ์„ฑ๋Šฅ ์ตœ์ ํ™” 2ํŽธ
ยท
๐Ÿ“ Game/โœ Unity
๋ชจ๋ฐ”์ผ ๊ฒŒ์ž„ ์„ฑ๋Šฅ ์ตœ์ ํ™” 2ํŽธ 1. ์Œ์•… ํŒŒ์ผ wav ์›๋ณธ ์‚ฌ์šฉ ์–ด์ฐจํ”ผ ์œ ๋‹ˆํ‹ฐ์—์„œ ๋‹ค์‹œ ์••์ถ•์„ ํ•ด์ฃผ๊ธฐ ๋•Œ๋ฌธ์— mp3๋ฅผ ์ผ์„ ๋•Œ์˜ ์ด๋“์€ ํ”„๋กœ์ ํŠธ์˜ ์šฉ๋Ÿ‰์ด ์ค„์–ด๋“ ๋‹ค๋Š” ๊ฒƒ ๋ฐ–์— ์—†๋‹ค. ๊ทธ๋ ‡๋‹ค๊ณ  ์ด๋ฏธ ์••์ถ•๋œ mp3๋ฅผ wav๋กœ ๋ฐ”๊ฟ€ ํ•„์š”๋Š” ์—†๋‹ค. 2. ํ…์Šค์ณ, 3D Mesh์˜ Read/Write Enabled ์ฒดํฌ๋ฐ•์Šค ๋น„ํ™œ์„ฑํ™” CPU์—์„œ GPU๋กœ ๋ฉ”๋ชจ๋ฆฌ๋ฅผ ์˜ฎ๊ธฐ๊ณ  CPU์—์„œ๋Š” ๋‚ด๋ฆฐ๋‹ค. ํ™œ์„ฑํ™”ํ•œ ๊ฒฝ์šฐ์—๋Š” CPU์—์„œ ๋ฉ”๋ชจ๋ฆฌ๋ฅผ ๋‚ด๋ฆฌ์ง€ ์•Š์•„ ๋ฉ”๋ชจ๋ฆฌ๊ฐ€ ์ค‘๋ณต๋œ๋‹ค. ํ…์Šค์ณ๋ฅผ ๋™์ ์œผ๋กœ ์กฐ์ž‘ํ•œ๋‹ค๋ฉด ๋‹น์—ฐํžˆ ์ผœ์•ผ ํ•˜์ง€๋งŒ, ์•„๋‹ˆ๋ผ๋ฉด ๋น„ํ™œ์„ฑํ™”ํ•˜๋Š” ๊ฒƒ์ด ์ข‹๋‹ค. 3. ํ™”๋ฉด ํ•ด์ƒ๋„ ์กฐ์ ˆ Screen.SetResolution(width, height, false); 4. Renderer.material ์ ‘๊ทผ ์ฃผ์˜ Renderer.materia..