x

Search in
Sort by:

Question Status:

Search help

  • Simple searches use one or more words. Separate the words with spaces (cat dog) to search cat,dog or both. Separate the words with plus signs (cat +dog) to search for items that may contain cat but must contain dog.
  • You can further refine your search on the search results page, where you can search by keywords, author, topic. These can be combined with each other. Examples
    • cat dog --matches anything with cat,dog or both
    • cat +dog --searches for cat +dog where dog is a mandatory term
    • cat -dog -- searches for cat excluding any result containing dog
    • [cats] —will restrict your search to results with topic named "cats"
    • [cats] [dogs] —will restrict your search to results with both topics, "cats", and "dogs"

Blueprint setted variable didn't set in C++

Hello everyone! So, about the problem. I has variable that declared in C++ code, below you can see it.

 UPROPERTY(EditAnywhere, BlueprintReadWrite)
         TArray<TSubclassOf<UUserWidget>> Slots;

Then, i set value in Blueprint Defaults or just set with Set node (Blueprint child of C++). After that i trying to call from Blueprint function that also decared in C++, and that function used variable above. But instead of using setted blueprint value, its used internal C++.

 // UFUNCTION(BlueprintCallable) void ... ;
        void UWidgetSwitcher::SetActiveWidget(int32 Index) {
              if (Index >= 0 && Index <= Slots.Num()) // Here Slots was read with C++ value, not setted in BP
      {      . . . .   }  }
 

How can i set that value in Blueprint and let that work in C++ with Blueprint value setted in? I dont want to create&transfer each call value from BP direct to function. Like that:

    void UWidgetSwitcher::SetActiveWidget(int32 Index, TArray<TSubclassOf<UUserWidget>> SSlots;) {
          if (Index >= 0 && Index <= SSlots.Num()){….}

Product Version: Not Selected
Tags:
more ▼

asked Jul 14 '18 at 08:09 PM in C++ Programming

avatar image

GloryOfNight
66 3 5 10

avatar image mcleary Jul 17 '18 at 08:47 AM

Can you post a screenshot of the Blueprint you are using? Maybe there is something wrong with that.

avatar image GloryOfNight Jul 20 '18 at 07:45 AM

I'm sorry for taking so long to answer. Here part of BP & C++ code. From other C++ file, but with same problem.

 void UMatch3Instance::SaveProgress() {
     USaver * SaveGameInstance = Cast<USaver>(UGameplayStatics::CreateSaveGameObject(USaver::StaticClass()));
     SaveGameInstance->PlayerBase = PlayerBase;
     SaveGameInstance->PlayerShip = PlayerShip;
     SaveGameInstance->PlayerStock = PlayerStock;
     UGameplayStatics::SaveGameToSlot(SaveGameInstance, TEXT("Slots"), 0);
 }
 
 void UMatch3Instance::InitializeProgress() {
      USaver * LoadGameInstance = Cast<USaver>(UGameplayStatics::LoadGameFromSlot(TEXT("Slots"), 0));
     if (LoadGameInstance != NULL) {
         PlayerBase = LoadGameInstance->PlayerBase;
         PlayerShip = LoadGameInstance->PlayerShip;
         PlayerStock = LoadGameInstance->PlayerStock;
     }
     else {
         UE_LOG(LogTemp, Warning, TEXT("FAILDED TO INITIALIZE PROGRESS"))
     }
 }


alt text

(comments are locked)
10|2000 characters needed characters left
Viewable by all users

1 answer: sort voted first

And looks like a found the problem. Problem was in C++ Variables where i tried to write in it.

If you want to write from Blueprint var to C++ you may sure ALL youre vars that working with it has UPROPERY() with or without BlueprintReadWrite.

more ▼

answered Jul 20 '18 at 08:07 AM

avatar image

GloryOfNight
66 3 5 10

avatar image mcleary Jul 20 '18 at 08:44 AM

That is true. Glad you found it.

(comments are locked)
10|2000 characters needed characters left
Viewable by all users
Your answer
toggle preview:

Up to 5 attachments (including images) can be used with a maximum of 5.2 MB each and 5.2 MB total.

Follow this question

Once you sign in you will be able to subscribe for any updates here

Answers to this question