Skip to content

Commit

Permalink
Changed GetRos2ForUnityPath() to allow dynamic directory
Browse files Browse the repository at this point in the history
  • Loading branch information
Robert-DEMCON committed Sep 15, 2023
1 parent 010d9e5 commit be12dff
Showing 1 changed file with 14 additions and 4 deletions.
18 changes: 14 additions & 4 deletions src/Ros2ForUnity/Scripts/ROS2ForUnity.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand Down

0 comments on commit be12dff

Please sign in to comment.