Skip to content

Commit

Permalink
Added possibility tto reuse existing gameobject when creating urdf fi…
Browse files Browse the repository at this point in the history
…les at runtime
  • Loading branch information
ReykCS committed Dec 10, 2022
1 parent 90f353e commit 216e193
Showing 1 changed file with 10 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -92,9 +92,14 @@ private static ImportPipelineData ImportPipelineInit(string filename, ImportSett
}

// Creates the robot game object.
private static void ImportPipelineCreateObject(ImportPipelineData im)
private static void ImportPipelineCreateObject(ImportPipelineData im, GameObject gameObjectToUse = null)
{
im.robotGameObject = new GameObject(im.robot.name);
if ( ! gameObjectToUse ) {
gameObjectToUse = new GameObject();
}

im.robotGameObject = gameObjectToUse;
im.robotGameObject.name = im.robot.name;

importsettings = im.settings;
im.settings.totalLinks = im.robot.links.Count;
Expand Down Expand Up @@ -202,15 +207,15 @@ public static IEnumerator<GameObject> Create(string filename, ImportSettings set
/// <param name="filename">URDF filename</param>
/// <param name="settings">Import Settings</param>
/// <returns> Robot game object</returns>
public static GameObject CreateRuntime(string filename, ImportSettings settings)
public static GameObject CreateRuntime(string filename, ImportSettings settings, GameObject gameObjectToUse = null)
{
ImportPipelineData im = ImportPipelineInit(filename, settings, false, true);
ImportPipelineData im = ImportPipelineInit(filename, settings, false, false);
if (im == null)
{
return null;
}

ImportPipelineCreateObject(im);
ImportPipelineCreateObject(im, gameObjectToUse);

while (ProcessJointStack(im))
{// process the stack until finished.
Expand Down

0 comments on commit 216e193

Please sign in to comment.