forked from cgvr/DeltaVR
properly replace archery target object's child with generated object
This commit is contained in:
@@ -48,7 +48,7 @@ public class ModelGenerationBox : MonoBehaviour
|
||||
string modelPath = await PipelineManager.Instance.GenerateModelAsync(inputPrompt);
|
||||
lastModelPath = modelPath;
|
||||
|
||||
GameObject spawnedObject = await PipelineManager.Instance.SpawnModel(modelPath);
|
||||
GameObject spawnedObject = await PipelineManager.Instance.SpawnModel(modelPath, true);
|
||||
spawnedObject.transform.parent = modelSpawnPoint;
|
||||
spawnedObject.transform.position = modelSpawnPoint.position;
|
||||
|
||||
|
||||
@@ -75,7 +75,7 @@ public class PipelineManager : MonoBehaviour
|
||||
});
|
||||
}
|
||||
|
||||
public async Task<GameObject> SpawnModel(string modelPath)
|
||||
public async Task<GameObject> SpawnModel(string modelPath, bool addRigidBody)
|
||||
{
|
||||
var gltf = new GltfImport();
|
||||
bool loadSuccess = await gltf.Load(modelPath);
|
||||
@@ -93,7 +93,10 @@ public class PipelineManager : MonoBehaviour
|
||||
MeshRenderer renderer = spawnedObjectBody.GetComponent<MeshRenderer>();
|
||||
renderer.material.SetFloat("metallicFactor", 0);
|
||||
|
||||
spawnedObjectMainTransform.gameObject.AddComponent<Rigidbody>();
|
||||
if (addRigidBody)
|
||||
{
|
||||
spawnedObjectMainTransform.gameObject.AddComponent<Rigidbody>();
|
||||
}
|
||||
|
||||
return spawnedObject;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user