Apologies for reviving this thread but I was wondering how we could inherit from the TSharedFromThis template.
I was not able to find this via the “Add new C++ class” option in the editor.
I do not believe this is possible through the editor / BPs (though I might be wrong as I spend 95% of the time in C++).
When creating a new class FYourClass
, you need to make it a child of TSharedFromThis
, so TSharedFromThis<FYourClass>
.
Here is a minimal version of the ISceneOutlinerTreeItem.h
header, which (roughly speaking) is used for connecting the rows in the Scene Outliner with their underlying data.
// Copyright Epic Games, Inc. All Rights Reserved.
#pragma once
#include "CoreMinimal.h"
/** Base tree item interface */
struct SCENEOUTLINER_API ISceneOutlinerTreeItem : TSharedFromThis<ISceneOutlinerTreeItem>
{
...
};
As you can see, the struct ISceneOutlinerTreeItem
is passed to the TSharedFromThis
template, resulting in template instantiation. You can find TSharedFromThis
inside the SharedPointer.h
header. Classes can also be used, as exemplified by the class ISceneOutlinerColumn
(ISceneOutlinerColumn.h
).