From be12dff19b93e7bdccd34329fa43478321149a58 Mon Sep 17 00:00:00 2001 From: Robert Roos Date: Fri, 15 Sep 2023 11:48:15 +0200 Subject: [PATCH] Changed GetRos2ForUnityPath() to allow dynamic directory --- src/Ros2ForUnity/Scripts/ROS2ForUnity.cs | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/src/Ros2ForUnity/Scripts/ROS2ForUnity.cs b/src/Ros2ForUnity/Scripts/ROS2ForUnity.cs index 4ba7cfd..060b163 100644 --- a/src/Ros2ForUnity/Scripts/ROS2ForUnity.cs +++ b/src/Ros2ForUnity/Scripts/ROS2ForUnity.cs @@ -86,12 +86,22 @@ private string GetEnvPathVariableValue() public static string GetRos2ForUnityPath() { char separator = Path.DirectorySeparatorChar; - string appDataPath = Application.dataPath; - string pluginPath = appDataPath; + string pluginPath = ""; - if (InEditor()) { - pluginPath += separator + ros2ForUnityAssetFolderName; + var assetGUIs = AssetDatabase.FindAssets("t:Folder Ros2ForUnity"); + if (assetGUIs.Length == 1) + { + pluginPath = AssetDatabase.GUIDToAssetPath(assetGUIs[0]); + } + else + { + pluginPath = Application.dataPath; + if (InEditor()) + { + pluginPath += separator + ros2ForUnityAssetFolderName; + } } + return pluginPath; }