2018년 10월 15일 월요일

UE4 - How to use UE_LOG In Custom Plugins

The result in at the end of the article.




UE_LOG and AddOnScreenDebugMessage doesn't work in my case

0
Hi, i made my custom actor based class Steam_Function_actor_based, inside it i made a method UE_RequestLobbyList()
  1. Steam_Function_actor_based.h
  2. // Fill out your copyright notice in the Description page of Project Settings.
  3. #pragma once
  4. #include "GameFramework/Actor.h"
  5. #include "Steam_Function_actor_based.generated.h"
  6. UCLASS()
  7. class STEAM_TRAINING_API ASteam_Function_actor_based : public AActor
  8. {
  9. GENERATED_BODY()
  10. public:
  11. // Sets default values for this actor's properties
  12. ASteam_Function_actor_based();
  13. // Called when the game starts or when spawned
  14. virtual void BeginPlay() override;
  15. // Called every frame
  16. virtual void Tick( float DeltaSeconds ) override;
  17. UFUNCTION(BlueprintCallable, Category = "Steam")
  18. void UE_RequestLobbyList();
  19. };
  20.  
and made method body in Steam_Function_actor_based.cpp
  1. // Fill out your copyright notice in the Description page of Project Settings.
  2. #include "steam_training.h"
  3. #include "Steam_Function_actor_based.h"
  4. #include "steam_api.h"
  5. #pragma comment(lib, "steam_api64.lib")
  6. void ASteam_Function_actor_based::UE_RequestLobbyList()
  7. {
  8. UE_LOG(LogTemp, Warning, TEXT("hSteamAPICall"));
  9. GEngine->AddOnScreenDebugMessage(-1, 5.f, FColor::Red, TEXT("hSteamAPICall"));
  10. SteamAPICall_t hSteamAPICall = SteamMatchmaking()->RequestLobbyList();
  11. //SteamAPI_SetMiniDumpComment("Minidump comment: SteamworksExample.exe\n");
  12. //SteamAPI_WriteMiniDump(1, 0, 0);
  13. UE_LOG(LogTemp, Warning, TEXT("hSteamAPICall is %d"), hSteamAPICall);
  14. GEngine->AddOnScreenDebugMessage(-1, 5.f, FColor::Red, FString::Printf(TEXT("hSteamAPICall is %d"), hSteamAPICall));
  15. }
  16.  
so when i call my method from blueprint, execution lines show method called https://yadi.sk/i/U1bZIsPfgSD9J , but no onscreen message and no log message, why? i also tryed call my method in other way - by casting after jump and casting fail (target variable just empty)
to be clear, i use 4.7.6 UE version
investigated interesting thing - Print String from blueprints work fine, but
  1. UE_LOG(LogTemp, Warning, TEXT("hSteamAPICall"));
  2. GEngine->AddOnScreenDebugMessage(-1, 5.f, FColor::Red, TEXT("hSteamAPICall"));
  3.  
from my custom method won't at all, but i call Print String after my method in blueprint graph
re:
You are aware that UE4 has a common interface to support variues online services under same APIs (called OnlineSubsystem) and has SteamWorks support ready?


futher investigation lead me to https://www.youtube.com/watch?t=1543&v=t-7JYG9rvWM, i added
DEFINE_LOG_CATEGORY(MyLog); //into my class .cpp
also added
DECLARE_LOG_CATEGORY_EXTERN(MyLog, Log, All); //into my class .h
made blueprint built from my class actor and added that new blueprint into blueprint SideScrollerCharacter that drive your character by default
after debug -> run new instance in VS i could get in output log my message
MyLog:Warning: hSteamAPICall****
and seems it appeared on screen, but i also got back return bool value and error
LogVoice:Warning: Failed to initialize voice interface LogScript:Warning: Accessed None 'target' SideScrollerExampleMap_C /Game/SideScrollerBP/Maps/UEDPIE_0_SideScrollerExampleMap.SideScrollerExampleMap:PersistentLevel.SideScrollerExampleMap_C_2 Function /Game/SideScrollerBP/Maps/SideScrollerExampleMap.SideScrollerExampleMap_C:ExecuteUbergraph_SideScrollerExampleMap:001F PIE:Error: Error Accessed None 'target' from node Event Begin Play in blueprint SideScrollerExampleMap
so do you have any idea why this PIE:Error: happen?

example :

DECLARE_LOG_CATEGORY_EXTERN(MyLog, Log, All); //into my class .h
DEFINE_LOG_CATEGORY(MyLog); //into my class .cpp
UE_LOG(MyLog, Warning, TEXT("%f , %f, %f"), Start.X, Start.Y, Start.Z); //use example

출처 : 언리얼엔진 포럼

댓글 없음:

댓글 쓰기