hi i use unreal engine 4.19 visual studio 2015 version 14.0.25431.01 update 3
i have create a project and export in html5 in aproximatively in 30minute max
after i have create a basic c++ class with visual studio and add my actor class in scene
my class :
cpp
#include "MyActor.h"
#include "EngineUtils.h"
#include "Engine/StaticMeshActor.h"
#include "ConstructorHelpers.h"
#include "Materials/Material.h"
#include "Components/StaticMeshComponent.h"
#ifdef EMSCRIPTEN
#include <emscripten.h>
#endif
// Sets default values
AMyActor::AMyActor()
{
// Set this actor to call Tick() every frame. You can turn this off to improve performance if you don't need it.
PrimaryActorTick.bCanEverTick = true;
static ConstructorHelpers::FObjectFinder<UMaterial> Material(TEXT("/Game/mat/BasicShapeMaterial_2"));
if (Material.Succeeded()) {
StoredMaterial = Material.Object;
}
}
#ifdef __EMSCRIPTEN__
extern "C" {
EMSCRIPTEN_KEEPALIVE
#endif
void AMyActor::changeColorCube(){
TArray<AStaticMeshActor *> actors;
FindAllActors(GetWorld(), actors);
for (int i = 0; i < actors.Num(); i++) {
AStaticMeshActor * m = actors[i];
if (m->ActorHasTag("Cubechange")) {
//static ConstructorHelpers::FObjectFinder<UMaterial> Material(TEXT("Material'/Game/mat/BasicShapeMaterial_2'"));
m->GetStaticMeshComponent()->SetMaterial(0, StoredMaterial);
}
}
}
#ifdef __EMSCRIPTEN__
}
#endif
// Called when the game starts or when spawned
void AMyActor::BeginPlay()
{
Super::BeginPlay();
}
// Called every frame
void AMyActor::Tick(float DeltaTime)
{
Super::Tick(DeltaTime);
}
template<typename T>
void AMyActor::FindAllActors(UWorld* World, TArray<T*>& Out)
{
for (TActorIterator<AActor> It(World, T::StaticClass()); It; ++It)
{
T* Actor = Cast<T>(*It);
if (Actor && !Actor->IsPendingKill())
{
Out.Add(Actor);
}
}
}
.h
// Fill out your copyright notice in the Description page of Project Settings.
#pragma once
#include "CoreMinimal.h"
#include "GameFramework/Actor.h"
#include "MyActor.generated.h"
UCLASS()
class MYPROJECT2_API AMyActor : public AActor
{
GENERATED_BODY()
public:
// Sets default values for this actor's properties
AMyActor();
UFUNCTION(BlueprintCallable, Category = "changeColor")
void changeColorCube();
template<typename T>
void FindAllActors(UWorld* World, TArray<T*>& Out);
protected:
// Called when the game starts or when spawned
virtual void BeginPlay() override;
public:
// Called every frame
virtual void Tick(float DeltaTime) override;
UMaterial* StoredMaterial;
};
im inspired by
https://forums.unrealengine.com/development-discussion/html5-development/91660-js-c-communication?119332-js-c-communication=
no error project generate
and the class is fonctional in editor
but i export in html5
after 5 minute the console displayed this line
UATHelper: Packaging (HTML5): JS_ENGINES = [NODE_JS] # add this if you have spidermonkey installed too, SPIDERMONKEY_ENGINE]
UATHelper: Packaging (HTML5): Performing 3 actions (4 in parallel)
UATHelper: Packaging (HTML5): [1/3] Compile MyActor.cpp
UATHelper: Packaging (HTML5): [2/3] Compile MyActor.gen.cpp
UATHelper: Packaging (HTML5): In file included from C:/Users/aznur/Documents/Unreal Projects/MyProject2/Source/MyProject2/MyActor.cpp:3:
UATHelper: Packaging (HTML5): In file included from C:/Users/aznur/Documents/Unreal Projects/MyProject2/Intermediate/Build/HTML5/UE4/Inc/MyProject2/MyActor.gen.cpp:8:
and after that no thing no error and the processor up to 80%-100% after 2 hours no change same line
nothing else can display
my code is good ?
I do not find a simple but complete example that shows the use of a c ++ class from start to finish
in ue4 with use by javascript EMSCRIPTEN method
thanks for help