You've already forked UnrealEngineUWP
mirror of
https://github.com/izzy2lost/UnrealEngineUWP.git
synced 2026-03-26 18:15:20 -07:00
The base class of any per platform settings. The pattern for using these is as follows.
Step 1) Subclass UPlatformSettings, UMyPerPlatformSettings : public UPlatformSettings.
Step 2) For your system should already have a UDeveloperSettings that you created so that
users can customize other properties for your system in the project. On that class
you need to create a property of type FPerPlatformSettings, e.g.
UPROPERTY(EditAnywhere, Category=Platform)
FPerPlatformSettings PlatformOptions
Step 3) In your UDeveloperSettings subclasses construct, there should be a line like this,
PlatformOptions.Settings = UPlatformSettings::GetAllPlatformSettings<UMyPerPlatformSettings>();
This will actually ensure that you initialize the settings exposed in the editor to whatever
the current platform configuration is for them.
Step 4) Nothing else needed. In your system code, you will just call
UMyPerPlatformSettings* MySettings = UPlatformSettings::GetSettingsForPlatform<UMyPerPlatformSettings>()
that will get you the current settings for the active platform, or the simulated platform in the editor.
Josh.Adams, Michael.Noland, Daren.Cheng
[FYI] Josh.Adams, Michael.Noland, Daren.Cheng
#ROBOMERGE-SOURCE: CL 16603959 in //UE5/Main/...
#ROBOMERGE-BOT: STARSHIP (Main -> Release-Engine-Test) (v828-16531559)
[CL 16603966 by nick darnell in ue5-release-engine-test branch]
72 lines
2.9 KiB
C++
72 lines
2.9 KiB
C++
// Copyright Epic Games, Inc. All Rights Reserved.
|
|
|
|
#include "PerPlatformSettingsCustomization.h"
|
|
#include "DetailWidgetRow.h"
|
|
#include "Widgets/SBoxPanel.h"
|
|
#include "Widgets/Images/SImage.h"
|
|
#include "EditorStyleSet.h"
|
|
#include "Engine/PlatformSettings.h"
|
|
#include "IDetailGroup.h"
|
|
#include "IDetailChildrenBuilder.h"
|
|
|
|
TSharedRef<IPropertyTypeCustomization> FPerPlatformSettingsCustomization::MakeInstance()
|
|
{
|
|
return MakeShareable(new FPerPlatformSettingsCustomization);
|
|
}
|
|
|
|
FPerPlatformSettingsCustomization::FPerPlatformSettingsCustomization()
|
|
{
|
|
}
|
|
|
|
void FPerPlatformSettingsCustomization::CustomizeHeader(TSharedRef<IPropertyHandle> PropertyHandle, FDetailWidgetRow& HeaderRow, IPropertyTypeCustomizationUtils& CustomizationUtils)
|
|
{
|
|
HeaderRow
|
|
.WholeRowContent()
|
|
.MaxDesiredWidth(TOptional<float>())
|
|
.MaxDesiredWidth(TOptional<float>())
|
|
[
|
|
PropertyHandle->CreatePropertyNameWidget()
|
|
];
|
|
}
|
|
|
|
void FPerPlatformSettingsCustomization::CustomizeChildren(TSharedRef<IPropertyHandle> PropertyHandle, IDetailChildrenBuilder& ChildBuilder, IPropertyTypeCustomizationUtils& CustomizationUtils)
|
|
{
|
|
TSharedPtr<IPropertyHandle> SettingsProperty = PropertyHandle->GetChildHandle(GET_MEMBER_NAME_CHECKED(FPerPlatformSettings, Settings));
|
|
TSharedPtr<IPropertyHandleArray> SettingsPropertyArray = SettingsProperty->AsArray();
|
|
|
|
uint32 NumSettings;
|
|
SettingsPropertyArray->GetNumElements(NumSettings);
|
|
for (uint32 Index = 0; Index < NumSettings; ++Index)
|
|
{
|
|
TSharedPtr<IPropertyHandle> PlatformSettingsProperty = SettingsPropertyArray->GetElement(Index);
|
|
if (PlatformSettingsProperty->IsValidHandle())
|
|
{
|
|
UObject* PlatformSettingsObject;
|
|
FPropertyAccess::Result Result = PlatformSettingsProperty->GetValue(PlatformSettingsObject);
|
|
if (Result == FPropertyAccess::Success)
|
|
{
|
|
if (UPlatformSettings* PlatformSettings = Cast<UPlatformSettings>(PlatformSettingsObject))
|
|
{
|
|
FAddPropertyParams Params = FAddPropertyParams()
|
|
.UniqueId(PlatformSettings->GetFName())
|
|
.AllowChildren(true)
|
|
.CreateCategoryNodes(false);
|
|
|
|
IDetailGroup& PlatformGroup = ChildBuilder.AddGroup(PlatformSettings->GetFName(), FText::FromString(PlatformSettings->GetPlatformIniName()));
|
|
|
|
TSharedPtr<IPropertyHandle> PlatformSettingsPropertyArrayEntry = PlatformSettingsProperty->GetChildHandle(0);
|
|
|
|
//FDetailWidgetRow& PlatformGroup = ChildBuilder.AddCustomRow(FText::FromString(PlatformSettings->GetPlatformIniName()));
|
|
|
|
uint32 PlatformPropertiesChildHandleCount;
|
|
PlatformSettingsPropertyArrayEntry->GetNumChildren(PlatformPropertiesChildHandleCount);
|
|
for (uint32 PlatformPropertyIndex = 0; PlatformPropertyIndex < PlatformPropertiesChildHandleCount; PlatformPropertyIndex++)
|
|
{
|
|
TSharedPtr<IPropertyHandle> PlatformPropertyHandle = PlatformSettingsPropertyArrayEntry->GetChildHandle(PlatformPropertyIndex);
|
|
PlatformGroup.AddPropertyRow(PlatformPropertyHandle.ToSharedRef());
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
} |