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"

[INI] - UE4 not Writing Values

Hi, I Know i am asking a lot of questions recently but thats just because i just got into ue4 related c++ just a couple days ago.

what i want to know is why ue4 isnt writing my values. here is the code: CPP

 #include "MyPlayerController.h"
 #include "Runtime/Core/Public/Misc/ConfigCacheIni.h"
 
 FString Section = "Evo.user";
 
 void AMyPlayerController::SetConfig() {
     /* Format 
     (
         *Section,
         Key,
         Value,
         FileName
     );
     */
 
     // Writing To The Config File
     if (!GConfig) return;
 
     GConfig->SetBool(
         *Section,
         TEXT("b_isTrue"),
         TEXT("true"),
         GGameIni
     );
     GConfig->Flush(false, GGameIni);
 }
 void AMyPlayerController::GetConfig() {
     /*
     Format 
     (
     Section,
     Key,
     Value,
     FileName
     );
     */
 
     if (!GConfig) return;
 
     // Getting the Value
     GConfig->GetBool(
         *Section,
         TEXT("b_isTrue"),
         b_isTrue,
         GGameIni
         );
 }
 
 

.H

 #pragma once
 
 #include "CoreMinimal.h"
 #include "GameFramework/PlayerController.h"
 #include "MyPlayerController.generated.h"
 
 /**
  * 
  */
 UCLASS()
 class EVO_API AMyPlayerController : public APlayerController
 {
     GENERATED_BODY()
 
 public:
 
     UPROPERTY(EditAnywhere)
         bool b_isTrue;
 
     void GetConfig();
     void SetConfig();
 };
 

i Know im doing something wrong probably. By the way i followed Rama's Wiki for this.

can anyone help me out. also if i want to write into a file of my own (in saved/config/windows). how will i do that? like do i have a create a file with whatever name i want [a ini one]. for ex: User and in the code use it like so: GUserIni?

Product Version: UE 4.19
Tags:
more ▼

asked May 03 '18 at 01:16 PM in Using UE4

avatar image

SupDeity
343 3 6 15

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

3 answers: sort voted first

I Got it working. just used the code in the blueprint function library.

more ▼

answered May 08 '18 at 10:15 AM

avatar image

SupDeity
343 3 6 15

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

This is how I've made mine work.

 // Header file
 UCLASS(Blueprintable, Config=Input)
 class PROJECT_API UMyConfig : public UObject
 {
     GENERATED_BODY()
 
 public:
     UFUNCTION(BlueprintCallable)
     void SaveConfig();
     
 public:
     UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Settings", Config)
     int MyConfigVar;
 };

 // cpp file
 void UMyConfig::SaveConfig()
 {
     Super::SaveConfig();
 }
more ▼

answered May 03 '18 at 01:55 PM

avatar image

shh---
104 1 3 9

avatar image SupDeity May 03 '18 at 01:57 PM

i will check to see if this works

avatar image SupDeity May 03 '18 at 01:58 PM

by the way will this add the value in the ini file itself? and the " input " is the actual file name?

avatar image shh--- May 03 '18 at 02:29 PM

yes, this will add variable to input.ini

Actually I don't remember if it was a filename or a predefined constant, you may check, and if not,we will find out how to specify the file name.

avatar image SupDeity May 03 '18 at 02:37 PM

Nop doesnt work

avatar image shh--- May 03 '18 at 04:02 PM

Sorry, I don't remember everything (I've done it 2 months ago, took 3-4 days to figure out) and I can't look through it right now. I'll do it as soon as I get some free time, and report you back. Meanwhile someone may answer.

avatar image shh--- May 03 '18 at 04:05 PM

One more thing. In my example I've used an UObject derived class, which was referenced in UCustomGameUserSettings. In your example you are using an AActor derived class. I wonder if you have created an instance of that actor in your level?

avatar image SupDeity May 04 '18 at 11:30 AM

No, i did had the actor added in the scene and even tried creating a UObject class and doing it in there, still doesnt work

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

Well i have tried this isnt working for some reason :/

more ▼

answered May 03 '18 at 03:16 PM

avatar image

SupDeity
343 3 6 15

(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