Skip to content

Instantly share code, notes, and snippets.

@kirby561
kirby561 / CustomAsset.h
Created May 13, 2024 23:25
Custom Asset Editors in Unreal Engine 5 - This is the source code from the Custom Asset Editor Youtube video.
#pragma once
#include "CoreMinimal.h"
#include "CustomAsset.generated.h"
UCLASS(BlueprintType)
class CUSTOMASSETEDITORRUNTIME_API UCustomAsset : public UObject {
GENERATED_BODY()
public:
@kirby561
kirby561 / AssignVerticesToBones.py
Last active April 5, 2024 15:22
Python Blender Scripts for Splined Mesh Youtube Video
#
# Replace vertex group with all vertices in a range
#
import bpy
import bmesh
def MakeBoneName(index):
if index < 10:
return "Bone.00" + str(index)
elif index < 100:
@kirby561
kirby561 / BpPoseableMeshComponent.cpp
Created April 4, 2024 16:51
UBpPoseableMeshComponent C++ code for the Splined Road Youtube Video ( Also see https://www.youtube.com/watch?v=399k219oxi8 )
#include "BpPoseableMeshComponent.h"
UBpPoseableMeshComponent::UBpPoseableMeshComponent(const FObjectInitializer& objInitializer) : Super(objInitializer) {
}
void UBpPoseableMeshComponent::SetBoneLocalTransformByName(const FName& boneName, const FTransform& transform) {
if (!GetSkinnedAsset() || !RequiredBones.IsValid()) {
return;
}
@kirby561
kirby561 / TestClasses.cpp
Created February 11, 2024 21:38
Gist for a Youtube video "How to declare and use Delegates in Unreal Engine 5"
#include "TestClasses.h"
DEFINE_LOG_CATEGORY_STATIC(TestClassSub, Log, All);
void UTestClass::InitDelegates() {
_someDelegate1.BindStatic(&UTestClass::SomeStaticDelegateFunction);
int hey = 5;
_someDelegate2.BindLambda([hey](FString param) {
UE_LOG(TestClassSub, Warning, TEXT("Lambda: %s, %d"), *param, hey);
@kirby561
kirby561 / SomeObject.cpp
Created January 19, 2024 02:45
The source files for the UE5 Blueprint/C++ interop tutorial at https://www.youtube.com/watch?v=ejGfHtgGOOI
#include "SomeObject.h"
DEFINE_LOG_CATEGORY_STATIC(SomeObjectSub, Log, All);
void USomeObject::HelloFromABlueprint(int someArgument) {
UE_LOG(SomeObjectSub, Warning, TEXT("Hello called from a blueprint down to C++! With arguemnt: %d"), someArgument);
CallBlueprintFromCpp(someArgument);
CallBlueprintNativeEvent(someArgument);
}
@kirby561
kirby561 / TestPlayerController.cpp
Created November 23, 2023 01:18
Using TransferComponent in a PlayerController example in Unreal Engine.
#include "TestPlayerController.h"
#include "Components/TransferComponent.h"
DEFINE_LOG_CATEGORY_STATIC(TestPlayerControllerSub, Log, All);
ATestPlayerController::ATestPlayerController() {
_transferComponent = CreateDefaultSubobject<UTransferComponent>(TEXT("TransferComponent"));
_transferComponent->SetVerboseLoggingEnabled(true);
}
@kirby561
kirby561 / TransferComponent.cpp
Created November 22, 2023 21:39
Implements a UActorComponent that can be attached to actors in Unreal Engine to send buffers larger than the max RPC size by sending chunks at a time.
/*
* Copyright © 2023 kirby561
*
* 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
#include "MenuController.h"
#include "Blueprint/UserWidget.h"
#include "Blueprint/WidgetTree.h"
#include "Components/ScrollBox.h"
#include "Components/CanvasPanel.h"
#include "Components/Button.h"
UMenuController::UMenuController() {
static ConstructorHelpers::FClassFinder<UUserWidget> widgetTemplate(TEXT("/Game/WBP_SomeWidget"));
_widgetTemplate = widgetTemplate.Class;
@kirby561
kirby561 / MenuController.h
Last active July 6, 2023 04:07
Generated header
#pragma once
#include "CoreMinimal.h"
#include "MenuController.generated.h"
class UUserWidget;
class UScrollBox;
class UCanvasPanel;
class UButton;