x

Search in
Sort by:

Question Status:

Search help

  • Simple searches use one or more words. Separate the words with spaces (cat dog) to search cat,dog or both. Separate the words with plus signs (cat +dog) to search for items that may contain cat but must contain dog.
  • You can further refine your search on the search results page, where you can search by keywords, author, topic. These can be combined with each other. Examples
    • cat dog --matches anything with cat,dog or both
    • cat +dog --searches for cat +dog where dog is a mandatory term
    • cat -dog -- searches for cat excluding any result containing dog
    • [cats] —will restrict your search to results with topic named "cats"
    • [cats] [dogs] —will restrict your search to results with both topics, "cats", and "dogs"

Steamworks Callback fails to compile in UE4 - Error Unrecognized Type GameOverlayActivated_t , Must be UCLAS, USTRUCT or ENUM

Hello, I am trying to work with Steamworks lately, and I am trying to do a simple event of pausing my game when the Steam Game Overlay becomes active.

I created a c++ Game Instance class in my game, and I can load it up in the game, as I can create and modify a variable in it. When I write the following code

Header file

include "Engine/GameInstance.h"

include "MusicalRangeInstance.generated.h"

 void SteamOverlayActive();

 UFUNCTION(BlueprintPure, category = "Steamworks")
 bool OnSteamOverlayEnabled(GameOverlayActivated_t *pResult, bool bIOFailure);
 CCallResult<UMusicalRangeInstance, GameOverlayActivated_t> m_callResultGameOverlayActive;


And then in cpp file

include "MusicalRange.h"

include "MusicalRangeInstance.h"

include "ThirdParty/Steamworks/Steamv132/sdk/public/steam/steam_api.h"

 void UMusicalRangeInstance::SteamOverlayActive() {
 SteamAPICall_t hSteamAPICall = SteamUtils()->IsOverlayEnabled();
 m_callResultGameOverlayActive.Set(hSteamAPICall, this, &UMusicalRangeInstance::OnSteamOverlayEnabled);
 }

 bool UMusicalRangeInstance::OnSteamOverlayEnabled(GameOverlayActivated_t *pResult, bool bIOFailure) {
 return bIOFailure || (pResult->m_bActive == false);
 }

[/code]

The problem I have, is that the c++ compile for UE4 says that GameOverlayActivated_t is not a valid structure. I haven't been able to find anything on this problem online. I am quite noob when it comes to Steamworks coding, and I am having a lot of trouble understanding the documentation just like that. Examples would be best. Like, it has an example for Call Results, but not really for Callbacks at https://partner.steamgames.com/documentation/getting_started

Product Version: UE 4.14
Tags:
more ▼

asked Feb 17 '17 at 04:20 PM in C++ Programming

Motanum gravatar image

Motanum
488 38 45 252

Wurmloch83 gravatar image Wurmloch83 Feb 17 '17 at 06:57 PM

The UHT does not know the the type GameOverlayActivated_t, and thus you cannot use it in UFUNCTIONS. Use a normal C++ Function as callback, copy the contents of GameOverlayActivated_t into a Structure that you define, and use this structure as parameter for you UFUNCTION. I cannot give an example, because i never worked with the steam api yet.

(comments are locked)
10|2000 characters needed characters left

1 answer: sort voted first

I managed to solve this after some tinkering. I have no idea if the Steamworks function I am trying to implement works at all, but at least it compiles now.

Header ended like this

 include "ThirdParty/Steamworks/Steamv132/sdk/public/steam/steam_api.h"
 include "Engine/GameInstance.h"
 include "MusicalRangeInstance.generated.h"
 
 void SteamOverlayActive();
 
 //UFUNCTION(BlueprintPure, category = "Steamworks")
 void OnSteamOverlayEnabled(GameOverlayActivated_t *pResult, bool bIOFailure);
 CCallResult<UMusicalRangeInstance, GameOverlayActivated_t> m_callResultGameOverlayActive;

I had to change OnSteamOverlayEnabled from Void to Bool, and get rid of the UFUNCTION macro.

On the CPP file I have the same include files as before but I had to change the OnSteamOverlayEnable code,

  void UMusicalRangeInstance::OnSteamOverlayEnabled(GameOverlayActivated_t *pResult, bool bIOFailure) {
 IsSteamOverlayActive = (pResult->m_bActive != 0);
        return;
 }

With those changes it compiles.

more ▼

answered Feb 17 '17 at 08:01 PM

Motanum gravatar image

Motanum
488 38 45 252

(comments are locked)
10|2000 characters needed characters left
Your answer
toggle preview:

Up to 5 attachments (including images) can be used with a maximum of 5.2 MB each and 5.2 MB total.

Follow this question

Once you sign in you will be able to subscribe for any updates here

Answers to this question