[UE5 / C++] ๐Ÿงฎ Multi Output

Singery00ยท2024๋…„ 7์›” 11์ผ
0

UE5 C++

๋ชฉ๋ก ๋ณด๊ธฐ
17/20
post-thumbnail

๊ฐœ์š”

๐Ÿงฎ C++๋กœ ๋‹ค์ค‘ ์ž…๋ ฅ๊ณผ ๋‹ค์ค‘ ์ถœ๋ ฅ์„ ๋ฐ›๋Š” ํ•จ์ˆ˜๋ฅผ ์ž‘์„ฑํ•˜์ž

๋ธ”๋ฃจํ”„๋ฆฐํŠธ์˜ ๋…ธ๋“œ๋ฅผ ๋ณด๋ฉด ๋‹ค์ค‘์ž…๋ ฅ๊ณผ ๋‹ค์ค‘์ถœ๋ ฅ์„ ๋ฐ›์„ ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค.
์ด๊ฑธ C++๋กœ ๋งŒ๋“ค์–ด ๋ณด๊ฒ ์Šต๋‹ˆ๋‹ค.

์ฐธ๊ณ  ํฌ๋Ÿผ


๋ณธ๋ก 


๐Ÿงฎ Multi Output

๋‹ค์ค‘ ๊ฐ’์„ ๋ฐ˜ํ™˜ํ•˜๊ธฐ ์œ„ํ•ด์„œ ๊ตฌ์กฐ์ฒด๋ฅผ ํ•˜๋‚˜ ๋งŒ๋“ค์–ด์„œ ํ•ด๋‹น ๊ตฌ์กฐ์ฒด๋ฅผ ๋ฐ˜ํ™˜ํ•ด๋„ ๋ฉ๋‹ˆ๋‹ค.

๊ทผ๋ฐ ์–ธ์ œ ๊ฐ ๋ฐ˜ํ™˜์— ํ•„์š”ํ•œ ๊ตฌ์กฐ์ฒด๋ฅผ ๋‹ค ๋งŒ๋“ค์–ด์„œ ํ• ๋‹นํ•˜๊ณ  ๋ฐ˜ํ™˜ํ•˜๋‚˜ ์‹ถ์–ด ์ฐพ์•„ ๋ดค์Šต๋‹ˆ๋‹ค.


๋‹ค์ค‘ ์ž…๋ ฅ

๋‹ค์ค‘ ์ž…๋ ฅ์€ ์‚ฌ์‹ค ๋˜‘๊ฐ™์Šต๋‹ˆ๋‹ค.

์ผ๋ฐ˜ ํ•จ์ˆ˜ ์ž…๋ ฅ๊ฐ’ ํŒŒ๋ผ๋ฏธํ„ฐ๋ฅผ ๋งŒ๋“ค์–ด ์ฃผ์‹œ๋ฉด ๋ฉ๋‹ˆ๋‹ค.

	UFUNCTION(BlueprintCallable, Category = "Unit Status")
	void TestMultiInput(float MyFloat, FString MyString);

๊ทธ๋ฆฌ๊ณ  Blueprint ์ƒ์—์„œ ๊ฒ€์ƒ‰ํ•ด์„œ ๋…ธ๋“œ๋ฅผ ์ถ”๊ฐ€ํ•ด๋ณด๋ฉด?

์„ค์ •ํ•œ MyFloat๊ณผ MyString์„ ์ž…๋ ฅ๋ฐ›์„ ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค.


๋‹ค์ค‘ ์ถœ๋ ฅ

๋‹ค์ค‘ ์ถœ๋ ฅ์€ ๋งค์šฐ ๊ฐ„๋‹จํ•ฉ๋‹ˆ๋‹ค.

์ž๋ฃŒํ˜• ๋’ค์— &์„ ๋ถ™์ด๋ฉด ๋์ž…๋‹ˆ๋‹ค.

์ด๋ ‡๊ฒŒ์š”.

	UFUNCTION(BlueprintCallable, Category = "Unit Status")
	void TestMultiOutput(float& MyFloat, FString& MyString);

Blueprint ์ƒ์—์„œ ๊ฒ€์ƒ‰ํ•ด์„œ ๋…ธ๋“œ๋ฅผ ์ถ”๊ฐ€ํ•ด๋ณด๋ฉด?

๋‹ค์ค‘๊ฐ’์„ ์ถœ๋ ฅํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค.

๊ฐ’์€ ๊ตฌํ˜„๋ถ€์—์„œ ๋™์ผํ•˜๊ฒŒ ํ• ๋‹นํ•ด์ฃผ๋ฉด ํ• ๋‹นํ•œ ๊ฐ’์ด ์ถœ๋ ฅ๋ฉ๋‹ˆ๋‹ค.

void AUnitBase::TestMultiOutput(float& MyFloat, FString& MyString)
{
	MyFloat = 5.0f;
	MyString = "Test";
}

๋™์‹œ์— ์‚ฌ์šฉ

๋ฌผ๋ก  ๋™์‹œ์— ์‚ฌ์šฉํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค.

๋‹จ, ๊ธฐ๋ณธ ๊ทœ์น™๊ณผ ๋™์ผํ•˜๊ฒŒ ํŒŒ๋ผ๋ฏธํ„ฐ ๊ฐ„์˜ ์ด๋ฆ„์€ ๋‹ฌ๋ผ์•ผ ํ•ฉ๋‹ˆ๋‹ค.
2๊ฐœ์˜ ์ž…๋ ฅ๊ณผ, 2๊ฐœ์˜ ์ถœ๋ ฅ์„ ๋„ฃ์—ˆ์Šต๋‹ˆ๋‹ค.

	UFUNCTION(BlueprintCallable, Category = "Unit Status")
	void TestMultiOutputValue(float MyFloat,FString MyString, float& MyFloatOut, FString& MyStringOut);

๊ทธ๋ฆฌ๊ณ  ์ž…๋ ฅ๊ฐ’์„ ์ถœ๋ ฅ๊ฐ’์— ํ• ๋‹นํ•ด๋ณด๊ฒ ์Šต๋‹ˆ๋‹ค.

void AUnitBase::TestMultiOutputValue(float MyFloat, FString MyString, float& MyFloatOut, FString& MyStringOut)
{
	MyFloatOut = MyFloat;
	MyStringOut = MyString;
}

Blueprint์—์„œ ๋…ธ๋“œ๋ฅผ ๊ฒ€์ƒ‰ํ•˜๋ฉด ์•„๋ž˜์ฒ˜๋Ÿผ ๋‚˜์˜ค์ฃ .

์ง์ ‘ ์ถœ๋ ฅํ•ด๋ณด๊ฒ ์Šต๋‹ˆ๋‹ค.
๊ฐ„๋‹จํ•˜๊ฒŒ ์ž‘์„ฑํ•ด์„œ 555์™€ Test๋ฅผ ๋„ฃ์–ด ๋ดค๊ตฌ์š”.

์‹คํ–‰ํ•˜๋ฉด ์ž˜ ์ถœ๋ ฅ๋˜๋Š” ๊ฒƒ์„ ํ™•์ธํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค.

์™œ ์ด๋ ‡๊ฒŒ ๋™์ž‘ํ•˜๋ƒ๊ณ  ๋ฌผ์œผ์‹œ๋ฉด ๊ทธ๋ƒฅ ์—”์ง„์ด ๊ทธ๋ ‡๊ฒŒ ๋™์ž‘ํ•œ๋‹ค๊ณ  ํ•ฉ๋‹ˆ๋‹ค.
ํฌ๋Ÿผ์—์„œ ์นด๋”๋ผ...


๋งˆ๋ฌด๋ฆฌ

Blueprint์™€ ๋™์‹œ์— ์ž‘์—…ํ•  ๋•Œ ๊ตฌ์กฐ์ฒด๋ฅผ ๋งŒ๋“ค์ง€ ์•Š๊ณ  ํŽธํ•˜๊ฒŒ ์ž‘์—…ํ•  ์ˆ˜ ์žˆ์–ด ์ข‹์€ ๊ฒƒ ๊ฐ™์Šต๋‹ˆ๋‹ค.

profile
๊ฒŒ์ž„ ๊ฐœ๋ฐœ์ž๊ฐ€ ๋˜์–ด๋ณด์ž

0๊ฐœ์˜ ๋Œ“๊ธ€