2023/10/02_UE5.3_問題:ラムダ式を使うと変更可能な左辺値である必要があると出る。
下記コードのbResult。
// 結果を示すフラグ
bool bResult = false;
FFunctionGraphTask::CreateAndDispatchWhenReady([this, ObjectPath, bResult]()
{
// ObjectPath の有効性を確認
if (ObjectPath.IsEmpty())
{
UE_LOG(LogTemp, Error, TEXT("ObjectPath is empty."));
bResult = false;// ObjectPathが見つからなければFalseを返す
}
解決
解決
下記コードのようにラムダ引数の前に & を付けて解決。
// 結果を示すフラグ
bool bResult = false;
// bResult をラムダ式内で変更可能な左辺値にするには、ラムダ引数の前に & を付けること
FFunctionGraphTask::CreateAndDispatchWhenReady([this, ObjectPath, &bResult]()
{
// ObjectPath の有効性を確認
if (ObjectPath.IsEmpty())
{
UE_LOG(LogTemp, Error, TEXT("ObjectPath is empty."));
bResult = false;// ObjectPathが見つからなければFalseを返す
}