update sapce shooter
移除了BetterStreamingAssets插件,并使用安卓原生接口类代替。
This commit is contained in:
+8
@@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 4b1fa97e8bb8c5c46ad030b9554e1b5c
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
+39
@@ -0,0 +1,39 @@
|
||||
//-------------------------------------
|
||||
// 作者:Stark
|
||||
//-------------------------------------
|
||||
|
||||
/// <summary>
|
||||
/// 为Github对开发者的友好,采用自动补充UnityPlayerActivity.java文件的通用姿势满足各个开发者
|
||||
/// </summary>
|
||||
internal class AndroidPost : UnityEditor.Android.IPostGenerateGradleAndroidProject
|
||||
{
|
||||
public int callbackOrder => 99;
|
||||
public void OnPostGenerateGradleAndroidProject(string path)
|
||||
{
|
||||
path = path.Replace("\\", "/");
|
||||
string untityActivityFilePath = $"{path}/src/main/java/com/unity3d/player/UnityPlayerActivity.java";
|
||||
var readContent = System.IO.File.ReadAllLines(untityActivityFilePath);
|
||||
string postContent = " //auto-gen-function\n" +
|
||||
" public boolean CheckAssetExist(String filePath){\n" +
|
||||
" android.content.res.AssetManager assetManager = getAssets();\n" +
|
||||
" java.io.InputStream inputStream = null;\n" +
|
||||
" try {\n" +
|
||||
" inputStream = assetManager.open(filePath);\n" +
|
||||
" if(null != inputStream)return true;\n" +
|
||||
" }catch(java.io.IOException e) {\n" +
|
||||
" e.printStackTrace();\n" +
|
||||
" }finally{\n" +
|
||||
" try {\n" +
|
||||
" inputStream.close();\n" +
|
||||
" } catch (java.io.IOException e) {\n" +
|
||||
" e.printStackTrace();\n" +
|
||||
" }\n" +
|
||||
" }\n" +
|
||||
" return false;\n" +
|
||||
" }\n" +
|
||||
"}";
|
||||
if (!readContent[readContent.Length - 18].Contains("CheckAssetExist"))
|
||||
readContent[readContent.Length - 1] = postContent;
|
||||
System.IO.File.WriteAllLines(untityActivityFilePath, readContent);
|
||||
}
|
||||
}
|
||||
+11
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 7bfd05221983858429246096617dff1d
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
+8
@@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: b19a7385dee2d0141901167dbfda9300
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
+44
@@ -0,0 +1,44 @@
|
||||
//-------------------------------------
|
||||
// 作者:Stark
|
||||
//-------------------------------------
|
||||
using UnityEngine;
|
||||
|
||||
public sealed class StreamingAssetsHelper
|
||||
{
|
||||
#if UNITY_ANDROID && !UNITY_EDITOR
|
||||
private static AndroidJavaClass _unityPlayerClass;
|
||||
public static AndroidJavaClass UnityPlayerClass
|
||||
{
|
||||
get
|
||||
{
|
||||
if (_unityPlayerClass == null)
|
||||
_unityPlayerClass = new UnityEngine.AndroidJavaClass("com.unity3d.player.UnityPlayer");
|
||||
return _unityPlayerClass;
|
||||
}
|
||||
}
|
||||
|
||||
private static AndroidJavaObject _currentActivity;
|
||||
public static AndroidJavaObject CurrentActivity
|
||||
{
|
||||
get
|
||||
{
|
||||
if (_currentActivity == null)
|
||||
_currentActivity = UnityPlayerClass.GetStatic<AndroidJavaObject>("currentActivity");
|
||||
return _currentActivity;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 利用安卓原生接口查询内置文件是否存在
|
||||
/// </summary>
|
||||
public static bool FileExists(string filePath)
|
||||
{
|
||||
return CurrentActivity.Call<bool>("CheckAssetExist", filePath);
|
||||
}
|
||||
#else
|
||||
public static bool FileExists(string filePath)
|
||||
{
|
||||
return System.IO.File.Exists(System.IO.Path.Combine(Application.streamingAssetsPath, filePath));
|
||||
}
|
||||
#endif
|
||||
}
|
||||
+11
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 358145d67e230b34883002b08b23cba3
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
Reference in New Issue
Block a user