Skip to content

Commit 2383978

Browse files
committed
Initial Commit
0 parents  commit 2383978

File tree

12 files changed

+492
-0
lines changed

12 files changed

+492
-0
lines changed

.gitignore

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
# macOS system files
2+
.DS_Store
3+
.AppleDouble
4+
.LSOverride
5+
Icon
6+
7+
# Thumbnails
8+
._*
9+
10+
# Files that might appear on external disks
11+
.Spotlight-V100
12+
.Trashes
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
{
2+
"FileVersion": 3,
3+
"Version": 1,
4+
"VersionName": "1.0",
5+
"FriendlyName": "%PLUGIN_NAME%",
6+
"Description": "%PLUGIN_NAME% Plugin by AvnishGameDev.",
7+
"Category": "Other",
8+
"CreatedBy": "AvnishGameDev",
9+
"CreatedByURL": "https://avnishgamedev.com",
10+
"DocsURL": "",
11+
"MarketplaceURL": "",
12+
"SupportURL": "",
13+
"CanContainContent": true,
14+
"IsBetaVersion": false,
15+
"IsExperimentalVersion": false,
16+
"Installed": false,
17+
"Modules": [
18+
{
19+
"Name": "%PLUGIN_NAME%",
20+
"Type": "Runtime",
21+
"LoadingPhase": "PreLoadingScreen"
22+
}
23+
]
24+
}
Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
// Copyright AvnishGameDev 2024.
2+
3+
using System.IO;
4+
using UnrealBuildTool;
5+
6+
public class %PLUGIN_NAME% : ModuleRules
7+
{
8+
public %PLUGIN_NAME%(ReadOnlyTargetRules Target) : base(Target)
9+
{
10+
PCHUsage = ModuleRules.PCHUsageMode.UseExplicitOrSharedPCHs;
11+
12+
PublicIncludePaths.AddRange(
13+
new string[] {
14+
// ... add public include paths required here ...
15+
}
16+
);
17+
18+
19+
PrivateIncludePaths.AddRange(
20+
new string[] {
21+
// ... add other private include paths required here ...
22+
}
23+
);
24+
25+
26+
PublicDependencyModuleNames.AddRange(
27+
new string[]
28+
{
29+
"Core",
30+
// ... add other public dependencies that you statically link with here ...
31+
}
32+
);
33+
34+
35+
PrivateDependencyModuleNames.AddRange(
36+
new string[]
37+
{
38+
"CoreUObject",
39+
"Engine",
40+
"Slate",
41+
"SlateCore",
42+
// ... add private dependencies that you statically link with here ...
43+
}
44+
);
45+
46+
47+
DynamicallyLoadedModuleNames.AddRange(
48+
new string[]
49+
{
50+
// ... add any modules that your module loads dynamically here ...
51+
}
52+
);
53+
54+
PrivateIncludePathModuleNames.AddRange(
55+
new string[] {
56+
"Settings",
57+
"Launch",
58+
}
59+
);
60+
61+
if (Target.Platform == UnrealTargetPlatform.IOS) {
62+
}
63+
else if(Target.Platform == UnrealTargetPlatform.Android)
64+
{
65+
string PluginPath = Utils.MakePathRelativeTo(ModuleDirectory, Target.RelativeEnginePath);
66+
AdditionalPropertiesForReceipt.Add("AndroidPlugin", Path.Combine(PluginPath, "%PLUGIN_NAME%_APL.xml"));
67+
}
68+
}
69+
}
Lines changed: 140 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,140 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<!-- Copyright (C) Avnish Kirnalli 2024. -->
3+
<!--GearVR plugin additions-->
4+
<root xmlns:android="http://schemas.android.com/apk/res/android">
5+
<!-- init section is always evaluated once per architecture -->
6+
<trace enable="true"/>
7+
<init>
8+
<log text="%PLUGIN_NAME% init"/>
9+
</init>
10+
11+
<androidManifestUpdates>
12+
<addElements tag="application">
13+
14+
<activity android:name="com.avnishgamedev.android.%PLUGIN_NAME%Activity"
15+
android:configChanges="keyboard|keyboardHidden|screenLayout|screenSize|orientation"
16+
android:label="@string/app_name" />
17+
18+
</addElements>
19+
20+
21+
</androidManifestUpdates>
22+
23+
<!-- optional additions to proguard -->
24+
<proguardAdditions>
25+
<insert><![CDATA[
26+
-keepattributes Signature
27+
-dontskipnonpubliclibraryclassmembers
28+
29+
-keepclassmembers class com.epicgames.ue4.GameActivity {
30+
public <methods>;
31+
public <fields>;
32+
}
33+
]]></insert>
34+
</proguardAdditions>
35+
36+
<resourceCopies>
37+
<!-- Copy the generated resource file to be packaged -->
38+
</resourceCopies>
39+
40+
<AARImports>
41+
</AARImports>
42+
43+
<!-- optional additions to the GameActivity imports in GameActivity.java -->
44+
<gameActivityImportAdditions>
45+
<insert>
46+
import java.util.HashSet;
47+
import java.util.Arrays;
48+
import android.text.TextUtils;
49+
import android.graphics.BitmapFactory;
50+
import android.os.Handler;
51+
import android.widget.Toast;
52+
</insert>
53+
</gameActivityImportAdditions>
54+
55+
56+
<!-- optional additions to the GameActivity class in GameActivity.java -->
57+
<gameActivityClassAdditions>
58+
<insert>
59+
<![CDATA[
60+
/**
61+
* Simply shows a toast text
62+
*/
63+
public void AndroidThunkJava_AndroidAPI_ShowToast(String toast) {
64+
runOnUiThread(new Runnable() {
65+
@Override
66+
public void run() {
67+
Toast.makeText(getApplicationContext(), toast, Toast.LENGTH_SHORT).show();
68+
}
69+
});
70+
}
71+
]]>
72+
</insert>
73+
</gameActivityClassAdditions>
74+
75+
<!-- optional additions to GameActivity onCreate metadata reading in GameActivity.java -->
76+
<gameActivityReadMetadataAdditions>
77+
<insert>
78+
79+
</insert>
80+
</gameActivityReadMetadataAdditions>
81+
82+
<!-- optional additions to GameActivity onCreate in GameActivity.java -->
83+
<gameActivityOnCreateAdditions>
84+
<insert>
85+
<![CDATA[
86+
]]>
87+
</insert>
88+
</gameActivityOnCreateAdditions>
89+
90+
<!-- optional additions to GameActivity onDestroy in GameActivity.java -->
91+
<gameActivityOnDestroyAdditions>
92+
<insert>
93+
94+
</insert>
95+
</gameActivityOnDestroyAdditions>
96+
97+
98+
<!-- optional additions to GameActivity onStart in GameActivity.java -->
99+
<gameActivityOnStartAdditions>
100+
<insert>
101+
102+
</insert>
103+
</gameActivityOnStartAdditions>
104+
105+
<!-- optional additions to GameActivity onStop in GameActivity.java -->
106+
<gameActivityOnStopAdditions>
107+
<insert>
108+
109+
</insert>
110+
</gameActivityOnStopAdditions>
111+
112+
113+
<!-- optional additions to GameActivity onPause in GameActivity.java -->
114+
<gameActivityOnPauseAdditions>
115+
<insert>
116+
<![CDATA[
117+
]]>
118+
</insert>
119+
</gameActivityOnPauseAdditions>
120+
121+
122+
<!-- optional additions to GameActivity onResume in GameActivity.java -->
123+
<gameActivityOnResumeAdditions>
124+
<insert>
125+
</insert>
126+
</gameActivityOnResumeAdditions>
127+
128+
129+
<!-- optional additions to GameActivity onActivityResult in GameActivity.java -->
130+
<gameActivityOnActivityResultAdditions>
131+
<insert>
132+
</insert>
133+
</gameActivityOnActivityResultAdditions>
134+
135+
136+
<!-- optional libraries to load in GameActivity.java before libUE4.so -->
137+
<soLoadLibrary>
138+
<!-- need this if plugin enabled and supported architecture, even if not packaged for GearVR -->
139+
</soLoadLibrary>
140+
</root>
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
// Copyright Epic Games, Inc. All Rights Reserved.
2+
3+
#include "%PLUGIN_NAME%.h"
4+
5+
#define LOCTEXT_NAMESPACE "F%PLUGIN_NAME%Module"
6+
7+
void F%PLUGIN_NAME%Module::StartupModule()
8+
{
9+
// This code will execute after your module is loaded into memory; the exact timing is specified in the .uplugin file per-module
10+
11+
}
12+
13+
void F%PLUGIN_NAME%Module::ShutdownModule()
14+
{
15+
// This function may be called during shutdown to clean up your module. For modules that support dynamic reloading,
16+
// we call this function before unloading the module.
17+
18+
}
19+
20+
#undef LOCTEXT_NAMESPACE
21+
22+
IMPLEMENT_MODULE(F%PLUGIN_NAME%Module, %PLUGIN_NAME%)
Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
// Copyright AvnishGameDev 2024.
2+
3+
#include "%PLUGIN_NAME%BPLibrary.h"
4+
#include "%PLUGIN_NAME%.h"
5+
6+
#if PLATFORM_ANDROID
7+
8+
#include "Android/AndroidJNI.h"
9+
#include "Android/AndroidApplication.h"
10+
11+
#define INIT_JAVA_METHOD(name, signature) \
12+
if (JNIEnv* Env = FAndroidApplication::GetJavaEnv(true)) { \
13+
name = FJavaWrapper::FindMethod(Env, FJavaWrapper::GameActivityClassID, #name, signature, false); \
14+
check(name != NULL); \
15+
} else { \
16+
check(0); \
17+
}
18+
19+
#define DECLARE_JAVA_METHOD(name) \
20+
static jmethodID name = NULL;
21+
22+
DECLARE_JAVA_METHOD(AndroidThunkJava_AndroidAPI_ShowToast); // Here goes the name of the method in the Java side
23+
24+
#endif
25+
26+
U%PLUGIN_NAME%BPLibrary::U%PLUGIN_NAME%BPLibrary(const FObjectInitializer& ObjectInitializer)
27+
: Super(ObjectInitializer)
28+
{
29+
#if PLATFORM_ANDROID
30+
// Same here, but we add the Java signature (the type of the parameters is between the parameters, and the return type is added at the end,
31+
// here the return type is V for "void")
32+
// More details here about Java signatures: http://www.rgagnon.com/javadetails/java-0286.html
33+
INIT_JAVA_METHOD(AndroidThunkJava_AndroidAPI_ShowToast, "(Ljava/lang/String;)V");
34+
#endif
35+
}
36+
37+
#if PLATFORM_ANDROID
38+
#undef DECLARE_JAVA_METHOD
39+
#undef INIT_JAVA_METHOD
40+
#endif
41+
42+
void U%PLUGIN_NAME%BPLibrary::Android_ShowToast(const FString& Message)
43+
{
44+
#if PLATFORM_ANDROID
45+
if (JNIEnv* Env = FAndroidApplication::GetJavaEnv(true))
46+
{
47+
// First step, we convert the FString (UE) parameter to a JNI parameter that will hold a String
48+
jstring JavaString = Env->NewStringUTF(TCHAR_TO_UTF8(*Message));
49+
50+
// Then we call the method, with the Java String parameter.
51+
FJavaWrapper::CallVoidMethod(Env, FJavaWrapper::GameActivityThis, AndroidThunkJava_AndroidAPI_ShowToast, JavaString);
52+
}
53+
#endif
54+
}
55+
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
// Copyright Epic Games, Inc. All Rights Reserved.
2+
3+
#pragma once
4+
5+
#include "Modules/ModuleManager.h"
6+
7+
class F%PLUGIN_NAME%Module : public IModuleInterface
8+
{
9+
public:
10+
11+
/** IModuleInterface implementation */
12+
virtual void StartupModule() override;
13+
virtual void ShutdownModule() override;
14+
};
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
// Copyright AvnishGameDev 2024.
2+
3+
#pragma once
4+
5+
#include "Kismet/BlueprintFunctionLibrary.h"
6+
#include "%PLUGIN_NAME%BPLibrary.generated.h"
7+
8+
UCLASS()
9+
class U%PLUGIN_NAME%BPLibrary : public UBlueprintFunctionLibrary
10+
{
11+
GENERATED_UCLASS_BODY()
12+
13+
UFUNCTION(BlueprintCallable, meta = (DisplayName = "Show Android Toast", Keywords = "android template show toast"), Category = "%PLUGIN_NAME%")
14+
static void Android_ShowToast(const FString& Message);
15+
};

GeneratePlugin.bat

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
@echo off
2+
setlocal
3+
4+
REM Check if Python is installed
5+
where python3 > nul 2>&1
6+
if %errorlevel% neq 0 (
7+
echo Python3 is not installed. Please install Python and try again.
8+
pause
9+
exit /b
10+
)
11+
12+
REM Check if required dependencies are installed
13+
python3 -c "import shutil" > nul 2>&1
14+
if %errorlevel% neq 0 (
15+
echo Required Python module 'shutil' is not installed. Please install it using 'pip install shutil' and try again.
16+
pause
17+
exit /b
18+
)
19+
20+
REM Run the Python script
21+
python3 Scripts/GeneratePlugin.py
22+
23+
:end

0 commit comments

Comments
 (0)