Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TArray.Add() 变参函数 #1513

Merged
merged 1 commit into from
Sep 12, 2023
Merged

TArray.Add() 变参函数 #1513

merged 1 commit into from
Sep 12, 2023

Conversation

BlurryLight
Copy link
Contributor

int32 Index = AddUninitialized(Self, GetSizeWithAlignment(Inner->Property), Info.Length());

看了下void FScriptArrayWrapper::Add的实现感觉这个接口应该是支持在ts端变参输入的,这样可以一次调用Add多个元素。

测试代码:

function printTArray<T>(arr: ue.TArray<T>)
{
    console.log("-----Num:", arr.Num());
    for(var i=0; i < arr.Num(); i++) {
        console.log(i, ":", arr.Get(i));
    }
}

let arr = ue.NewArray(ue.BuiltinInt);
arr.Add(...[1,2,3,4,5])
printTArray(arr);   // 5 , 1,2,3,4,5



let strArr = ue.NewArray(ue.BuiltinString);
strArr.Add(...["Hello","Puer","Ts"])
printTArray(strArr); // 3, hello puer ts

@chexiongsheng chexiongsheng merged commit 837d29c into Tencent:master Sep 12, 2023
@BlurryLight BlurryLight deleted the patch-1 branch September 12, 2023 13:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants