diff --git a/Assets/Scripts/InteractionEngine/CommunicationEvents.cs b/Assets/Scripts/InteractionEngine/CommunicationEvents.cs index 77d5fa1134a57a26a30e0e08762f79bf0f357db9..a48095f4480779249ea354de98979f195a7475b3 100644 --- a/Assets/Scripts/InteractionEngine/CommunicationEvents.cs +++ b/Assets/Scripts/InteractionEngine/CommunicationEvents.cs @@ -77,6 +77,8 @@ public enum OperationSystem { Windows = 0, Android = 1, + iOS =2, + WindowsStoreApps = 3, } public static bool CursorVisDefault = true; //Script. @@ -106,6 +108,21 @@ public static string CreateHierarchiePath(List<Directories> hierarchie, string p return System.IO.Path.Combine(prefix, postfix); } + + public static string Get_DataPath() + { + + string Target_StreamToDataPath_writeable = Path.Combine(Application.persistentDataPath, "DataPath_writeable"); + string dataPath = Opsys switch + { + OperationSystem.Android => Target_StreamToDataPath_writeable, + OperationSystem.Windows or _ => Application.dataPath, + }; + if(Application.isEditor) { dataPath = Target_StreamToDataPath_writeable; } + + return dataPath; + } + // TODO! avoid tree traversel with name public static string CreatePathToFile(out bool file_exists, string name, string format = null, List<Directories> hierarchie = null, bool use_install_folder = false) { @@ -120,14 +137,11 @@ public static string CreatePathToFile(out bool file_exists, string name, string break; } - string path = Opsys switch + string path = Application.persistentDataPath; + if (use_install_folder) { - OperationSystem.Android => Application.persistentDataPath, - OperationSystem.Windows or _ => use_install_folder ? Application.dataPath : Application.persistentDataPath, - }; - - string Target_StreamToDataPath_UnityEditor = "UnityEditor"; - if (Application.isEditor && use_install_folder) { path = Path.Combine(Application.persistentDataPath, Target_StreamToDataPath_UnityEditor); } + path=Get_DataPath(); + } if (hierarchie != null) { diff --git a/Assets/Scripts/Loading/StreamingAssetLoader.cs b/Assets/Scripts/Loading/StreamingAssetLoader.cs index f5f0f6320bcb45a9cc6e5dc4ab2d09ce678ec283..ac80d957e30c30bec32c5648ce17bdb398e2941d 100644 --- a/Assets/Scripts/Loading/StreamingAssetLoader.cs +++ b/Assets/Scripts/Loading/StreamingAssetLoader.cs @@ -16,7 +16,7 @@ public static class StreamingAssetLoader public static string StreamToPersistentDataPath_Folder_Cookie = "cookie_persistentDataPath.txt"; public static string StreamToDataPath_withHandler_Folder = "StreamToDataPath_withHandler"; public static string PersDataPathToPlayerSaveGame_Path = "stages/SaveGames"; - public static string Target_StreamToDataPath_UnityEditor = "UnityEditor"; + public static string Target_StreamToDataPath_UnityEditor = "DataPath_writeable"; //Config @@ -38,6 +38,7 @@ public static void ResetPlayerConfig() NetworkJSON_Load(); } + public static bool ReloadManualy_StreamToPers() { ResetPlayerConfig(); @@ -52,7 +53,7 @@ public static bool ReloadManualy_StreamToPers() public static bool ReloadManualy_StreamToDataPath() { string sourcePath = Path.Combine(Application.streamingAssetsPath, StreamToDataPath_Folder); - string targetFolder = Application.dataPath; + string targetFolder = Get_DataPath(); RereadFileWithUnityWebRequest(sourcePath, "", StreamToDataPath_Folder_Cookie, targetFolder); NetworkJSON_Load(); @@ -61,7 +62,6 @@ public static bool ReloadManualy_StreamToDataPath() } public static bool ReloadManualy_StreamToDataPathWithHandler(string TargetDir_1) { - string sourcePath = Path.Combine(Application.streamingAssetsPath, StreamToDataPath_withHandler_Folder); string targetFolder_dpwh = TargetDir_1; //Debug.Log(targetFolder_dpwh); @@ -94,7 +94,7 @@ public static bool checkPersistentDataPath() } public static bool checkDataPath() { - return checkFileExistence(Application.dataPath, StreamToDataPath_Folder_Cookie); + return checkFileExistence(Get_DataPath(), StreamToDataPath_Folder_Cookie); } public static bool checkFileExistence(string sourcepath, string filename) { @@ -231,10 +231,10 @@ public static void RereadFiles_DataPath() { //Debug.Log("Reread_DataPath"); string rootPath = Path.Combine(Application.streamingAssetsPath, StreamToDataPath_Folder); - string targetFolder = Application.dataPath; + string targetFolder = Application.dataPath; if (Application.isEditor) { - targetFolder = Path.Combine(Application.persistentDataPath, Target_StreamToDataPath_UnityEditor); + Get_DataPath(); } RereadFiles_DataPath_withHandler(); @@ -248,22 +248,10 @@ public static void RereadFiles_DataPath() public static void RereadFiles_DataPath_withHandler() { string rootPath = Path.Combine(Application.streamingAssetsPath, StreamToDataPath_withHandler_Folder); - string targetFolder_wh = Application.dataPath; - - //Debug.Log(CommunicationEvents.Opsys); - if (CommunicationEvents.Opsys == OperationSystem.Android) - { - targetFolder_wh = Application.persistentDataPath; - //Debug.Log(OperationSystem.Android + " " + targetFolder_wh); - } - if (Application.isEditor) - { - targetFolder_wh = Path.Combine(Application.persistentDataPath, Target_StreamToDataPath_UnityEditor); - } + string targetFolder_wh = Get_DataPath(); if (!ReReadFiles(rootPath, targetFolder_wh)) - { - //Debug.Log( " 2 " + targetFolder_wh); + { ReloadManualy_StreamToDataPathWithHandler(targetFolder_wh); } } @@ -518,7 +506,7 @@ public static void RereadFileUWR(string pathfolders, string fileName, ID_toPath { //copies and unpacks file from apk to persistentDataPath where it can be accessed string destinationPath; - if (toMainpath == ID_toPath.DataPath && CommunicationEvents.Opsys != OperationSystem.Android) { destinationPath = Path.Combine(Application.dataPath, destpathf); } + if (toMainpath == ID_toPath.DataPath && CommunicationEvents.Opsys != OperationSystem.Android) { destinationPath = Path.Combine(Get_DataPath(), destpathf); } else { destinationPath = Path.Combine(Application.persistentDataPath, destpathf); diff --git a/Assets/Scripts/UI/NetwMenu/StartMenu_mobile.cs b/Assets/Scripts/UI/NetwMenu/StartMenu_mobile.cs index c27ffc8c22cf2a0255dbfb4ea81feb776c7b5924..c844693e5a414033e8be2d232be6935e7e9de6fe 100644 --- a/Assets/Scripts/UI/NetwMenu/StartMenu_mobile.cs +++ b/Assets/Scripts/UI/NetwMenu/StartMenu_mobile.cs @@ -118,9 +118,10 @@ void start2_CheckOS_CheckConfig() //Debug.Log("EndAdaption"); NetworkJSON_Load(); - if (!checkDataPath() )//|| true) - Debug.Log("Todo: Pr�fen auf Bugs bzl DataPath"); - //if (!checkDataPath()) + if (!checkDataPath() && false) + Debug.Log("Todo: Pr�fen auf Bugs bzl DataPath"); + + if (!checkDataPath() || true) { ResetDataPath(); //Debug.Log("Info: DataPath Resetted"); @@ -185,6 +186,16 @@ void checkOS2() CommunicationEvents.Opsys = OperationSystem.Windows; return; } + if (Application.platform == RuntimePlatform.OSXPlayer) + { + CommunicationEvents.Opsys = OperationSystem.iOS; + return; + } + if (Application.platform == RuntimePlatform.WindowsPlayer) + { + CommunicationEvents.Opsys = OperationSystem.WindowsStoreApps; + return; + } Debug.Log("Detecting OS: " + Application.platform + " -> " + CommunicationEvents.Opsys); //Default: diff --git a/Assets/Scripts/UI/NetwMenu/SystemOptionsMenu_mobile.cs b/Assets/Scripts/UI/NetwMenu/SystemOptionsMenu_mobile.cs index db5a5b27edc2b2456a7ca6f906fa4b6931f08060..a650b4522e2dc2f23ddd926ed66bc193e0f4272a 100644 --- a/Assets/Scripts/UI/NetwMenu/SystemOptionsMenu_mobile.cs +++ b/Assets/Scripts/UI/NetwMenu/SystemOptionsMenu_mobile.cs @@ -98,7 +98,7 @@ void UpdateUI_6() { case OperationSystem.Windows: - Opsys_ButtonT.GetComponent<Text>().text = "Windows optimized"; + Opsys_ButtonT.GetComponent<Text>().text = "Windows/Desktop optimized"; Opsys_ButtonUT.GetComponent<Text>().text = "Press for changing optimzation"; setMouse(); break; @@ -106,11 +106,12 @@ void UpdateUI_6() case OperationSystem.Android: - Opsys_ButtonT.GetComponent<Text>().text = "Android optimized: No mouse"; + Opsys_ButtonT.GetComponent<Text>().text = "Android/Mobile optimized: No mouse, No Datapath"; Opsys_ButtonUT.GetComponent<Text>().text = "Press for changing optimzation"; setMouse(); break; + default: Opsys_ButtonT.GetComponent<Text>().text = "Not optimized"; diff --git a/Assets/StreamingAssets/README_StreamingAssets.md b/Assets/StreamingAssets/README_StreamingAssets.md index 043f859a1619185176ee40527cfa39329b607704..3325745a1d26888a2e2212bce1dd9fea3d6a5523 100644 --- a/Assets/StreamingAssets/README_StreamingAssets.md +++ b/Assets/StreamingAssets/README_StreamingAssets.md @@ -4,10 +4,12 @@ For OperatingSystem Android: please register all Files in StreamingAssetLoader! ## StreamToDataPath: All files and subfolders will be copied to DataPath. +Will be triggered on each start of the game. Exception: Files with "meta" in the name. ## StreamToPersistentDataPath: All files and subfolders will be copied to PersistentDataPath. +Will be triggered on first time installing the game or with the corresponding restart buttons. Exception: Files with "meta" in the name. diff --git a/Assets/StreamingAssets/StreamToDataPath/cookie_dataPath.txt b/Assets/StreamingAssets/StreamToDataPath/cookie_dataPath.txt index 56a6051ca2b02b04ef92d5150c9ef600403cb1de..5b7e4b1a51f09443d62d33540b8a36afa11d6204 100644 --- a/Assets/StreamingAssets/StreamToDataPath/cookie_dataPath.txt +++ b/Assets/StreamingAssets/StreamToDataPath/cookie_dataPath.txt @@ -1 +1,5 @@ -1 \ No newline at end of file +DataPath: + +Its location is the installation folder. +Files in this directory are not persistent. +They will be overwritten on each start of the game. diff --git a/Assets/StreamingAssets/StreamToPersistentDataPath/cookie_persistentDataPath.txt b/Assets/StreamingAssets/StreamToPersistentDataPath/cookie_persistentDataPath.txt index 56a6051ca2b02b04ef92d5150c9ef600403cb1de..d75714cedd2f493d7f648f7124c56f79f42741d5 100644 --- a/Assets/StreamingAssets/StreamToPersistentDataPath/cookie_persistentDataPath.txt +++ b/Assets/StreamingAssets/StreamToPersistentDataPath/cookie_persistentDataPath.txt @@ -1 +1,6 @@ -1 \ No newline at end of file +PersistantDataPath: + +Its locations is the operating systems corresponding default user appdata folder. +Its informations are persistent. +They will be initialized on first start. +They can be resetted with the ingame reset buttons. diff --git a/Assets/cookie_dataPath.txt b/Assets/cookie_dataPath.txt index 56a6051ca2b02b04ef92d5150c9ef600403cb1de..5b7e4b1a51f09443d62d33540b8a36afa11d6204 100644 --- a/Assets/cookie_dataPath.txt +++ b/Assets/cookie_dataPath.txt @@ -1 +1,5 @@ -1 \ No newline at end of file +DataPath: + +Its location is the installation folder. +Files in this directory are not persistent. +They will be overwritten on each start of the game.