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

[Unity plugin] Fix the missing .meta for copied library. #1154

Open
wants to merge 5 commits into
base: main
Choose a base branch
from
Open
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
29 changes: 29 additions & 0 deletions unity/Editor/Bindings/MujocoBinaryRetriever.cs
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ public class MujocoBinaryRetriever {
"/Applications/MuJoCo.app/Contents/Frameworks" +
"/mujoco.framework/Versions/Current/libmujoco.3.0.1.dylib",
mujocoPath + "/mujoco.dylib");
GenerateMetaFile(mujocoPath + "/mujoco.dylib");
AssetDatabase.Refresh();
}
} else if (RuntimeInformation.IsOSPlatform(OSPlatform.Linux)) {
Expand All @@ -47,6 +48,7 @@ public class MujocoBinaryRetriever {
Environment.GetFolderPath(Environment.SpecialFolder.UserProfile) +
"/.mujoco/mujoco-3.0.1/lib/libmujoco.so.3.0.1",
mujocoPath + "/libmujoco.so");
GenerateMetaFile(mujocoPath + "/libmujoco.so");
AssetDatabase.Refresh();
}
} else {
Expand All @@ -55,11 +57,38 @@ public class MujocoBinaryRetriever {
Environment.GetFolderPath(Environment.SpecialFolder.UserProfile) +
"\\MuJoCo\\bin\\mujoco.dll",
mujocoPath + "\\mujoco.dll");
GenerateMetaFile(mujocoPath + "\\mujoco.dll");
AssetDatabase.Refresh();
}
}
}
}
}

static void GenerateMetaFile(string file) {
ganyuanzhen marked this conversation as resolved.
Show resolved Hide resolved
string metaFileName = file + ".meta";

// Check if .meta file exists.
if (File.Exists(metaFileName)) {
Debug.Log("Meta file for " + file + " is already created!");
return;
}

// Create a uuid
var uuidN = Guid.NewGuid().ToString("N");

// Write content to .meta
using (StreamWriter writer = File.CreateText(metaFileName)) {
writer.WriteLine("fileFormatVersion: 2");
writer.WriteLine("guid: " + (uuidN.ToString()));
writer.WriteLine("DefaultImporter:");
writer.WriteLine(" externalObjects: {}");
writer.WriteLine(" userData: ");
writer.WriteLine(" assetBundleName: ");
writer.WriteLine(" assetBundleVariant: ");
}

Debug.Log("Meta file for " + file + " created!");
ganyuanzhen marked this conversation as resolved.
Show resolved Hide resolved
}
}
}