Advertisement

change umg unreal engine by c++

Started by May 11, 2017 04:56 PM
3 comments, last by Pedro Alves 7 years, 6 months ago
how i change umg for another by widget when i click in button  using c++
i using this tutorial to make my login systyem


but i can´t put work

void ULoginMenuWidget::OnOptionsClicked()
{

	/*if (GetWorld()->GetGameInstance())
	{
		UStateManager *StateManager = Cast<UStateManager>(GetWorld()->GetGameInstance()); 
		if (StateManager) 
		{ StateManager->ChangeState(EGameState::EOptionsScreen);
		}
	}
	*/
	if (GEngine) {
		GEngine->AddOnScreenDebugMessage(-1, 2.f, FColor::MakeRandomColor(), TEXT("Options"));
	}
	/**/
	
}
my game crash

Hello

i find the solution i forget the add new instance to blueprintclass

Hello

Advertisement

now i have other problem

when i try login the game and exit and try make login for the secound time the game crash
give this error
what i doing wrong
and this is the link to my project
https://www.dropbox.com/sh/ay42hi5u7npwf8n/AAB0lDrJ6VjKQ2pVL4wcCP8Sa?dl=0
Access violation - code c0000005 (first/second chance not available)

UE4Editor_CoreUObject
UE4Editor_RPG_4849!UGameSparksStatics::LoginSucessDetails_Response() [c:\users\pedro\documents\unreal projects\rpg\source\rpg\gamesparksstatics.cpp:48]
UE4Editor_RPG_4849!GameSparks::Core::GSTypedRequest<GameSparks::Api::Requests::AccountDetailsRequest,GameSparks::Api::Responses::AccountDetailsResponse>::Callbacks::OnSucess() [c:\users\pedro\documents\unreal projects\rpg\plugins\gamesparks\source\gamesparksbasesdk\include\gamesparks\gstypedrequest.h:113]
UE4Editor_GameSparks!GameSparks::Core::GSRequest::Complete() [c:\users\pedro\documents\unreal projects\rpg\plugins\gamesparks\source\gamesparksbasesdk\src\gamesparks\gsrequest.cpp:83]
UE4Editor_GameSparks!GameSparks::Core::GS::ProcessReceivedResponse() [c:\users\pedro\documents\unreal projects\rpg\plugins\gamesparks\source\gamesparksbasesdk\src\gamesparks\gs.cpp:510]
UE4Editor_GameSparks!GameSparks::Core::GS::ProcessReceivedItem() [c:\users\pedro\documents\unreal projects\rpg\plugins\gamesparks\source\gamesparksbasesdk\src\gamesparks\gs.cpp:565]
UE4Editor_GameSparks!GameSparks::Core::GS::OnMessageReceived() [c:\users\pedro\documents\unreal projects\rpg\plugins\gamesparks\source\gamesparksbasesdk\src\gamesparks\gs.cpp:164]
UE4Editor_GameSparks!GameSparks::Core::GSConnection::OnWebSocketCallback() [c:\users\pedro\documents\unreal projects\rpg\plugins\gamesparks\source\gamesparksbasesdk\src\gamesparks\gsconnection.cpp:129]
UE4Editor_GameSparks!`anonymous namespace'::_RealWebSocket::_dispatch() [c:\users\pedro\documents\unreal projects\rpg\plugins\gamesparks\source\gamesparksbasesdk\src\easywsclient\easywsclient.cpp:649]
UE4Editor_GameSparks!GameSparks::Core::GSConnection::Update() [c:\users\pedro\documents\unreal projects\rpg\plugins\gamesparks\source\gamesparksbasesdk\src\gamesparks\gsconnection.cpp:160]
UE4Editor_GameSparks!GameSparks::Core::GS::UpdateConnections() [c:\users\pedro\documents\unreal projects\rpg\plugins\gamesparks\source\gamesparksbasesdk\src\gamesparks\gs.cpp:314]
UE4Editor_GameSparks!UGameSparksModule::Tick() [c:\users\pedro\documents\unreal projects\rpg\plugins\gamesparks\source\gamesparks\private\gamesparksmodule.cpp:66]
UE4Editor_Engine
UE4Editor_UnrealEd
UE4Editor_UnrealEd
UE4Editor
UE4Editor
UE4Editor
UE4Editor
UE4Editor
kernel32
ntdll

Hello

Access violation - code c0000005

This generally means you're attempting to read and/or write to memory which is invalid.

Check if pointers are null before using them. Additionally, check if you're reading/writing outside the bounds of an array (keep in mind that for an array of size 5, the last valid index is 4).

Hello to all my stalkers.

The problem is only happen when i try login for the secound time

i think the problem is in this function


void UGameSparksStatics::LoginSucessDetails_Response(GameSparks::Core::GS & gs, const GameSparks::Api::Responses::AccountDetailsResponse & resp)
{
    if (inicialized) {
        if (!resp.GetHasErrors()) {

            /***********************************************************************/
            if (theWorld->GetGameInstance())
            {
                UStateManager *manager = Cast<UStateManager>(theWorld->GetGameInstance());
                if (manager)
                {
                    manager->ChangeState(EGameState::EServerScreen);
                }


            }
/****************************************************************************************/
            else
            {
                if (GEngine) {
                    GEngine->AddOnScreenDebugMessage(-1, 2.f, FColor::MakeRandomColor(), TEXT("Accounts Details Request Fail"));
                }
            }

        }


    }
}

becouse i call a fuction like this the gameengine never crash

i think the gameparks don´t like when have change the gamestats


void UGameSparksStatics::LoginSucessDetails_Response(GameSparks::Core::GS & gs, const GameSparks::Api::Responses::AccountDetailsResponse & resp)
{
    if (inicialized) {
        if (!resp.GetHasErrors()) {
            if (GEngine) {
            GEngine->AddOnScreenDebugMessage(-1, 2.f, FColor::MakeRandomColor(),resp.GetJSONString().c_str());

            }
            else
            {
                if (GEngine) {
                    GEngine->AddOnScreenDebugMessage(-1, 2.f, FColor::MakeRandomColor(), TEXT("Accounts Details Request Fail"));
                }
            }

        }


    }
}

Hello

This topic is closed to new replies.

Advertisement