From 0764061d8f1155e4376dbba922d4281553213f58 Mon Sep 17 00:00:00 2001 From: hevinci Date: Thu, 25 May 2023 16:38:33 +0800 Subject: [PATCH] update space shooter --- .../GameScript/Editor/Encryption.cs | 14 ----- .../PatchLogic/FsmNode/FsmInitialize.cs | 2 +- .../StreamingAssetsHelper/Editor.meta | 8 --- .../StreamingAssetsHelperEditor.cs.meta | 11 ---- .../StreamingAssetsHelper/Runtime.meta | 8 --- .../Runtime/StreamingAssetsHelper.cs | 57 ------------------ ...lperEditor.cs => StreamingAssetsHelper.cs} | 60 ++++++++++++++++++- .../StreamingAssetsHelper.cs.meta | 0 8 files changed, 60 insertions(+), 100 deletions(-) delete mode 100644 Assets/YooAsset/Samples~/Space Shooter/ThirdParty/StreamingAssetsHelper/Editor.meta delete mode 100644 Assets/YooAsset/Samples~/Space Shooter/ThirdParty/StreamingAssetsHelper/Editor/StreamingAssetsHelperEditor.cs.meta delete mode 100644 Assets/YooAsset/Samples~/Space Shooter/ThirdParty/StreamingAssetsHelper/Runtime.meta delete mode 100644 Assets/YooAsset/Samples~/Space Shooter/ThirdParty/StreamingAssetsHelper/Runtime/StreamingAssetsHelper.cs rename Assets/YooAsset/Samples~/Space Shooter/ThirdParty/StreamingAssetsHelper/{Editor/StreamingAssetsHelperEditor.cs => StreamingAssetsHelper.cs} (57%) rename Assets/YooAsset/Samples~/Space Shooter/ThirdParty/StreamingAssetsHelper/{Runtime => }/StreamingAssetsHelper.cs.meta (100%) diff --git a/Assets/YooAsset/Samples~/Space Shooter/GameScript/Editor/Encryption.cs b/Assets/YooAsset/Samples~/Space Shooter/GameScript/Editor/Encryption.cs index 1e3ca41..43d5106 100644 --- a/Assets/YooAsset/Samples~/Space Shooter/GameScript/Editor/Encryption.cs +++ b/Assets/YooAsset/Samples~/Space Shooter/GameScript/Editor/Encryption.cs @@ -47,20 +47,6 @@ public class FileStreamEncryption : IEncryptionServices return result; } - // LoadFromFileOffset - if (fileInfo.BundleName.Contains("_gameres_uiimage")) - { - var fileData = File.ReadAllBytes(fileInfo.FilePath); - int offset = 32; - var temper = new byte[fileData.Length + offset]; - Buffer.BlockCopy(fileData, 0, temper, offset, fileData.Length); - - EncryptResult result = new EncryptResult(); - result.LoadMethod = EBundleLoadMethod.LoadFromFileOffset; - result.EncryptedData = temper; - return result; - } - // Normal { EncryptResult result = new EncryptResult(); diff --git a/Assets/YooAsset/Samples~/Space Shooter/GameScript/Runtime/PatchLogic/FsmNode/FsmInitialize.cs b/Assets/YooAsset/Samples~/Space Shooter/GameScript/Runtime/PatchLogic/FsmNode/FsmInitialize.cs index 69640c2..642577d 100644 --- a/Assets/YooAsset/Samples~/Space Shooter/GameScript/Runtime/PatchLogic/FsmNode/FsmInitialize.cs +++ b/Assets/YooAsset/Samples~/Space Shooter/GameScript/Runtime/PatchLogic/FsmNode/FsmInitialize.cs @@ -74,7 +74,7 @@ internal class FsmInitialize : IStateNode } yield return initializationOperation; - if (package.InitializeStatus == EOperationStatus.Succeed) + if (initializationOperation.Status == EOperationStatus.Succeed) { _machine.ChangeState(); } diff --git a/Assets/YooAsset/Samples~/Space Shooter/ThirdParty/StreamingAssetsHelper/Editor.meta b/Assets/YooAsset/Samples~/Space Shooter/ThirdParty/StreamingAssetsHelper/Editor.meta deleted file mode 100644 index c53ee20..0000000 --- a/Assets/YooAsset/Samples~/Space Shooter/ThirdParty/StreamingAssetsHelper/Editor.meta +++ /dev/null @@ -1,8 +0,0 @@ -fileFormatVersion: 2 -guid: 4b1fa97e8bb8c5c46ad030b9554e1b5c -folderAsset: yes -DefaultImporter: - externalObjects: {} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/YooAsset/Samples~/Space Shooter/ThirdParty/StreamingAssetsHelper/Editor/StreamingAssetsHelperEditor.cs.meta b/Assets/YooAsset/Samples~/Space Shooter/ThirdParty/StreamingAssetsHelper/Editor/StreamingAssetsHelperEditor.cs.meta deleted file mode 100644 index 8c2390f..0000000 --- a/Assets/YooAsset/Samples~/Space Shooter/ThirdParty/StreamingAssetsHelper/Editor/StreamingAssetsHelperEditor.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: 7bfd05221983858429246096617dff1d -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/YooAsset/Samples~/Space Shooter/ThirdParty/StreamingAssetsHelper/Runtime.meta b/Assets/YooAsset/Samples~/Space Shooter/ThirdParty/StreamingAssetsHelper/Runtime.meta deleted file mode 100644 index ac0c679..0000000 --- a/Assets/YooAsset/Samples~/Space Shooter/ThirdParty/StreamingAssetsHelper/Runtime.meta +++ /dev/null @@ -1,8 +0,0 @@ -fileFormatVersion: 2 -guid: b19a7385dee2d0141901167dbfda9300 -folderAsset: yes -DefaultImporter: - externalObjects: {} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/YooAsset/Samples~/Space Shooter/ThirdParty/StreamingAssetsHelper/Runtime/StreamingAssetsHelper.cs b/Assets/YooAsset/Samples~/Space Shooter/ThirdParty/StreamingAssetsHelper/Runtime/StreamingAssetsHelper.cs deleted file mode 100644 index 026f597..0000000 --- a/Assets/YooAsset/Samples~/Space Shooter/ThirdParty/StreamingAssetsHelper/Runtime/StreamingAssetsHelper.cs +++ /dev/null @@ -1,57 +0,0 @@ -//------------------------------------- -// 作者:Stark -//------------------------------------- -using System.Collections.Generic; -using UnityEngine; - -public sealed class StreamingAssetsHelper -{ - private static readonly Dictionary _cacheData = new Dictionary(1000); - -#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("currentActivity"); - return _currentActivity; - } - } - - /// - /// 利用安卓原生接口查询内置文件是否存在 - /// - public static bool FileExists(string filePath) - { - if (_cacheData.TryGetValue(filePath, out bool result) == false) - { - result = CurrentActivity.Call("CheckAssetExist", filePath); - _cacheData.Add(filePath, result); - } - return result; - } -#else - public static bool FileExists(string filePath) - { - if (_cacheData.TryGetValue(filePath, out bool result) == false) - { - result = System.IO.File.Exists(System.IO.Path.Combine(Application.streamingAssetsPath, filePath)); - _cacheData.Add(filePath, result); - } - return result; - } -#endif -} \ No newline at end of file diff --git a/Assets/YooAsset/Samples~/Space Shooter/ThirdParty/StreamingAssetsHelper/Editor/StreamingAssetsHelperEditor.cs b/Assets/YooAsset/Samples~/Space Shooter/ThirdParty/StreamingAssetsHelper/StreamingAssetsHelper.cs similarity index 57% rename from Assets/YooAsset/Samples~/Space Shooter/ThirdParty/StreamingAssetsHelper/Editor/StreamingAssetsHelperEditor.cs rename to Assets/YooAsset/Samples~/Space Shooter/ThirdParty/StreamingAssetsHelper/StreamingAssetsHelper.cs index c3f9a84..1943007 100644 --- a/Assets/YooAsset/Samples~/Space Shooter/ThirdParty/StreamingAssetsHelper/Editor/StreamingAssetsHelperEditor.cs +++ b/Assets/YooAsset/Samples~/Space Shooter/ThirdParty/StreamingAssetsHelper/StreamingAssetsHelper.cs @@ -1,6 +1,64 @@ //------------------------------------- // 作者:Stark //------------------------------------- +using System.Collections.Generic; +using UnityEngine; + +/// +/// StreamingAssets目录下资源查询帮助类 +/// +public sealed class StreamingAssetsHelper +{ + private static readonly Dictionary _cacheData = new Dictionary(1000); + +#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("currentActivity"); + return _currentActivity; + } + } + + /// + /// 利用安卓原生接口查询内置文件是否存在 + /// + public static bool FileExists(string filePath) + { + if (_cacheData.TryGetValue(filePath, out bool result) == false) + { + result = CurrentActivity.Call("CheckAssetExist", filePath); + _cacheData.Add(filePath, result); + } + return result; + } +#else + public static bool FileExists(string filePath) + { + if (_cacheData.TryGetValue(filePath, out bool result) == false) + { + result = System.IO.File.Exists(System.IO.Path.Combine(Application.streamingAssetsPath, filePath)); + _cacheData.Add(filePath, result); + } + return result; + } +#endif +} + #if UNITY_ANDROID && UNITY_EDITOR /// @@ -69,7 +127,7 @@ public boolean CheckAssetExist(String filePath) } catch(java.io.IOException e) { - e.printStackTrace(); + //e.printStackTrace(); } return false; } diff --git a/Assets/YooAsset/Samples~/Space Shooter/ThirdParty/StreamingAssetsHelper/Runtime/StreamingAssetsHelper.cs.meta b/Assets/YooAsset/Samples~/Space Shooter/ThirdParty/StreamingAssetsHelper/StreamingAssetsHelper.cs.meta similarity index 100% rename from Assets/YooAsset/Samples~/Space Shooter/ThirdParty/StreamingAssetsHelper/Runtime/StreamingAssetsHelper.cs.meta rename to Assets/YooAsset/Samples~/Space Shooter/ThirdParty/StreamingAssetsHelper/StreamingAssetsHelper.cs.meta