Writing a CherryControl script

Next, we will add a script to the cherry prefab to support the creation and release of the cherry with respect to the Cucumber Man's hand.

  1. In the Project panel, select Assets | Cherry | Cherry.Prefab
  2. In the Inspector panel, click the Add Component button
  3. Select New Script and name the script CherryControl
  4. Click the Create and Add button
  5. In the Project panel, drag the new script into the Assets | Custom Scripts folder
  6. Edit the script so that it matches what is provided in the following code block

The first part of the script consists of the namespace import statements and the class declaration:

 using System.Collections; using System.Collections.Generic; using UnityEngine;  public class CherryControl : MonoBehaviour ...

Get Getting Started with Unity 2018 - Third Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.