Preliminary support for plugins. Load all plugins in plugin folder.
This commit is contained in:
@@ -50,6 +50,7 @@ public class MjImporterWithAssets : MjcfImporter {
|
|||||||
// mjcfString.
|
// mjcfString.
|
||||||
var name = Path.GetFileNameWithoutExtension(filePath) + $"{UnityEngine.Random.Range(0,999)}";
|
var name = Path.GetFileNameWithoutExtension(filePath) + $"{UnityEngine.Random.Range(0,999)}";
|
||||||
string newPath = Path.Combine(Application.temporaryCachePath, $"{name}.xml");
|
string newPath = Path.Combine(Application.temporaryCachePath, $"{name}.xml");
|
||||||
|
MjEngineTool.LoadPlugins();
|
||||||
_mjModel = MjEngineTool.LoadModelFromFile(filePath);
|
_mjModel = MjEngineTool.LoadModelFromFile(filePath);
|
||||||
MjEngineTool.SaveModelToFile(newPath, _mjModel);
|
MjEngineTool.SaveModelToFile(newPath, _mjModel);
|
||||||
Debug.Log($"Imported MJCF loaded, saved to {newPath}");
|
Debug.Log($"Imported MJCF loaded, saved to {newPath}");
|
||||||
|
|||||||
@@ -284,6 +284,11 @@ public class MjcfImporter {
|
|||||||
CreateGameObjectWithCamera(parentObject, child);
|
CreateGameObjectWithCamera(parentObject, child);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
case "plugin": {
|
||||||
|
Debug.Log($"Plugin elements are only partially supported.");
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
default: {
|
default: {
|
||||||
Debug.Log($"The importer does not yet support tags <{child.Name}>.");
|
Debug.Log($"The importer does not yet support tags <{child.Name}>.");
|
||||||
break;
|
break;
|
||||||
|
|||||||
@@ -0,0 +1,8 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 1135ed488170c0444b32c18cc61fb9ef
|
||||||
|
folderAsset: yes
|
||||||
|
DefaultImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
||||||
@@ -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 {
|
public static class MjSceneImportSettings {
|
||||||
|
|||||||
Reference in New Issue
Block a user