1. 配置完成Essientkit Kit 2. 增加 图片保存功能

This commit is contained in:
SnowShow 2025-03-28 15:01:59 +08:00
parent 76a2bc3d97
commit 90f48242bb
14 changed files with 204 additions and 12 deletions

View File

@ -45,6 +45,8 @@ namespace GameLogic
private async UniTaskVoid OnClicktraceSaveLocalImageBtn()
{
Log.Info(m_trackScrollerView.GetCurrentModel().m_data._key);
MobileGalleryPermissionUtility.SaveImageToGallery(m_trackScrollerView.GetCurrentModel().m_data._key,m_trackScrollerView.GetCurrentModel().m_data._texture);
await UniTask.Yield();
}

View File

@ -1,6 +1,8 @@
using System;
using System.IO;
using System.Threading;
using Cysharp.Threading.Tasks;
using Fantasy;
using UnityEngine;
using UnityEngine.Networking;
@ -8,7 +10,7 @@ namespace GameLogic
{
public static class ImageUtility
{
public static async UniTask<Texture2D> UnityWebDownloadTexture2D(string url,CancellationToken token)
public static async UniTask<Texture2D> UnityWebDownloadTexture2D(string url, CancellationToken token)
{
UnityWebRequest request = UnityWebRequestTexture.GetTexture(url);
var operation = await request.SendWebRequest().ToUniTask(cancellationToken: token);
@ -17,8 +19,30 @@ namespace GameLogic
Debug.LogWarning($"Error downloading image: {operation.error}");
return null;
}
Texture2D tex2D = DownloadHandlerTexture.GetContent(request);
tex2D.name = GetImageNameFromUrl(url);
return tex2D;
}
public static string GetImageNameFromUrl(string url)
{
try
{
// 移除可能存在的查询参数(?后面的部分)
int queryIndex = url.IndexOf('?');
if (queryIndex != -1)
url = url.Substring(0, queryIndex);
// 获取URL中的文件名部分
string fileName = Path.GetFileName(url);
return fileName;
}
catch (Exception ex)
{
Debug.LogError($"从URL获取图片名称时出错: {ex.Message}");
return string.Empty;
}
}
}
}

View File

@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: dcd66b7d2eca1114a9910693b0a7b699
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,50 @@
using System;
using TEngine;
using UnityEngine;
using VoxelBusters.CoreLibrary;
using VoxelBusters.EssentialKit;
namespace GameLogic
{
/// <summary>
/// 移动端相册权限工具类
/// </summary>
public static class MobileGalleryPermissionUtility
{
/// <summary>
/// 保存图片到相册
/// </summary>
public static void SaveImageToGallery(string fileName,Texture2D imgTex2D)
{
MediaContentSaveOptions saveOptions = new MediaContentSaveOptions(directoryName: "EintooAR", fileName: $"{fileName}");
MediaServices.SaveMediaContent(imgTex2D.EncodeToPNG(), MimeType.kPNGImage, saveOptions,
(bool result, Error error) =>
{
if (error == null)
{
SHowDialog($"图片保存成功/EintooAR/{imgTex2D.name}");
}
else
{
SHowDialog($"图片保存失败/EintooAR/{imgTex2D.name}");
}
});
}
private static void SHowDialog(string message)
{
AlertDialog dialog = AlertDialog.CreateInstance();
dialog.Message = message;
dialog.Show();
GameModule.Timer.AddTimer((te)=>
{
dialog.Dismiss();
},1f);
}
}
}

View File

@ -0,0 +1,2 @@
fileFormatVersion: 2
guid: 4b26421fec2e3504f824940d1b9aecf1

View File

@ -32,7 +32,10 @@
"GUID:66c2eb417c67ad849907d0769db96dbf",
"GUID:2289059ddf1745b4d80a0f184af99d6b",
"GUID:448b0b55421917e4784a8f2f7449081f",
"GUID:bfb3a80268dac420ab25cd26e09e4475"
"GUID:bfb3a80268dac420ab25cd26e09e4475",
"GUID:46ee17e5fcc7f436f9df354a1efda6a4",
"GUID:77cdc4b9a869f4caa8b2e41e3b794af0",
"GUID:f712e8ae9bab041c2a043390d1a751a1"
],
"includePlatforms": [],
"excludePlatforms": [],

View File

@ -1,6 +1,10 @@
org.gradle.jvmargs=-Xmx**JVM_HEAP_SIZE**M
org.gradle.parallel=true
unityStreamingAssets=**STREAMING_ASSETS**
# Android Resolver Properties Start
android.useAndroidX=true
android.enableJetifier=true
# Android Resolver Properties End
**ADDITIONAL_PROPERTIES**
android.overridePathCheck=true
android.useAndroidX=true

View File

@ -5,8 +5,32 @@ apply from: '../shared/keepUnitySymbols.gradle'
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation 'androidx.appcompat:appcompat:1.2.0'
// Android Resolver Dependencies Start
implementation 'androidx.activity:activity:1.6.0+' // Assets/Plugins/VoxelBusters/EssentialKit/Essentials/Editor/CrossPlatformEssentialKitDependencies.xml:19
implementation 'androidx.appcompat:appcompat:1.5.0+' // Assets/Plugins/VoxelBusters/EssentialKit/Essentials/Editor/CrossPlatformEssentialKitDependencies.xml:28
implementation 'androidx.appcompat:appcompat-resources:1.5.0+' // Assets/Plugins/VoxelBusters/EssentialKit/Essentials/Editor/CrossPlatformEssentialKitDependencies.xml:30
implementation 'androidx.core:core:1.7.0+' // Assets/Plugins/VoxelBusters/EssentialKit/Essentials/Editor/CrossPlatformEssentialKitDependencies.xml:25
implementation 'androidx.exifinterface:exifinterface:1.3.0+' // Assets/Plugins/VoxelBusters/EssentialKit/Essentials/Editor/CrossPlatformEssentialKitDependencies.xml:17
implementation 'com.android.billingclient:billing:7.1.1+' // Assets/Plugins/VoxelBusters/EssentialKit/Essentials/Editor/CrossPlatformEssentialKitDependencies.xml:9
implementation 'com.google.android.gms:play-services-games-v2:20.0.0+' // Assets/Plugins/VoxelBusters/EssentialKit/Essentials/Editor/CrossPlatformEssentialKitDependencies.xml:12
implementation 'com.google.android.play:app-update:2.1.0' // Assets/Plugins/VoxelBusters/EssentialKit/Essentials/Editor/CrossPlatformEssentialKitDependencies.xml:6
implementation 'com.google.android.play:review:2.0.1+' // Assets/Plugins/VoxelBusters/EssentialKit/Essentials/Editor/CrossPlatformEssentialKitDependencies.xml:22
implementation 'com.google.firebase:firebase-messaging:23.1.1+' // Assets/Plugins/VoxelBusters/EssentialKit/Essentials/Editor/CrossPlatformEssentialKitDependencies.xml:15
// Android Resolver Dependencies End
**DEPS**}
// Android Resolver Exclusions Start
android {
packagingOptions {
exclude ('/lib/armeabi/*' + '*')
exclude ('/lib/armeabi-v7a/*' + '*')
exclude ('/lib/mips/*' + '*')
exclude ('/lib/mips64/*' + '*')
exclude ('/lib/x86/*' + '*')
exclude ('/lib/x86_64/*' + '*')
}
}
// Android Resolver Exclusions End
android {
namespace "com.unity3d.player"
ndkPath "**NDKPATH**"

View File

@ -0,0 +1,27 @@
pluginManagement {
repositories {
**ARTIFACTORYREPOSITORY**
gradlePluginPortal()
google()
mavenCentral()
}
}
include ':launcher', ':unityLibrary'
**INCLUDES**
dependencyResolutionManagement {
repositoriesMode.set(RepositoriesMode.PREFER_SETTINGS)
repositories {
**ARTIFACTORYREPOSITORY**
google()
mavenCentral()
// Android Resolver Repos Start
def unityProjectPath = $/file:///**DIR_UNITYPROJECT**/$.replace("\\", "/")
mavenLocal()
// Android Resolver Repos End
flatDir {
dirs "${project(':unityLibrary').projectDir}/libs"
}
}
}

View File

@ -0,0 +1,7 @@
fileFormatVersion: 2
guid: ba42dad9f52e9374f9f332e777d31668
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -15,42 +15,49 @@ MonoBehaviour:
m_applicationSettings:
m_logLevel: 3
m_appStoreIds:
m_ios:
m_ios: 17380953476
m_tvos:
m_android:
m_android: com.Eintoo.EintooAR
m_usagePermissionSettings:
m_addressBookUsagePermission:
m_description: $productName uses contacts.
m_description: "This permission allows the app to access your contacts to
help you easily find and interact with your friends. (\u6B64\u6743\u9650\u5141\u8BB8\u5E94\u7528\u8BBF\u95EE\u60A8\u7684\u901A\u8BAF\u5F55\uFF0C\u4EE5\u4FBF\u5E2E\u52A9\u60A8\u8F7B\u677E\u627E\u5230\u670B\u53CB\u5E76\u4E0E\u4ED6\u4EEC\u4E92\u52A8\u3002)"
m_descriptionOverrides:
m_ios:
m_tvos:
m_android:
m_cameraUsagePermission:
m_description: $productName uses camera.
m_description: "This permission allows the app to use your device's camera
to take photos or videos. (\u6B64\u6743\u9650\u5141\u8BB8\u5E94\u7528\u4F7F\u7528\u60A8\u7684\u8BBE\u5907\u76F8\u673A\u62CD\u6444\u7167\u7247\u6216\u89C6\u9891\u3002)"
m_descriptionOverrides:
m_ios:
m_tvos:
m_android:
m_galleryUsagePermission:
m_description: $productName uses gallery.
m_description: This permission allows the app to access your gallery to select
and upload photos or videos.
m_descriptionOverrides:
m_ios:
m_tvos:
m_android:
m_galleryWritePermission:
m_description: $productName wants to write to gallery.
m_description: "This permission allows the app to save photos or videos to
your gallery. (\u6B64\u6743\u9650\u5141\u8BB8\u5E94\u7528\u5C06\u7167\u7247\u6216\u89C6\u9891\u4FDD\u5B58\u5230\u60A8\u7684\u56FE\u5E93\u4E2D\u3002)"
m_descriptionOverrides:
m_ios:
m_tvos:
m_android:
m_locationWhenInUsePermission:
m_description: $productName would like to user your location.
m_description: "This permission allows the app to access your location while
you are using the app to provide location-based services such as maps or
local content. (\u6B64\u6743\u9650\u5141\u8BB8\u5E94\u7528\u5728\u4F7F\u7528\u8FC7\u7A0B\u4E2D\u8BBF\u95EE\u60A8\u7684\u4F4D\u7F6E\uFF0C\u4EE5\u4FBF\u63D0\u4F9B\u57FA\u4E8E\u4F4D\u7F6E\u7684\u670D\u52A1\uFF0C\u5982\u5730\u56FE\u6216\u672C\u5730\u5185\u5BB9\u3002)"
m_descriptionOverrides:
m_ios:
m_tvos:
m_android:
m_accessFriendsPermission:
m_description: $productName wants to access friends.
m_description: "This permission allows the app to access your friends' information
to enable social interactions and content sharing. (\u6B64\u6743\u9650\u5141\u8BB8\u5E94\u7528\u8BBF\u95EE\u60A8\u7684\u597D\u53CB\u4FE1\u606F\uFF0C\u4EE5\u4FBF\u5B9E\u73B0\u793E\u4EA4\u4E92\u52A8\u548C\u5185\u5BB9\u5171\u4EAB\u3002)"
m_descriptionOverrides:
m_ios:
m_tvos:

View File

@ -0,0 +1,32 @@
<dependencies>
<packages>
<package>androidx.activity:activity:1.6.0+</package>
<package>androidx.appcompat:appcompat:1.5.0+</package>
<package>androidx.appcompat:appcompat-resources:1.5.0+</package>
<package>androidx.core:core:1.7.0+</package>
<package>androidx.exifinterface:exifinterface:1.3.0+</package>
<package>com.android.billingclient:billing:7.1.1+</package>
<package>com.google.android.gms:play-services-games-v2:20.0.0+</package>
<package>com.google.android.play:app-update:2.1.0</package>
<package>com.google.android.play:review:2.0.1+</package>
<package>com.google.firebase:firebase-messaging:23.1.1+</package>
</packages>
<files />
<settings>
<setting name="androidAbis" value="arm64-v8a" />
<setting name="bundleId" value="com.Eintoo.EintooAR" />
<setting name="explodeAars" value="True" />
<setting name="gradleBuildEnabled" value="True" />
<setting name="gradlePropertiesTemplateEnabled" value="True" />
<setting name="gradleTemplateEnabled" value="True" />
<setting name="installAndroidPackages" value="True" />
<setting name="localMavenRepoDir" value="Assets/GeneratedLocalRepo" />
<setting name="packageDir" value="Assets/Plugins/Android" />
<setting name="patchAndroidManifest" value="True" />
<setting name="patchMainTemplateGradle" value="True" />
<setting name="projectExportEnabled" value="False" />
<setting name="useFullCustomMavenRepoPathWhenExport" value="True" />
<setting name="useFullCustomMavenRepoPathWhenNotExport" value="False" />
<setting name="useJetifier" value="True" />
</settings>
</dependencies>

View File

@ -3,4 +3,6 @@
<projectSetting name="com.google.external-dependency-managerAnalyticsCookie" value="a7d83c3a40764383a2ef6a99caee1414" />
<projectSetting name="com.google.external-dependency-managerAnalyticsEnabled" value="True" />
<projectSetting name="Google.VersionHandler.VerboseLoggingEnabled" value="False" />
<projectSetting name="GooglePlayServices.PromptBeforeAutoResolution" value="False" />
<projectSetting name="GooglePlayServices.UseJetifier" value="True" />
</projectSettings>

View File

@ -140,7 +140,7 @@ PlayerSettings:
loadStoreDebugModeEnabled: 0
visionOSBundleVersion: 1.0
tvOSBundleVersion: 1.0
bundleVersion: 1.05
bundleVersion: 0.1.5
preloadedAssets:
- {fileID: -944628639613478452, guid: c271117232a153d46826a63d58f2ad40, type: 3}
metroInputSource: 0
@ -783,7 +783,7 @@ PlayerSettings:
webGLCloseOnQuit: 0
webWasm2023: 0
scriptingDefineSymbols:
Android: ENABLE_LOG;TextMeshPro;ODIN_VALIDATOR;ODIN_VALIDATOR_3_1;ODIN_INSPECTOR;ODIN_INSPECTOR_3;ODIN_INSPECTOR_3_1;SLATE;ES3_TMPRO;ES3_UGUI;ATMOSPHERIC_HEIGHT_FOG;ENVIRO_3;DOTWEEN;UNITY_POST_PROCESSING_STACK_V2;NODECANVAS;ENABLE_HYBRIDCLR;ENABLE_VOXELBUSTERS_ESSENTIAL_KIT
Android: ENABLE_LOG;TextMeshPro;ODIN_VALIDATOR;ODIN_VALIDATOR_3_1;ODIN_INSPECTOR;ODIN_INSPECTOR_3;ODIN_INSPECTOR_3_1;SLATE;ES3_TMPRO;ES3_UGUI;ATMOSPHERIC_HEIGHT_FOG;ENVIRO_3;DOTWEEN;UNITY_POST_PROCESSING_STACK_V2;NODECANVAS;ENABLE_HYBRIDCLR;ENABLE_VOXELBUSTERS_ESSENTIAL_KIT;ODIN_VALIDATOR_3_2;ODIN_VALIDATOR_3_3;ODIN_INSPECTOR_3_2;ODIN_INSPECTOR_3_3
EmbeddedLinux: TextMeshPro;ES3_TMPRO;ES3_UGUI;ENVIRO_3;DOTWEEN;UNITY_POST_PROCESSING_STACK_V2
GameCoreScarlett: DOTWEEN
GameCoreXboxOne: TextMeshPro;ENVIRO_3;DOTWEEN;UNITY_POST_PROCESSING_STACK_V2