How to create new touch interface in C++

Hello there,
I’m trying to destroy/create different touch interface in C++ during the game. Basically what I’m doing is:
In header, expose class variable. For some reason if I use TSubclassOf I cannot get the Touch Interface Setup created in content.

UPROPERTY(EditDefaultsOnly, Category = "Misc")
	UTouchInterface* InGameTouchInterfaceClass;

In CPP:

	m_gameTouchInterface = NewObject<UTouchInterface>(InGameTouchInterfaceClass);
	if (m_gameTouchInterface) {
		Log("Create touch interface!");
		m_playerCtrller->ActivateTouchInterface(m_gameTouchInterface);
	}

The code logs “Create touch interface” and no error reported. But the interface didn’t show up. Please help ;D

Hello! Do you check bAlwaysShowTouchInterface option in Project Input Settings?

It turns out that I should directly put:

ctrller->ActivateTouchInterface(InGameTouchInterfaceClass)

instead of creating a new uboject and assign to it… If anyone wonder how to do it, this is the way I found ;D. Thank you anyway!

1 Like