Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adding support to change the default material in MuJoCo according to … #1345

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 16 additions & 1 deletion unity/Runtime/Importer/MjcfImporter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
using System.Linq;
using System.Xml;
using UnityEngine;
using UnityEngine.Rendering;

namespace Mujoco {
// API for importing Mujoco XML files into Unity scenes.
Expand All @@ -28,7 +29,21 @@ public class MjcfImporter {
public static Material DefaultMujocoMaterial {
get {
if (_DefaultMujocoMaterial == null) {
_DefaultMujocoMaterial = new Material(Shader.Find("Standard"));
if (GraphicsSettings.renderPipelineAsset != null)
{
if (GraphicsSettings.renderPipelineAsset.GetType().ToString().Contains("HighDefinition"))
{
_DefaultMujocoMaterial = new Material(Shader.Find("HDRP/Lit"));
}
else if (GraphicsSettings.renderPipelineAsset.GetType().ToString().Contains("Universal"))
{
_DefaultMujocoMaterial = new Material(Shader.Find("Universal Render Pipeline/Lit"));
}
}
else
{
_DefaultMujocoMaterial = new Material(Shader.Find("Standard"));
}
}

return _DefaultMujocoMaterial;
Expand Down