Merge pull request #1428 from Balint-H:feature/unity-plugins

PiperOrigin-RevId: 612144507
Change-Id: Ie355c0da2b4a51331aadcfce865a1edd720381b5
This commit is contained in:
Copybara-Service
2024-03-03 02:16:08 -08:00
3 changed files with 16 additions and 0 deletions
@@ -50,6 +50,7 @@ public class MjImporterWithAssets : MjcfImporter {
// mjcfString.
var name = Path.GetFileNameWithoutExtension(filePath) + $"{UnityEngine.Random.Range(0,999)}";
string newPath = Path.Combine(Application.temporaryCachePath, $"{name}.xml");
MjEngineTool.LoadPlugins();
_mjModel = MjEngineTool.LoadModelFromFile(filePath);
MjEngineTool.SaveModelToFile(newPath, _mjModel);
Debug.Log($"Imported MJCF loaded, saved to {newPath}");
+5
View File
@@ -284,6 +284,11 @@ public class MjcfImporter {
CreateGameObjectWithCamera(parentObject, child);
break;
}
case "plugin": {
Debug.Log($"Plugin elements are only partially supported.");
break;
}
default: {
Debug.Log($"The importer does not yet support tags <{child.Name}>.");
break;
+10
View File
@@ -368,6 +368,16 @@ public static class MjEngineTool {
}
}
}
public static void LoadPlugins() {
if(!Directory.Exists("Packages/org.mujoco/Runtime/Plugins/")) return;
foreach (string pluginPath in Directory.GetFiles("Packages/org.mujoco/Runtime/Plugins/")) {
MujocoLib.mj_loadPluginLibrary(pluginPath);
}
}
}
public static class MjSceneImportSettings {