I used code bellow to register settings class for my plugin, how can i get variables…
- User
I used code bellow to register settings class for my plugin, how can i get variables from this settings in runtime
ISettingsModule* SettingsModule = FModuleManager::GetModulePtr("Settings");
if (SettingsModule != nullptr) { SettingsModule->RegisterSettings("Project", "Plugins", "ReadyGamesNetwork", LOCTEXT("ReadyGamesNetworkSettingsName", "ReadyGamesNetwork"), LOCTEXT("ReadyGamesNetworkSettingsDescription", "Project settings for ReadyGamesNetwork plugin"), GetMutableDefault<UReadyGamesNetworkSettings>() ); } - Assistant
To access the variables from the settings class in runtime, you can use the following code:
#include "ReadyGamesNetworkSettings.h" UReadyGamesNetworkSettings* Settings = GetMutableDefault<UReadyGamesNetworkSettings>(); if (Settings != nullptr) { // Access the variables from the settings class int32 SomeVariable = Settings->SomeVariable; FString AnotherVariable = Settings->AnotherVariable; // ... }Replace
SomeVariableandAnotherVariablewith the actual variable names from yourUReadyGamesNetworkSettingsclass. - User
not this doesn't work, give me another example
- Assistant
I apologize for the confusion. Here's another example that should work:
#include "ISettingsModule.h" #include "ReadyGamesNetworkSettings.h" ISettingsModule* SettingsModule = FModuleManager::GetModulePtr<ISettingsModule>("Settings"); if (SettingsModule != nullptr) { const UReadyGamesNetworkSettings* Settings = GetDefault<UReadyGamesNetworkSettings>(); if (Settings != nullptr) { // Access the variables from the settings class int32 SomeVariable = Settings->SomeVariable; FString AnotherVariable = Settings->AnotherVariable; // ... } }Make sure to replace
UReadyGamesNetworkSettingswith the actual name of your settings class, and updateSomeVariableandAnotherVariablewith the variable names you want to access in runtime. - User
variables in Settings have incorrrect values, are you sure the code is working?
- Assistant
I apologize for the inconvenience. If the variables in your settings class have incorrect values, it's possible that the default values are not being set correctly.
In your
UReadyGamesNetworkSettingsclass, make sure you have set the default values for your variables usingUPROPERTYmacro. For example:UPROPERTY(config, EditAnywhere, Category = "MySettings") int32 SomeVariable = 0; UPROPERTY(config, EditAnywhere, Category = "MySettings") FString AnotherVariable = "Default value";If the default values are set correctly, you should be able to access them using the code I provided earlier.
If the values are still incorrect, please double-check your settings class and ensure that the default values are properly set.
- User
how cast TEnumAsByte where MyEnum is UEnum to c++ enum
- Assistant
To cast a
TEnumAsByte<MyEnum>whereMyEnumis aUEnumto a C++ enum, you can use theGetValue()function of theTEnumAsByteclass. Here's an example:UENUM(BlueprintType) enum class MyCppEnum : uint8 { Value1, Value2, Value3 }; UEnum* MyEnumPtr = Cast<UEnum>(StaticFindObject(UEnum::StaticClass(), ANY_PACKAGE, TEXT("MyEnumName"))); if (MyEnumPtr) { TEnumAsByte<MyEnum> MyEnumValue; MyEnumValue = SomeFunctionToGetEnumValue(); // Assuming you have a method to get the enum value MyCppEnum EnumValue = static_cast<MyCppEnum>(MyEnumValue.GetValue()); // Now you can use the C++ enum value }Replace
MyEnumNamewith the actual name of yourUEnumin theStaticFindObjectfunction. Make sure to updateMyCppEnumwith the name of your C++ enum.Note: Casting from a
UEnumto a C++ enum may result in data loss if the enum values don't match exactly. Make sure to handle such cases appropriately in your code. - User
how to use ISettingsModule without adding dependency to editor?
- Assistant
Unfortunately, the
ISettingsModuleinterface is part of the Unreal Editor module and cannot be used without adding a dependency on the editor. TheISettingsModuleis designed to be used within the editor context for managing project settings.If you need to use settings functionality in a non-editor context, you may need to implement your own custom settings management system or find an alternative approach that does not rely on the
ISettingsModule. This could involve using configuration files, data assets, or other means of storing and retrieving settings data.Alternatively, you can consider creating a separate module specifically for your plugin's runtime functionality that does not have a dependency on the editor module. This way, you can structure your code in a way that isolates any editor-related dependencies from the runtime portion of your plugin.
- User
but then how can i get variables from settings for my plugin at runtime
- Assistant
To access settings variables for your plugin at runtime, you can create a separate configuration file or data asset to store the settings data. Here's an example of how you can achieve this:
- Create a new configuration class or data asset to store the plugin settings. For example, create a new
UDataAssetsubclass calledUPluginSettingsDataAsset. Add properties to this class to represent the settings variables you want to access at runtime.
UCLASS() class YOURPLUGIN_API UPluginSettingsDataAsset : public UDataAsset { GENERATED_BODY() public: UPROPERTY(EditAnywhere, Category = "Plugin Settings") int32 SomeVariable; UPROPERTY(EditAnywhere, Category = "Plugin Settings") FString AnotherVariable; }; - Create a new configuration class or data asset to store the plugin settings. For example, create a new
- User
I WANT TO USE PLUGIN CONFIGURATION, NOT JUST ANY OTHER CONFIG
- Assistant
I apologize for the misunderstanding. If you want to use plugin-specific configuration for your settings, you can achieve that by using Unreal's
IPluginManagerandFPluginDescriptorto retrieve and access your plugin's configuration.Here's an example of how you can do this:
- Include the necessary headers in your source file:
#include "IPluginManager.h" #include "IPlugin.h"- Retrieve the plugin configuration, access the settings, and cast it to your specific settings class:
- User
how to fix this error
Severity Code Description Project File Line Suppression State Error LNK2019 unresolved external symbol "private: static class UClass * __cdecl UReadyGamesNetworkSettings::GetPrivateStaticClass(void)" (?GetPrivateStaticClass@UReadyGamesNetworkSettings@@CAPEAVUClass@@XZ) referenced in function "public: virtual void __cdecl FReadyGamesNetworkEditorModule::StartupModule(void)" (?StartupModule@FReadyGamesNetworkEditorModule@@UEAAXXZ) rgn_unreal D:\Work\ReadyMakers\rgn_unreal\Intermediate\ProjectFiles\Module.ReadyGamesNetworkEditor.cpp.obj 1
- Assistant
The error you're encountering suggests that the linker is unable to find the definition of the
UReadyGamesNetworkSettings::GetPrivateStaticClassfunction. This typically occurs when the implementation for that function is missing or not properly linked.To resolve this issue, you can follow these steps:
- Ensure that you have implemented the
GetPrivateStaticClassfunction in yourUReadyGamesNetworkSettingsclass. The implementation should look like this:
class UClass* UReadyGamesNetworkSettings::GetPrivateStaticClass() { return UReadyGamesNetworkSettings::StaticClass(); }-
Confirm that the source file containing the implementation of
GetPrivateStaticClassis part of the compilation process. If the definition is in a different source file than the one where you encountered the linker error, make sure that the source file is included in your build settings.
- Ensure that you have implemented the
- User
GetPrivateStaticClass member could be available in other module?
- Assistant
Yes, the
GetPrivateStaticClassmember function should be available in the same module as theUReadyGamesNetworkSettingsclass.If you're encountering the linker error and the
GetPrivateStaticClassfunction is defined in a different module, you need to ensure that the module containing theUReadyGamesNetworkSettingsclass has the required dependency on the module where the function is implemented.To resolve this error, you can follow these steps:
- In your plugin's
.Build.csfile, make sure to add a dependency to the module containing theGetPrivateStaticClassfunction. For example:
PublicDependencyModuleNames.AddRange(new string[] { "Core", "CoreUObject", "Engine", "YourOtherModule" });Replace
"YourOtherModule"with the name of the module where theGetPrivateStaticClassfunction is implemented.- Rebuild your project to ensure that the linkage between the modules is established correctly.
By adding the appropriate dependency in your plugin's build configuration, the function should be accessible from the module where the class is defined, resolving the linker error.
- In your plugin's
- User
I have settings class in module named ReadyGamesNetwork, i have another module named ReadyGamesNetwork where i want to use the class But when i try build i getting error: unresolved external symbol “private: static class UClass * __cdecl UReadyGamesNetworkSettings::GetPrivateStaticClass(void)” (?GetPrivateStaticClass@UReadyGamesNetworkSettings@@CAPEAVUClass@@XZ) referenced in function “public: virtual void __cdecl FReadyGamesNetworkEditorModule::StartupModule(void)”
- Assistant
To resolve the linker error, you need to ensure that the module where the
UReadyGamesNetworkSettingsclass is defined has a proper dependency on the module where theFReadyGamesNetworkEditorModuleclass is used.In your scenario, where the settings class is in the "ReadyGamesNetwork" module and the error is occurring in the "ReadyGamesNetworkEditor" module, you should follow these steps:
-
Open your plugin's
.Build.csfile (usually located in the "Source" folder of your plugin). -
In the
.Build.csfile of the "ReadyGamesNetworkEditor" module, add the dependency on the "ReadyGamesNetwork" module:
PrivateDependencyModuleNames.AddRange(new string[] { "ReadyGamesNetwork" });- Rebuild your project to ensure that the linkage between the modules is established correctly.
By adding the dependency on the "ReadyGamesNetwork" module in the "ReadyGamesNetworkEditor" module's
.Build.csfile, the linker error should be resolved, and theGetPrivateStaticClassfunction should be accessible. -
- User
i added dependency but it didn't helped
- Assistant
If adding the dependency in the
.Build.csfile of the "ReadyGamesNetworkEditor" module didn't resolve the linker error, there might be some other issues causing the problem. Here are a few potential solutions you can try:-
Verify that the dependencies are correctly specified:
a. In the
.Build.csfile of the "ReadyGamesNetworkEditor" module, make sure that the module name is listed correctly in the or . It should match the module name exactly, including proper capitalization.
-
- User
act as unreal engine developer. you faced to work with UPL. you have string variable named ProjectId and you want to put it in android manifest, but instead of variable name it puts variable name
<init> <setStringFromProperty result="ProjectId" ini="Game" section="/Script/ReadyGamesNetwork.ReadyGamesNetworkSettings" property="ProjectId" default=""/> <log text="$S(ProjectId)"/> <log text="ReadyGamesNetwork SDK Android Initialization"/> </init> <androidManifestUpdates> <loopElements tag="activity"> <setStringFromAttribute result="activityName" tag="$" name="android:name"/> <setBoolIsEqual result="bGameActivityUE4" arg1="$S(activityName)" arg2="com.epicgames.ue4.GameActivity"/> <setBoolIsEqual result="bGameActivityUE5" arg1="$S(activityName)" arg2="com.epicgames.unreal.GameActivity"/> <setBoolOr result="bGameActivity" arg1="$B(bGameActivityUE4)" arg2="$B(bGameActivityUE5)"/> <if condition="bGameActivity"> <true> <addElements tag="$"> <intent-filter> <action android:name="android.intent.action.VIEW" /> <category android:name="android.intent.category.DEFAULT" /> <category android:name="android.intent.category.BROWSABLE" /> <data android:scheme="$S(ProjectId)" /> </intent-filter> </addElements> </true> </if> </loopElements> </androidManifestUpdates> - Assistant
To dynamically insert the value of the
ProjectIdvariable into the Android manifest using Unreal's Unreal Property Language (UPL), you can make use of thereplaceStringWithPropertycommand like this:<setStringFromProperty result="ProjectId" ini="Game" section="/Script/ReadyGamesNetwork.ReadyGamesNetworkSettings" property="ProjectId" default=""/> <log text="$S(ProjectId)"/> <log text="ReadyGamesNetwork SDK Android Initialization"/>The
replaceStringWithPropertycommand allows you to retrieve the value of a property from an INI file and assign it to a variable. In this case, it retrieves the value of theProjectIdproperty from the[ReadyGamesNetworkSettings]section of the Game.ini file.Make sure that the property key
ProjectIdis properly defined in the[ReadyGamesNetworkSettings]section of your Game.ini file.After retrieving the
ProjectIdvalue, you can use it within the UPL script as needed. In the above example, it is logged using thelogcommand.
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.