Skip to content

Commit

Permalink
Fixed score details texts sometimes being non curved
Browse files Browse the repository at this point in the history
  • Loading branch information
NSGolova committed Apr 20, 2024
1 parent 5633598 commit 06e1e09
Showing 1 changed file with 21 additions and 18 deletions.
39 changes: 21 additions & 18 deletions src/UI/QuestUI.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,24 @@ namespace QuestUI {
GameObject* beatSaberUIObject = nullptr;
GameObject* dropdownListPrefab = nullptr;
GameObject* modalPrefab = nullptr;

static SafePtrUnity<TMP_FontAsset> mainTextFont;
TMP_FontAsset* GetMainTextFont() {
if(!mainTextFont) mainTextFont.emplace(Resources::FindObjectsOfTypeAll<TMP_FontAsset*>()->FirstOrDefault([](TMP_FontAsset* x) { return x->get_name() == "Teko-Medium SDF"; }));
if(!mainTextFont) {
return nullptr;
}
return mainTextFont.ptr();
}

static SafePtrUnity<Material> mainUIFontMaterial;
Material* GetMainUIFontMaterial() {
if(!mainUIFontMaterial) mainUIFontMaterial.emplace(Resources::FindObjectsOfTypeAll<Material*>()->FirstOrDefault([](Material* x) { return x->get_name() == "Teko-Medium SDF Curved Softer"; }));
if(!mainUIFontMaterial) {
return nullptr;
}
return mainUIFontMaterial.ptr();
}

void SetupPersistentObjects() {
if(!beatSaberUIObject) {
Expand Down Expand Up @@ -107,6 +125,9 @@ namespace QuestUI {
modalPrefab->set_name(name);
modalPrefab->SetActive(false);
}

GetMainTextFont();
GetMainUIFontMaterial();
}

static PhysicsRaycasterWithCache* physicsRaycaster = nullptr;
Expand Down Expand Up @@ -139,24 +160,6 @@ namespace QuestUI {
return mat_UINoGlow.ptr();
}

static SafePtrUnity<TMP_FontAsset> mainTextFont;
TMP_FontAsset* GetMainTextFont() {
if(!mainTextFont) mainTextFont.emplace(Resources::FindObjectsOfTypeAll<TMP_FontAsset*>()->FirstOrDefault([](TMP_FontAsset* x) { return x->get_name() == "Teko-Medium SDF"; }));
if(!mainTextFont) {
return nullptr;
}
return mainTextFont.ptr();
}

static SafePtrUnity<Material> mainUIFontMaterial;
Material* GetMainUIFontMaterial() {
if(!mainUIFontMaterial) mainUIFontMaterial.emplace(Resources::FindObjectsOfTypeAll<Material*>()->FirstOrDefault([](Material* x) { return x->get_name() == "Teko-Medium SDF Curved Softer"; }));
if(!mainUIFontMaterial) {
return nullptr;
}
return mainUIFontMaterial.ptr();
}

void ClearCache() {
diContainer = nullptr;
physicsRaycaster = nullptr;
Expand Down

0 comments on commit 06e1e09

Please sign in to comment.