[ad_1]
I adopted this submit to implement a delegate on a listing that notifies me when a change has occurred (add file, delete file or take away file).
This works superb, although the problem is that for every operation, a number of occasions are triggered. Within the Information
array containing info from the operation, I see the next behaviour:
- When including a picture,
Information
dimension is 5 and incorporates oneFCA_Added
and 4FCA_Modified
. - When deleting a picture,
Information
dimension is 1 and incorporates aFCA_Removed
. - When including a number of pictures (for instance 2 pictures),
Information
dimension is 10 and incorporates oneFCA_Added
and 4FCA_Modified
for the primary picture and oneFCA_Added
and 4FCA_Modified
for the second picture.
Be aware: Typically including a picture will end in fewer FCA_Modified
. For instance, in one other PC, every picture leads to one FCA_Added
and two (relatively than 4) FCA_Modified
.
In any case, the problem stays that Information
is offering a lot of occasions for every operation. If I need to management this with a swap for instance, it means every picture will set off my UpdateDynamicMaterialArray
a number of occasions when just one name is required per file.
I hooked up a picture with the console output for a 2 file addition operation. enter picture description right here
To make clear the console output picture, Aspect motion 1 is a FCA_Added
and an Aspect motion 2 is an FCA_Modified
.
The perform I take advantage of to regulate the occasions:
/**
* Will set off when a change (addition, substitute, deletion) is carried out on ResourcesDirPath
* @param Information Array of kind FFileChangeData indicating the character of the change noticed
*/
void AMyController::OnProjectDirectoryChanged(const TArray<FFileChangeData>& Information) {
UE_LOG(LogTemp, Warning, TEXT("Information num: %d"), Information.Num());
for (FFileChangeData Aspect : Information) {
UE_LOG(LogTemp, Warning, TEXT("Aspect filename: %s"), *Aspect.Filename);
UE_LOG(LogTemp, Warning, TEXT("Aspect motion: %d"), Aspect.Motion);
swap (Aspect.Motion) {
case FFileChangeData::FCA_Added:
UpdateDynamicMaterialArray(&Aspect.Filename, FFileChangeData::FCA_Added);
//MyReferenceManager->MyHUD->AddTile();
break;
case FFileChangeData::FCA_Modified:
UpdateDynamicMaterialArray(&Aspect.Filename, FFileChangeData::FCA_Modified);
//MyReferenceManager->MyHUD->RefreshTile();
break;
case FFileChangeData::FCA_Removed:
UpdateDynamicMaterialArray(&Aspect.Filename, FFileChangeData::FCA_Removed);
//MyReferenceManager->MyHUD->RemoveTile();
break;
default: ;
}
}
}
FFileChangeData docs and EFileChangeAction didn’t assist.
Why does one operation end in a number of occasions of various kind? I think that is OS associated (I take advantage of Home windows) and that there’s not a lot I can do. Is that this true?
PD: This submit was initially created in stackoverflow and moved it right here as I used to be not conscious of the existance of this discussion board.
[ad_2]