How to register a Tick function to the editor global?

I am making a plugin which has its own thread to handle requests from other apps. One thing I want to do is to import raw resources created by other app to UE contents(uassets for animation, mat, mesh and so on). The problem I got is that all import functions I can find is not thread safe, so that I have to store those import requests trigger by sub thread to a vector and handle them in my game thread.

The only way I came up with is to spawn an actor in plugin’s StartupModule function and look into the request queue in the actor’s Tick function. But I can’t find a good example to follow to create a “shadow” Actor and ticks it in editor. So I am wondering if I went the right direction. Is there other way to achieve this functionality? If no, how to spawn an actor out of the “World” and get it ticked? I am new to UE4 so could you guys give me some hints? Thanks.

You can implement tick to any object by adding inference to FTickableGameObject or FTickableEditorObject the class (like interface) it self don’t event need to be UObject so you can do this on module class or any class you can think off.

If tick involves game it self use FTickableGameObject and ot make it tick to editor override IsTickableInEditor and IsTickableWhenPaused to make it return true. If it’s more for editor functions use FTickableEditorObject

Once you set it up just override Tick function as you normally do in actor

here is some example from engine source:

https://github.com/EpicGames/UnrealEngine/blob/7d9919ac7bfd80b7483012eab342cb427d60e8c9/Engine/Plugins/Runtime/MIDIDevice/Source/MIDIDevice/MIDIDeviceModule.cpp

https://github.com/EpicGames/UnrealEngine/blob/7d9919ac7bfd80b7483012eab342cb427d60e8c9/Engine/Plugins/FX/Niagara/Source/NiagaraEditor/Private/ViewModels/NiagaraMetaDataCollectionViewModel.h

https://github.com/EpicGames/UnrealEngine/blob/7d9919ac7bfd80b7483012eab342cb427d60e8c9/Engine/Source/Editor/SkeletonEditor/Private/SkeletonEditor.h

It works! thank you.

Those links do not work anymore. Is there somewhere else to see the example code?

The “example code” is the unreal engine source code. Just open UE4.sln and search for MIDIDeviceModule or SkeletonEditor.

To be more specific about this topic: You have to create an instance of your own FTickableEditorObject and it will register itself to the engine/editor update loop.

class FAssetTest : public FTickableEditorObject
{

public:
	virtual void Tick(float DeltaTime) override
	{
		TimePassed += DeltaTime;
	}

	virtual ETickableTickType GetTickableTickType() const override
	{
		return ETickableTickType::Always;
	}
	virtual TStatId GetStatId() const override
	{
		RETURN_QUICK_DECLARE_CYCLE_STAT(FAssetTest, STATGROUP_Tickables);
	}
	virtual bool IsTickableWhenPaused() const
	{
		return true;
	}
	virtual bool IsTickableInEditor() const
	{
		return true;
	}


private:
	float TimePassed = 0;

};

void ExampleModule::StartupModule()
{
	...

	auto AssetTest = new FAssetTest(); // "memory leak"
}