Skip to content

Commit

Permalink
Merge pull request #974 from CesiumGS/public-credits-widget
Browse files Browse the repository at this point in the history
Make credit system's widget publicly accessible.
  • Loading branch information
kring authored Oct 2, 2022
2 parents 227710c + 871a2a0 commit 00da7e0
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 10 deletions.
1 change: 1 addition & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@

- Improved the dithered transition between levels-of-detail, making it faster and eliminating depth fighting.
- Add an option on the `Cesium3DTileset` to change the tileset's mobility. This allows users to make tileset movable at runtime, if needed.
- `ACesiumCreditSystem` now has a Blueprint-accessible property for the `CreditsWidget`. This is useful to, for example, move the credits to an in-game billboard rather than a 2D overlay.

##### Fixes :wrench:

Expand Down
14 changes: 7 additions & 7 deletions Source/CesiumRuntime/Private/CesiumCreditSystem.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -149,12 +149,12 @@ ACesiumCreditSystem::ACesiumCreditSystem()

void ACesiumCreditSystem::BeginPlay() {
Super::BeginPlay();
if (!_creditsWidget) {
_creditsWidget =
if (!CreditsWidget) {
CreditsWidget =
CreateWidget<UScreenCreditsWidget>(GetWorld(), CreditsWidgetClass);
}
if (IsValid(_creditsWidget) && !IsRunningDedicatedServer()) {
_creditsWidget->AddToViewport();
if (IsValid(CreditsWidget) && !IsRunningDedicatedServer()) {
CreditsWidget->AddToViewport();
}
}

Expand All @@ -163,7 +163,7 @@ bool ACesiumCreditSystem::ShouldTickIfViewportsOnly() const { return true; }
void ACesiumCreditSystem::Tick(float DeltaTime) {
Super::Tick(DeltaTime);

if (!_pCreditSystem || !IsValid(_creditsWidget)) {
if (!_pCreditSystem || !IsValid(CreditsWidget)) {
return;
}

Expand Down Expand Up @@ -207,7 +207,7 @@ void ACesiumCreditSystem::Tick(float DeltaTime) {
}
}
OnScreenCredits += "<credits url=\"popup\" text=\" Data attribution\"/>";
_creditsWidget->SetCredits(Credits, OnScreenCredits);
CreditsWidget->SetCredits(Credits, OnScreenCredits);
}
_pCreditSystem->startNextFrame();
}
Expand Down Expand Up @@ -283,7 +283,7 @@ FString ACesiumCreditSystem::ConvertHtmlToRtf(std::string html) {
std::string output, url;
err = tidyParseString(tdoc, html.c_str());
if (err < 2) {
convertHtmlToRtf(output, url, tdoc, tidyGetRoot(tdoc), _creditsWidget);
convertHtmlToRtf(output, url, tdoc, tidyGetRoot(tdoc), CreditsWidget);
}
tidyBufFree(&tidy_errbuf);
tidyRelease(tdoc);
Expand Down
6 changes: 3 additions & 3 deletions Source/CesiumRuntime/Public/CesiumCreditSystem.h
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,9 @@ class CESIUMRUNTIME_API ACesiumCreditSystem : public AActor {
UPROPERTY(BlueprintReadOnly, Category = "Cesium")
bool CreditsUpdated = false;

UPROPERTY(BlueprintReadOnly, Category = "Cesium")
class UScreenCreditsWidget* CreditsWidget;

// Called every frame
virtual bool ShouldTickIfViewportsOnly() const override;
virtual void Tick(float DeltaTime) override;
Expand All @@ -54,9 +57,6 @@ class CESIUMRUNTIME_API ACesiumCreditSystem : public AActor {
private:
static UClass* CesiumCreditSystemBP;

UPROPERTY()
class UScreenCreditsWidget* _creditsWidget;

/**
* A tag that is assigned to Credit Systems when they are created
* as the "default" Credit System for a certain world.
Expand Down

0 comments on commit 00da7e0

Please sign in to comment.