Forum Discussion
Justin_Michaux
Feb 16, 2024Copper Contributor
Instantiating or Destroying a GameObject
Hello, I noticed that after installing the Mesh Toolkit in Unity, nodes for Instantiating or Destroying GameObjects are not available in Visual Scripting anymore.
Also it is impossible to create a custom node after the tookit is installed, even after regenerating nodes, the result as described.
I would like to know if this is intentional, and how can I get to instantiate or Destroy a GameObject in a Mesh Project?
Thanks!
- Weald_SpatialBrass Contributor
There's this from the Cloud Scripting documentation:
Cloning and reparenting
Nodes can be cloned and reparented in the Mesh Cloud Scripting API; the corresponding Unity scene will update accordingly. If you clone a node, it'll clone that node and all its children (including children that may be in the corresponding Unity objects but are not visible to Mesh Cloud Scripting).
It's possible to clone or reparent Nodes that correspond to Unity Components. This is implemented by recreating these Unity components based on the Mesh Cloud Scripting Node representations. Only Nodes that can be created through the Mesh Cloud Scripting API can be cloned or reparented. If you've created a component in Unity and set fields that aren't reflected in the corresponding Mesh Cloud Scripting Node, these fields will be reset to their defaults if the Node itself is cloned. For this reason, we recommend that you clone or reparent Transform Nodes where you're manipulating objects that were created in Unity. These will always correctly keep all the original Unity settings.
- michael-buschbeck-ms
Microsoft
You're right, instantiating and destroying scene object currently isn't supported in Mesh Visual Scripting.
It's not a security issue as much as an integration complication: Out of the box, instantiating an object in a visual script would create an isolated instance that only exists on the client that created it. Even if you were to make sure that you're instantiating the same scene object on all clients individually, Mesh wouldn't know they're collectively supposed to be the same shared object.
That said, I'm aware it's a pain point and we're actively working towards making it possible.- Weald_SpatialBrass ContributorThank you for clearing this up. Is it possible with Cloud Scripting?
- Weald_SpatialBrass ContributorI am wondering the same thing. I will talk to the Microsoft team and see what I can find out. It may be possible to do this with Cloud Scripting. I guess they see it as a security risk. I wonder if Prefabs in the library are scanned by the packager and these could include malicious scripts.