archive: add 5 repo prompt(s) [skip ci]

This commit is contained in:
github-actions[bot]
2026-02-24 13:17:06 +00:00
parent 7ba44727a6
commit 0a748161ba
7 changed files with 586185 additions and 0 deletions
File diff suppressed because it is too large Load Diff
+718
View File
@@ -0,0 +1,718 @@
Project Path: arc_JanKXSKI_AssetTutorialPlugin_m0zswh3g
Source Tree:
```txt
arc_JanKXSKI_AssetTutorialPlugin_m0zswh3g
├── AssetTutorialPlugin.uplugin
├── LICENSE
├── README.md
├── Resources
│ └── Icon128.png
└── Source
├── AssetTutorialPlugin
│ ├── AssetTutorialPlugin.Build.cs
│ ├── Private
│ │ ├── AssetTutorialPlugin.cpp
│ │ └── NormalDistribution.cpp
│ └── Public
│ ├── AssetTutorialPlugin.h
│ └── NormalDistribution.h
└── AssetTutorialPluginEditor
├── AssetTutorialPluginEditor.Build.cs
├── Private
│ ├── AssetTutorialPluginEditor.cpp
│ ├── NormalDistributionActions.cpp
│ ├── NormalDistributionEditorToolkit.cpp
│ ├── NormalDistributionFactory.cpp
│ └── SNormalDistributionWidget.cpp
└── Public
├── AssetTutorialPluginEditor.h
├── NormalDistributionActions.h
├── NormalDistributionEditorToolkit.h
├── NormalDistributionFactory.h
└── SNormalDistributionWidget.h
```
`AssetTutorialPlugin.uplugin`:
```uplugin
{
"FileVersion": 3,
"Version": 1,
"VersionName": "1.0",
"FriendlyName": "AssetTutorialPlugin",
"Description": "",
"Category": "Other",
"CreatedBy": "",
"CreatedByURL": "",
"DocsURL": "",
"MarketplaceURL": "",
"SupportURL": "",
"CanContainContent": true,
"IsBetaVersion": false,
"IsExperimentalVersion": false,
"Installed": false,
"Modules": [
{
"Name": "AssetTutorialPlugin",
"Type": "Runtime",
"LoadingPhase": "Default"
},
{
"Name": "AssetTutorialPluginEditor",
"Type": "Editor",
"LoadingPhase": "Default"
}
]
}
```
`LICENSE`:
```
MIT License
Copyright (c) 2022 JanKXSKI
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
```
`README.md`:
```md
This is the source code for the "Creating A Custom Asset Type With Its Own Editor In C++" tutorial over at https://dev.epicgames.com/community/learning/tutorials/vyKB/unreal-engine-creating-a-custom-asset-type-with-its-own-editor-in-c.
```
`Source/AssetTutorialPlugin/AssetTutorialPlugin.Build.cs`:
```cs
// Copyright Epic Games, Inc. All Rights Reserved.
using UnrealBuildTool;
public class AssetTutorialPlugin : ModuleRules
{
public AssetTutorialPlugin(ReadOnlyTargetRules Target) : base(Target)
{
PCHUsage = ModuleRules.PCHUsageMode.UseExplicitOrSharedPCHs;
PublicIncludePaths.AddRange(
new string[] {
// ... add public include paths required here ...
}
);
PrivateIncludePaths.AddRange(
new string[] {
// ... add other private include paths required here ...
}
);
PublicDependencyModuleNames.AddRange(
new string[]
{
"Core",
// ... add other public dependencies that you statically link with here ...
}
);
PrivateDependencyModuleNames.AddRange(
new string[]
{
"CoreUObject",
"Engine",
"Slate",
"SlateCore",
// ... add private dependencies that you statically link with here ...
}
);
DynamicallyLoadedModuleNames.AddRange(
new string[]
{
// ... add any modules that your module loads dynamically here ...
}
);
}
}
```
`Source/AssetTutorialPlugin/Private/AssetTutorialPlugin.cpp`:
```cpp
// Copyright Epic Games, Inc. All Rights Reserved.
#include "AssetTutorialPlugin.h"
#define LOCTEXT_NAMESPACE "FAssetTutorialPluginModule"
void FAssetTutorialPluginModule::StartupModule()
{
// This code will execute after your module is loaded into memory; the exact timing is specified in the .uplugin file per-module
}
void FAssetTutorialPluginModule::ShutdownModule()
{
// This function may be called during shutdown to clean up your module. For modules that support dynamic reloading,
// we call this function before unloading the module.
}
#undef LOCTEXT_NAMESPACE
IMPLEMENT_MODULE(FAssetTutorialPluginModule, AssetTutorialPlugin)
```
`Source/AssetTutorialPlugin/Private/NormalDistribution.cpp`:
```cpp
#include "NormalDistribution.h"
UNormalDistribution::UNormalDistribution()
: Mean(0.5f)
, StandardDeviation(0.2f)
{}
float UNormalDistribution::DrawSample()
{
return std::normal_distribution<>(Mean, StandardDeviation)(RandomNumberGenerator);
}
void UNormalDistribution::LogSample()
{
UE_LOG(LogTemp, Log, TEXT("%f"), DrawSample())
}
```
`Source/AssetTutorialPlugin/Public/AssetTutorialPlugin.h`:
```h
// Copyright Epic Games, Inc. All Rights Reserved.
#pragma once
#include "CoreMinimal.h"
#include "Modules/ModuleManager.h"
class FAssetTutorialPluginModule : public IModuleInterface
{
public:
/** IModuleInterface implementation */
virtual void StartupModule() override;
virtual void ShutdownModule() override;
};
```
`Source/AssetTutorialPlugin/Public/NormalDistribution.h`:
```h
#pragma once
#include "CoreMinimal.h"
#include "UObject/NoExportTypes.h"
#include <random>
#include "NormalDistribution.generated.h"
UCLASS(BlueprintType)
class ASSETTUTORIALPLUGIN_API UNormalDistribution : public UObject
{
GENERATED_BODY()
public:
UNormalDistribution();
UPROPERTY(EditAnywhere)
float Mean;
UPROPERTY(EditAnywhere)
float StandardDeviation;
UFUNCTION(BlueprintCallable)
float DrawSample();
UFUNCTION(CallInEditor)
void LogSample();
private:
std::mt19937 RandomNumberGenerator;
};
```
`Source/AssetTutorialPluginEditor/AssetTutorialPluginEditor.Build.cs`:
```cs
// Copyright Epic Games, Inc. All Rights Reserved.
using UnrealBuildTool;
public class AssetTutorialPluginEditor : ModuleRules
{
public AssetTutorialPluginEditor(ReadOnlyTargetRules Target) : base(Target)
{
PCHUsage = ModuleRules.PCHUsageMode.UseExplicitOrSharedPCHs;
PublicIncludePaths.AddRange(
new string[] {
// ... add public include paths required here ...
}
);
PrivateIncludePaths.AddRange(
new string[] {
// ... add other private include paths required here ...
}
);
PublicDependencyModuleNames.AddRange(
new string[]
{
"Core",
// ... add other public dependencies that you statically link with here ...
}
);
PrivateDependencyModuleNames.AddRange(
new string[]
{
"CoreUObject",
"Engine",
"Slate",
"SlateCore",
"AssetTutorialPlugin",
"UnrealEd"
// ... add private dependencies that you statically link with here ...
}
);
DynamicallyLoadedModuleNames.AddRange(
new string[]
{
// ... add any modules that your module loads dynamically here ...
}
);
}
}
```
`Source/AssetTutorialPluginEditor/Private/AssetTutorialPluginEditor.cpp`:
```cpp
#include "AssetTutorialPluginEditor.h"
void FAssetTutorialPluginEditorModule::StartupModule()
{
NormalDistributionAssetTypeActions = MakeShared<FNormalDistributionAssetTypeActions>();
FAssetToolsModule::GetModule().Get().RegisterAssetTypeActions(NormalDistributionAssetTypeActions.ToSharedRef());
}
void FAssetTutorialPluginEditorModule::ShutdownModule()
{
if (!FModuleManager::Get().IsModuleLoaded("AssetTools")) return;
FAssetToolsModule::GetModule().Get().UnregisterAssetTypeActions(NormalDistributionAssetTypeActions.ToSharedRef());
}
IMPLEMENT_MODULE(FAssetTutorialPluginEditorModule, AssetTutorialPluginEditor)
```
`Source/AssetTutorialPluginEditor/Private/NormalDistributionActions.cpp`:
```cpp
#include "NormalDistributionActions.h"
#include "NormalDistribution.h"
#include "NormalDistributionEditorToolkit.h"
UClass* FNormalDistributionAssetTypeActions::GetSupportedClass() const
{
return UNormalDistribution::StaticClass();
}
FText FNormalDistributionAssetTypeActions::GetName() const
{
return INVTEXT("Normal Distribution");
}
FColor FNormalDistributionAssetTypeActions::GetTypeColor() const
{
return FColor::Cyan;
}
uint32 FNormalDistributionAssetTypeActions::GetCategories()
{
return EAssetTypeCategories::Misc;
}
void FNormalDistributionAssetTypeActions::OpenAssetEditor(const TArray<UObject*>& InObjects, TSharedPtr<class IToolkitHost> EditWithinLevelEditor)
{
MakeShared<FNormalDistributionEditorToolkit>()->InitEditor(InObjects);
}
```
`Source/AssetTutorialPluginEditor/Private/NormalDistributionEditorToolkit.cpp`:
```cpp
#include "NormalDistributionEditorToolkit.h"
#include "Widgets/Docking/SDockTab.h"
#include "SNormalDistributionWidget.h"
#include "Modules/ModuleManager.h"
void FNormalDistributionEditorToolkit::InitEditor(const TArray<UObject*>& InObjects)
{
NormalDistribution = Cast<UNormalDistribution>(InObjects[0]);
const TSharedRef<FTabManager::FLayout> Layout = FTabManager::NewLayout("NormalDistributionEditorLayout")
->AddArea
(
FTabManager::NewPrimaryArea()->SetOrientation(Orient_Vertical)
->Split
(
FTabManager::NewSplitter()
->SetSizeCoefficient(0.6f)
->SetOrientation(Orient_Horizontal)
->Split
(
FTabManager::NewStack()
->SetSizeCoefficient(0.8f)
->AddTab("NormalDistributionPDFTab", ETabState::OpenedTab)
)
->Split
(
FTabManager::NewStack()
->SetSizeCoefficient(0.2f)
->AddTab("NormalDistributionDetailsTab", ETabState::OpenedTab)
)
)
->Split
(
FTabManager::NewStack()
->SetSizeCoefficient(0.4f)
->AddTab("OutputLog", ETabState::OpenedTab)
)
);
FAssetEditorToolkit::InitAssetEditor(EToolkitMode::Standalone, {}, "NormalDistributionEditor", Layout, true, true, InObjects);
}
void FNormalDistributionEditorToolkit::RegisterTabSpawners(const TSharedRef<class FTabManager>& InTabManager)
{
FAssetEditorToolkit::RegisterTabSpawners(InTabManager);
WorkspaceMenuCategory = InTabManager->AddLocalWorkspaceMenuCategory(INVTEXT("Normal Distribution Editor"));
InTabManager->RegisterTabSpawner("NormalDistributionPDFTab", FOnSpawnTab::CreateLambda([=](const FSpawnTabArgs&)
{
return SNew(SDockTab)
[
SNew(SNormalDistributionWidget)
.Mean(this, &FNormalDistributionEditorToolkit::GetMean)
.StandardDeviation(this, &FNormalDistributionEditorToolkit::GetStandardDeviation)
.OnMeanChanged(this, &FNormalDistributionEditorToolkit::SetMean)
.OnStandardDeviationChanged(this, &FNormalDistributionEditorToolkit::SetStandardDeviation)
];
}))
.SetDisplayName(INVTEXT("PDF"))
.SetGroup(WorkspaceMenuCategory.ToSharedRef());
FPropertyEditorModule& PropertyEditorModule = FModuleManager::GetModuleChecked<FPropertyEditorModule>("PropertyEditor");
FDetailsViewArgs DetailsViewArgs;
DetailsViewArgs.NameAreaSettings = FDetailsViewArgs::HideNameArea;
TSharedRef<IDetailsView> DetailsView = PropertyEditorModule.CreateDetailView(DetailsViewArgs);
DetailsView->SetObjects(TArray<UObject*>{ NormalDistribution });
InTabManager->RegisterTabSpawner("NormalDistributionDetailsTab", FOnSpawnTab::CreateLambda([=](const FSpawnTabArgs&)
{
return SNew(SDockTab)
[
DetailsView
];
}))
.SetDisplayName(INVTEXT("Details"))
.SetGroup(WorkspaceMenuCategory.ToSharedRef());
}
void FNormalDistributionEditorToolkit::UnregisterTabSpawners(const TSharedRef<class FTabManager>& InTabManager)
{
FAssetEditorToolkit::UnregisterTabSpawners(InTabManager);
InTabManager->UnregisterTabSpawner("NormalDistributionPDFTab");
InTabManager->UnregisterTabSpawner("NormalDistributionDetailsTab");
}
float FNormalDistributionEditorToolkit::GetMean() const
{
return NormalDistribution->Mean;
}
float FNormalDistributionEditorToolkit::GetStandardDeviation() const
{
return NormalDistribution->StandardDeviation;
}
void FNormalDistributionEditorToolkit::SetMean(float Mean)
{
NormalDistribution->Modify();
NormalDistribution->Mean = Mean;
}
void FNormalDistributionEditorToolkit::SetStandardDeviation(float StandardDeviation)
{
NormalDistribution->Modify();
NormalDistribution->StandardDeviation = StandardDeviation;
}
```
`Source/AssetTutorialPluginEditor/Private/NormalDistributionFactory.cpp`:
```cpp
#include "NormalDistributionFactory.h"
#include "NormalDistribution.h"
UNormalDistributionFactory::UNormalDistributionFactory()
{
SupportedClass = UNormalDistribution::StaticClass();
bCreateNew = true;
}
UObject* UNormalDistributionFactory::FactoryCreateNew(UClass* Class, UObject* InParent, FName Name, EObjectFlags Flags, UObject* Context, FFeedbackContext* Warn)
{
return NewObject<UNormalDistribution>(InParent, Class, Name, Flags, Context);
}
```
`Source/AssetTutorialPluginEditor/Private/SNormalDistributionWidget.cpp`:
```cpp
#include "SNormalDistributionWidget.h"
#include "Editor.h"
void SNormalDistributionWidget::Construct(const FArguments& InArgs)
{
Mean = InArgs._Mean;
StandardDeviation = InArgs._StandardDeviation;
OnMeanChanged = InArgs._OnMeanChanged;
OnStandardDeviationChanged = InArgs._OnStandardDeviationChanged;
}
int32 SNormalDistributionWidget::OnPaint(const FPaintArgs& Args, const FGeometry& AllottedGeometry, const FSlateRect& MyCullingRect, FSlateWindowElementList& OutDrawElements, int32 LayerId, const FWidgetStyle& InWidgetStyle, bool bParentEnabled) const
{
const int32 NumPoints = 512;
TArray<FVector2D> Points;
Points.Reserve(NumPoints);
const FTransform2D PointsTransform = GetPointsTransform(AllottedGeometry);
for (int32 PointIndex = 0; PointIndex < NumPoints; ++PointIndex)
{
const float X = PointIndex / (NumPoints - 1.0);
const float D = (X - Mean.Get()) / StandardDeviation.Get();
const float Y = FMath::Exp(-0.5f * D * D);
Points.Add(PointsTransform.TransformPoint(FVector2D(X, Y)));
}
FSlateDrawElement::MakeLines(OutDrawElements, LayerId, AllottedGeometry.ToPaintGeometry(), Points);
return LayerId;
}
FVector2D SNormalDistributionWidget::ComputeDesiredSize(float) const
{
return FVector2D(200.0, 200.0);
}
FReply SNormalDistributionWidget::OnMouseButtonDown(const FGeometry& AllottedGeometry, const FPointerEvent& MouseEvent)
{
if (GEditor && GEditor->CanTransact() && ensure(!GIsTransacting))
GEditor->BeginTransaction(TEXT(""), INVTEXT("Edit Normal Distribution"), nullptr);
return FReply::Handled().CaptureMouse(SharedThis(this));
}
FReply SNormalDistributionWidget::OnMouseButtonUp(const FGeometry& AllottedGeometry, const FPointerEvent& MouseEvent)
{
if (GEditor) GEditor->EndTransaction();
return FReply::Handled().ReleaseMouseCapture();
}
FReply SNormalDistributionWidget::OnMouseMove(const FGeometry& AllottedGeometry, const FPointerEvent& MouseEvent)
{
if (!HasMouseCapture()) return FReply::Unhandled();
const FTransform2D PointsTransform = GetPointsTransform(AllottedGeometry);
const FVector2D LocalPosition = AllottedGeometry.AbsoluteToLocal(MouseEvent.GetScreenSpacePosition());
const FVector2D NormalizedPosition = PointsTransform.Inverse().TransformPoint(LocalPosition);
if (OnMeanChanged.IsBound())
OnMeanChanged.Execute(NormalizedPosition.X);
if (OnStandardDeviationChanged.IsBound())
OnStandardDeviationChanged.Execute(FMath::Max(0.025f, FMath::Lerp(0.025f, 0.25f, NormalizedPosition.Y)));
return FReply::Handled();
}
FTransform2D SNormalDistributionWidget::GetPointsTransform(const FGeometry& AllottedGeometry) const
{
const double Margin = 0.05 * AllottedGeometry.GetLocalSize().GetMin();
const FScale2D Scale((AllottedGeometry.GetLocalSize() - 2.0 * Margin) * FVector2D(1.0, -1.0));
const FVector2D Translation(Margin, AllottedGeometry.GetLocalSize().Y - Margin);
return FTransform2D(Scale, Translation);
}
```
`Source/AssetTutorialPluginEditor/Public/AssetTutorialPluginEditor.h`:
```h
#pragma once
#include "CoreMinimal.h"
#include "Modules/ModuleManager.h"
#include "NormalDistributionActions.h"
class FAssetTutorialPluginEditorModule : public IModuleInterface
{
public:
void StartupModule() override;
void ShutdownModule() override;
private:
TSharedPtr<FNormalDistributionAssetTypeActions> NormalDistributionAssetTypeActions;
};
```
`Source/AssetTutorialPluginEditor/Public/NormalDistributionActions.h`:
```h
#pragma once
#include "CoreMinimal.h"
#include "AssetTypeActions_Base.h"
class FNormalDistributionAssetTypeActions : public FAssetTypeActions_Base
{
public:
UClass* GetSupportedClass() const override;
FText GetName() const override;
FColor GetTypeColor() const override;
uint32 GetCategories() override;
void OpenAssetEditor(const TArray<UObject*>& InObjects, TSharedPtr<class IToolkitHost> EditWithinLevelEditor) override;
};
```
`Source/AssetTutorialPluginEditor/Public/NormalDistributionEditorToolkit.h`:
```h
#pragma once
#include "CoreMinimal.h"
#include "NormalDistribution.h"
#include "Toolkits/AssetEditorToolkit.h"
class FNormalDistributionEditorToolkit : public FAssetEditorToolkit
{
public:
void InitEditor(const TArray<UObject*>& InObjects);
void RegisterTabSpawners(const TSharedRef<class FTabManager>& TabManager) override;
void UnregisterTabSpawners(const TSharedRef<class FTabManager>& TabManager) override;
FName GetToolkitFName() const override { return "NormalDistributionEditor"; }
FText GetBaseToolkitName() const override { return INVTEXT("Normal Distribution Editor"); }
FString GetWorldCentricTabPrefix() const override { return "Normal Distribution "; }
FLinearColor GetWorldCentricTabColorScale() const override { return {}; }
float GetMean() const;
float GetStandardDeviation() const;
void SetMean(float Mean);
void SetStandardDeviation(float StandardDeviation);
private:
UNormalDistribution* NormalDistribution;
};
```
`Source/AssetTutorialPluginEditor/Public/NormalDistributionFactory.h`:
```h
#pragma once
#include "CoreMinimal.h"
#include "Factories/Factory.h"
#include "NormalDistributionFactory.generated.h"
UCLASS()
class UNormalDistributionFactory : public UFactory
{
GENERATED_BODY()
public:
UNormalDistributionFactory();
UObject* FactoryCreateNew(UClass* Class, UObject* InParent, FName Name, EObjectFlags Flags, UObject* Context, FFeedbackContext* Warn);
};
```
`Source/AssetTutorialPluginEditor/Public/SNormalDistributionWidget.h`:
```h
#pragma once
#include "CoreMinimal.h"
#include "Widgets/SLeafWidget.h"
DECLARE_DELEGATE_OneParam(FOnMeanChanged, float /*NewMean*/)
DECLARE_DELEGATE_OneParam(FOnStandardDeviationChanged, float /*NewStandardDeviation*/)
class SNormalDistributionWidget : public SLeafWidget
{
public:
SLATE_BEGIN_ARGS(SNormalDistributionWidget)
: _Mean(0.5f)
, _StandardDeviation(0.2f)
{}
SLATE_ATTRIBUTE(float, Mean)
SLATE_ATTRIBUTE(float, StandardDeviation)
SLATE_EVENT(FOnMeanChanged, OnMeanChanged)
SLATE_EVENT(FOnStandardDeviationChanged, OnStandardDeviationChanged)
SLATE_END_ARGS()
void Construct(const FArguments& InArgs);
int32 OnPaint(const FPaintArgs& Args, const FGeometry& AllottedGeometry, const FSlateRect& MyCullingRect, FSlateWindowElementList& OutDrawElements, int32 LayerId, const FWidgetStyle& InWidgetStyle, bool bParentEnabled) const override;
FVector2D ComputeDesiredSize(float) const override;
FReply OnMouseButtonDown(const FGeometry& AllottedGeometry, const FPointerEvent& MouseEvent) override;
FReply OnMouseButtonUp(const FGeometry& AllottedGeometry, const FPointerEvent& MouseEvent) override;
FReply OnMouseMove(const FGeometry& AllottedGeometry, const FPointerEvent& MouseEvent) override;
private:
TAttribute<float> Mean;
TAttribute<float> StandardDeviation;
FOnMeanChanged OnMeanChanged;
FOnStandardDeviationChanged OnStandardDeviationChanged;
FTransform2D GetPointsTransform(const FGeometry& AllottedGeometry) const;
};
```
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff