Skip to content

Commit be12dff

Browse files
author
Robert Roos
committed
Changed GetRos2ForUnityPath() to allow dynamic directory
1 parent 010d9e5 commit be12dff

File tree

1 file changed

+14
-4
lines changed

1 file changed

+14
-4
lines changed

src/Ros2ForUnity/Scripts/ROS2ForUnity.cs

+14-4
Original file line numberDiff line numberDiff line change
@@ -86,12 +86,22 @@ private string GetEnvPathVariableValue()
8686
public static string GetRos2ForUnityPath()
8787
{
8888
char separator = Path.DirectorySeparatorChar;
89-
string appDataPath = Application.dataPath;
90-
string pluginPath = appDataPath;
89+
string pluginPath = "";
9190

92-
if (InEditor()) {
93-
pluginPath += separator + ros2ForUnityAssetFolderName;
91+
var assetGUIs = AssetDatabase.FindAssets("t:Folder Ros2ForUnity");
92+
if (assetGUIs.Length == 1)
93+
{
94+
pluginPath = AssetDatabase.GUIDToAssetPath(assetGUIs[0]);
95+
}
96+
else
97+
{
98+
pluginPath = Application.dataPath;
99+
if (InEditor())
100+
{
101+
pluginPath += separator + ros2ForUnityAssetFolderName;
102+
}
94103
}
104+
95105
return pluginPath;
96106
}
97107

0 commit comments

Comments
 (0)