From 597ba19bcd4c897f69d172d96c5baabdf6e3651b Mon Sep 17 00:00:00 2001
From: Stefan Richter <o-s-r1993@web.de>
Date: Mon, 13 May 2024 16:04:29 +0200
Subject: [PATCH] While in UnityEditor: DataPath will now link to
 PersistentDataPath

---
 Assets/Resources/Prefabs/UI/NetwMenu/OptionsM.prefab |  2 +-
 .../Scripts/InteractionEngine/CommunicationEvents.cs |  4 ++++
 Assets/Scripts/Loading/StreamingAssetLoader.cs       | 12 +++++++++++-
 3 files changed, 16 insertions(+), 2 deletions(-)

diff --git a/Assets/Resources/Prefabs/UI/NetwMenu/OptionsM.prefab b/Assets/Resources/Prefabs/UI/NetwMenu/OptionsM.prefab
index 3721bc37..2ea00eb0 100644
--- a/Assets/Resources/Prefabs/UI/NetwMenu/OptionsM.prefab
+++ b/Assets/Resources/Prefabs/UI/NetwMenu/OptionsM.prefab
@@ -17448,7 +17448,7 @@ GameObject:
   m_Icon: {fileID: 0}
   m_NavMeshLayer: 0
   m_StaticEditorFlags: 0
-  m_IsActive: 1
+  m_IsActive: 0
 --- !u!224 &178559033428688118
 RectTransform:
   m_ObjectHideFlags: 0
diff --git a/Assets/Scripts/InteractionEngine/CommunicationEvents.cs b/Assets/Scripts/InteractionEngine/CommunicationEvents.cs
index 7180a18a..77d5fa11 100644
--- a/Assets/Scripts/InteractionEngine/CommunicationEvents.cs
+++ b/Assets/Scripts/InteractionEngine/CommunicationEvents.cs
@@ -1,5 +1,6 @@
 using System.Collections.Generic;
 using System.Diagnostics;
+using System.IO;
 using UnityEngine;
 using UnityEngine.Events;
 
@@ -125,6 +126,9 @@ public static string CreatePathToFile(out bool file_exists, string name, string
             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); }
+
         if (hierarchie != null)
         {
             path = CreateHierarchiePath(hierarchie, path);
diff --git a/Assets/Scripts/Loading/StreamingAssetLoader.cs b/Assets/Scripts/Loading/StreamingAssetLoader.cs
index 06c1981b..f5f0f632 100644
--- a/Assets/Scripts/Loading/StreamingAssetLoader.cs
+++ b/Assets/Scripts/Loading/StreamingAssetLoader.cs
@@ -16,6 +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";
 
 
     //Config
@@ -72,6 +73,7 @@ public static bool ReloadManualy_StreamToDataPathWithHandler(string TargetDir_1)
         //Debug.Log("Reloaded_DPwH");
         return true;
     }
+    
     //---------------------------------------------------------------------------------------
 
 
@@ -229,7 +231,11 @@ 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);
+        }       
 
         RereadFiles_DataPath_withHandler();
         if (!ReReadFiles(rootPath, targetFolder))
@@ -250,6 +256,10 @@ public static void RereadFiles_DataPath_withHandler()
             targetFolder_wh = Application.persistentDataPath;
             //Debug.Log(OperationSystem.Android + " " + targetFolder_wh);
         }
+        if (Application.isEditor)
+        {
+            targetFolder_wh = Path.Combine(Application.persistentDataPath, Target_StreamToDataPath_UnityEditor);
+        }
 
         if (!ReReadFiles(rootPath, targetFolder_wh))
         {
-- 
GitLab