UNITY LINK

Working With Properties of Unity Objects

You can discover, access and modify properties of Unity objects.

Load the UnityLink package and open a project:

In[7]:=
Click for copyable input
In[8]:=
Click for copyable input

Get a unity object:

In[9]:=
Click for copyable input
Out[9]=

You can manipulate properties of a Unity object obj using part specification obj[["prop"]].

Discover Properties

obj[["Properties"]] gives a list of all available properties of the Unity object obj.

In[13]:=
Click for copyable input
Out[13]=
  • Unity objects of different types have different properties available to them.

Access a Property

obj[["prop"]] extracts the value corresponding to the property "prop" of a Unity object obj.

In[14]:=
Click for copyable input
Out[14]=

Extract multiple properties using a list:

In[15]:=
Click for copyable input
Out[15]=

Modify a Property

obj[["prop"]] = val changes the value of the property prop to val.

In[17]:=
Click for copyable input

Change multiple properties using a list :

In[19]:=
Click for copyable input

Work with Component Properties

obj[["comp", "prop"]] can be used to extract the value of a property "prop" associated to a Unity component "comp" of a Unity object obj.

In[27]:=
Click for copyable input
Out[27]=

Get the position from the transform component:

In[28]:=
Click for copyable input
Out[28]=

Move the object:

In[30]:=
Click for copyable input
  • Properties of the Transform component are accessible directly from the game object.