UnityLink`
UnityLink`

CloseUnityScene

CloseUnityScene[]

closes the active Unity scene.

CloseUnityScene["name"]

closes the Unity scene with the specified name.

CloseUnityScene[patt]

closes the Unity scene with the name matching the string pattern patt.

CloseUnityScene[RegularExpression["regex"]]

closes the Unity scene with the name matching the specified regular expression.

CloseUnityScene[,n]

closes at most n Unity scenes.

Details

  • If the active scene is closed, then the first open scene in the Hierarchy window will become the active scene. If there are no more open scenes, then a new default scene will be created and become the active scene.
  • CloseUnityScene[expr] closes the first open Unity scene it finds.
  • CloseUnityScene[expr,n] closes at most n scenes.
  • CloseUnityScene[expr,All] closes all matching scenes.
  • CloseUnityScene[All] closes all open scenes.
  • CloseUnityScene is Listable.

Examples

Basic Examples  (2)

Load the UnityLink:

In[1]:=
Click for copyable input

Open a Unity project:

In[2]:=
Click for copyable input

Open multiple scenes:

In[3]:=
Click for copyable input

Close the active scene:

In[1]:=
Click for copyable input

Close the active scene:

In[1]:=
Click for copyable input

Close a scene by name:

In[1]:=
Click for copyable input

Close a scene using a string pattern:

In[1]:=
Click for copyable input

Use abbreviated string patterns:

In[1]:=
Click for copyable input

Close multiple scenes using a string pattern:

In[1]:=
Click for copyable input

Close multiple scenes using a RegularExpression:

In[1]:=
Click for copyable input

Find all open scenes:

In[1]:=
Click for copyable input

Find at most 2 scenes:

In[1]:=
Click for copyable input

CloseUnityScene is Listable:

In[1]:=
Click for copyable input