2026-03-08 22:17:14 -04:00
|
|
|
#pragma once
|
|
|
|
|
|
|
|
|
|
#include "CoreMinimal.h"
|
2026-03-18 10:17:58 -04:00
|
|
|
#include "WingServer.h"
|
|
|
|
|
#include "WingHandler.h"
|
|
|
|
|
#include "WingUtils.h"
|
2026-03-08 22:17:14 -04:00
|
|
|
#include "Materials/MaterialFunction.h"
|
|
|
|
|
#include "Factories/MaterialFunctionFactoryNew.h"
|
2026-03-18 10:17:58 -04:00
|
|
|
#include "WingPackageMaker.h"
|
2026-03-12 00:44:17 -04:00
|
|
|
#include "MaterialFunction_Create.generated.h"
|
2026-03-08 22:17:14 -04:00
|
|
|
|
|
|
|
|
|
|
|
|
|
// ---------------------------------------------------------------------------
|
|
|
|
|
// ---------------------------------------------------------------------------
|
|
|
|
|
// ---------------------------------------------------------------------------
|
|
|
|
|
|
2026-03-15 19:32:09 -04:00
|
|
|
UCLASS()
|
2026-03-18 10:17:58 -04:00
|
|
|
class UWing_MaterialFunction_Create : public UObject, public IWingHandler
|
2026-03-08 22:17:14 -04:00
|
|
|
{
|
|
|
|
|
GENERATED_BODY()
|
|
|
|
|
|
|
|
|
|
public:
|
2026-03-12 18:31:55 -04:00
|
|
|
UPROPERTY(meta=(Description="Full asset path for the new material function (e.g. '/Game/Materials/MF_MyFunc')"))
|
|
|
|
|
FString AssetPath;
|
2026-03-08 22:17:14 -04:00
|
|
|
|
|
|
|
|
UPROPERTY(meta=(Optional, Description="Description for the material function"))
|
|
|
|
|
FString Description;
|
|
|
|
|
|
|
|
|
|
virtual FString GetDescription() const override
|
|
|
|
|
{
|
|
|
|
|
return TEXT("Create a new UMaterialFunction asset with an optional description.");
|
|
|
|
|
}
|
|
|
|
|
|
2026-03-13 23:41:59 -04:00
|
|
|
virtual void Handle() override
|
2026-03-08 22:17:14 -04:00
|
|
|
{
|
2026-03-18 10:17:58 -04:00
|
|
|
WingPackageMaker Maker(AssetPath);
|
2026-03-12 18:31:55 -04:00
|
|
|
if (!Maker.Ok()) return;
|
2026-03-08 22:17:14 -04:00
|
|
|
|
2026-03-10 07:17:42 -04:00
|
|
|
// Create via IAssetTools + factory.
|
2026-03-12 18:31:55 -04:00
|
|
|
UMaterialFunction* MF = Maker.CreateAsset<UMaterialFunction, UMaterialFunctionFactoryNew>();
|
|
|
|
|
if (!MF) return;
|
2026-03-08 22:17:14 -04:00
|
|
|
|
2026-03-10 07:17:42 -04:00
|
|
|
// Set optional description.
|
2026-03-08 22:17:14 -04:00
|
|
|
if (!Description.IsEmpty())
|
|
|
|
|
MF->Description = Description;
|
|
|
|
|
|
2026-03-18 10:17:58 -04:00
|
|
|
UWingServer::Printf(TEXT("Created %s\n"), *MF->GetPathName());
|
2026-03-08 22:17:14 -04:00
|
|
|
}
|
|
|
|
|
};
|