-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
e3f10a6
commit 12ac2f9
Showing
14 changed files
with
211 additions
and
17 deletions.
There are no files selected for viewing
Binary file not shown.
Binary file not shown.
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
@echo off | ||
CD /D .. | ||
ue4 package -NoHostPlatform -TargetPlatforms=Win64+Android+Linux+LinuxArm64 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
#!/bin/sh | ||
ue4 package -NoHostPlatform -TargetPlatforms=IOS+Mac+TVOS+VisionOS |
Git LFS file not shown
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
// Copyright (c) 2024 Thirdweb. All Rights Reserved. | ||
|
||
#include "ThirdwebAssetManager.h" | ||
|
||
#if WITH_EDITOR || PLATFORM_ANDROID || PLATFORM_IOS | ||
#include "WebBrowserTexture.h" | ||
|
||
#include "Materials/Material.h" | ||
#endif | ||
|
||
UThirdwebAssetManager::UThirdwebAssetManager() | ||
{ | ||
DefaultMaterial = FString(TEXT("/Thirdweb/Assets/WebTexture_M.WebTexture_M")); | ||
DefaultTranslucentMaterial = FString(TEXT("/Thirdweb/Assets/WebTexture_TM.WebTexture_TM")); | ||
|
||
#if WITH_EDITOR || PLATFORM_ANDROID || PLATFORM_IOS | ||
// Add a hard reference to UWebBrowserTexture, without this the WebBrowserTexture DLL never gets loaded on Windows. | ||
UWebBrowserTexture::StaticClass(); | ||
#endif | ||
} | ||
|
||
void UThirdwebAssetManager::LoadDefaultMaterials() | ||
{ | ||
DefaultMaterial.LoadSynchronous(); | ||
DefaultTranslucentMaterial.LoadSynchronous(); | ||
} | ||
|
||
UMaterial* UThirdwebAssetManager::GetDefaultMaterial() | ||
{ | ||
return DefaultMaterial.Get(); | ||
} | ||
|
||
UMaterial* UThirdwebAssetManager::GetDefaultTranslucentMaterial() | ||
{ | ||
return DefaultTranslucentMaterial.Get(); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,43 @@ | ||
// Copyright (c) 2024 Thirdweb. All Rights Reserved. | ||
|
||
#include "Modules/ModuleManager.h" | ||
#include "ThirdwebModule.h" | ||
|
||
#include "IWebBrowserSingleton.h" | ||
#include "ThirdwebAssetManager.h" | ||
#include "WebBrowserModule.h" | ||
|
||
#include "Materials/Material.h" | ||
|
||
class FThirdwebModule : public IThirdwebModule | ||
{ | ||
public: | ||
virtual void StartupModule() override | ||
{ | ||
if (ThirdwebAssetManager == nullptr) | ||
{ | ||
ThirdwebAssetManager = NewObject<UThirdwebAssetManager>((UObject*)GetTransientPackage(), NAME_None, RF_Transient | RF_Public); | ||
ThirdwebAssetManager->LoadDefaultMaterials(); | ||
|
||
IWebBrowserModule::Get(); // force the module to load | ||
if (IWebBrowserModule::IsAvailable() && IWebBrowserModule::Get().IsWebModuleAvailable()) | ||
{ | ||
IWebBrowserSingleton* WebBrowserSingleton = IWebBrowserModule::Get().GetSingleton(); | ||
if (WebBrowserSingleton) | ||
{ | ||
WebBrowserSingleton->SetDefaultMaterial(ThirdwebAssetManager->GetDefaultMaterial()); | ||
WebBrowserSingleton->SetDefaultTranslucentMaterial(ThirdwebAssetManager->GetDefaultTranslucentMaterial()); | ||
} | ||
} | ||
} | ||
} | ||
|
||
virtual void ShutdownModule() override | ||
{ | ||
} | ||
|
||
private: | ||
UThirdwebAssetManager* ThirdwebAssetManager = nullptr; | ||
}; | ||
|
||
IMPLEMENT_MODULE(FThirdwebModule, Thirdweb); | ||
|
||
IMPLEMENT_MODULE(FDefaultModuleImpl, Thirdweb) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
// Copyright (c) 2024 Thirdweb. All Rights Reserved. | ||
|
||
#pragma once | ||
|
||
#include "Materials/Material.h" | ||
|
||
#include "UObject/SoftObjectPtr.h" | ||
|
||
#include "ThirdwebAssetManager.generated.h" | ||
|
||
class UMaterial; | ||
/** | ||
* @class UThirdwebAssetManager | ||
* @brief Manages and handles loading, unloading, and accessing game assets. | ||
* | ||
* The UThirdwebAssetManager class is responsible for the efficient management | ||
* of game assets such as textures, models, sound files, and other resources. | ||
* It provides functions to load and unload assets, handles asset reference | ||
* counting, and ensures that assets are loaded only once. This helps in | ||
* optimizing game performance by minimizing redundant loading and memory usage. | ||
*/ | ||
UCLASS() | ||
class THIRDWEB_API UThirdwebAssetManager : public UObject | ||
{ | ||
GENERATED_BODY() | ||
public: | ||
UThirdwebAssetManager(); | ||
|
||
void LoadDefaultMaterials(); | ||
|
||
UMaterial* GetDefaultMaterial(); | ||
UMaterial* GetDefaultTranslucentMaterial(); | ||
|
||
protected: | ||
UPROPERTY() | ||
TSoftObjectPtr<UMaterial> DefaultMaterial; | ||
TSoftObjectPtr<UMaterial> DefaultTranslucentMaterial; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
// Copyright (c) 2024 Thirdweb. All Rights Reserved. | ||
|
||
#pragma once | ||
|
||
#include "Modules/ModuleManager.h" | ||
|
||
class IThirdwebModule : public IModuleInterface | ||
{ | ||
public: | ||
/** | ||
* Singleton-like access to this module's interface. This is just for convenience! | ||
* Beware of calling this during the shutdown phase, though. Your module might have been unloaded already. | ||
* | ||
* @return Returns singleton instance, loading the module on demand if needed | ||
*/ | ||
static IThirdwebModule& Get() { return FModuleManager::LoadModuleChecked<IThirdwebModule>("Thirdweb"); } | ||
|
||
/** | ||
* Checks to see if this module is loaded and ready. It is only valid to call Get() if IsAvailable() returns true. | ||
* | ||
* @return True if the module is loaded and ready to use | ||
*/ | ||
static bool IsAvailable() { return FModuleManager::Get().IsModuleLoaded("Thirdweb"); } | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<root xmlns:android="http://schemas.android.com/apk/res/android"> | ||
<init> | ||
<log text="Thirdweb Plugin Init"/> | ||
<setBoolFromPropertyContains result="bPackageForOculusQuest" ini="Engine" section="/Script/AndroidRuntimeSettings.AndroidRuntimeSettings" property="PackageForOculusMobile" contains="Quest"/> | ||
<setBoolFromPropertyContains result="bPackageForOculusQuest2" ini="Engine" section="/Script/AndroidRuntimeSettings.AndroidRuntimeSettings" property="PackageForOculusMobile" contains="Quest2"/> | ||
<setBoolFromPropertyContains result="bPackageForOculusQuestPro" ini="Engine" section="/Script/AndroidRuntimeSettings.AndroidRuntimeSettings" property="PackageForOculusMobile" contains="QuestPro"/> | ||
|
||
<setBoolOr result="bPackageForOculusMobile" | ||
arg1="$B(bPackageForOculusQuest)" arg2="$B(bPackageForOculusQuest2)"/> | ||
<setBoolOr result="bPackageForOculusMobile" | ||
arg1="$B(bPackageForOculusMobile)" arg2="$B(bPackageForOculusQuestPro)"/> | ||
|
||
<if condition="bPackageForOculusMobile"> | ||
<true> | ||
<log text="Adding com.oculus.always_draw_view_root for Oculus devices to manifest for hardware acceleration."/> | ||
</true> | ||
</if> | ||
</init> | ||
|
||
<androidManifestUpdates> | ||
<if condition="bPackageForOculusMobile"> | ||
<true> | ||
<addElements tag="application"> | ||
<meta-data android:name="com.oculus.always_draw_view_root" android:value="true"/> | ||
</addElements> | ||
</true> | ||
</if> | ||
</androidManifestUpdates> | ||
|
||
</root> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters