Documentation

Unity Spark

Open Unity Spark

Unity Spark

Write and attach scripts

Open scripts in the Script window, attach them to objects, and ask the assistant to write them for you in Unity Spark.
Read time 2 minutesLast updated 3 hours ago

The assistant writes most scripts for you, but you can also open, read, and change them yourself in the Script window, and attach them to the objects they control. For more information about how scripts work, refer to Introduction to scripts in Unity Spark.
For a description of each control, refer to Script window reference.

Open the Script window

To add the Script window to your workspace:
  1. In any window group, select Add window (+).
  2. Select Script, or search for it in the Search windows field.
To start a new script, select New script (+).
To open an existing script, select Open a script (+), then select the script. You can also double-click a script in the Project window to open it.
When the assistant works on a script, it shows a label in the Scene view. Select the label's text to open that script in the Script window. For more information, refer to Follow the scripts and assets the agent works on.

Attach a script to an object

To attach a script to an object, do one of the following:

Drag and drop the script onto the object

To attach a script to an object:
  1. In the Project window, select the script.
  2. Drag the script onto the object in the Scene view or the Hierarchy window.

Use the Inspector window to add the script as a component

To attach a script to an object using the Inspector window:
  1. Open the Inspector window (Add Window (+) > Inspector).
  2. Select the object in the Scene view or the Hierarchy window.
  3. In the Inspector window, select Add Component > Scripts.
  4. Select the script.
For more information, refer to Add a component.

Ask the assistant to write scripts

The assistant can write and change scripts for you. Describe the behavior you want. For example, you can enter the following prompts:
  • Put a spinning coin on each platform and count the coins I collect.
  • When the player clicks Play, load the Level 1 scene.
The assistant can make mistakes so always review its changes:
  1. Review the scripts.
  2. Play your game to test them.
  3. If needed, ask for changes.
If your game logs errors, enter
/fix-errors
in the Chat window. For more information about fixing errors, refer to Fix errors with the assistant.

Additional resources