Scripting the cucumber count

Let's start with our cucumber count:

  1. In the Hierarchy panel, select HUD_Canvas | Cucumber_Count
  2. In the Inspector panel, click the Add Component button
  3. Select New Script and name the script CucumberManager
  4. Edit the script

With the script open, make the necessary modifications to match the script provided, as follows:

 using System.Collections; using System.Collections.Generic; using UnityEngine; using UnityEngine.UI;  public class CucumberManager : MonoBehaviour {      public int currentCucumberCount;     Text Cucumber_Count;     public GameObject[] cucumbers;       void Awake () {          Cucumber_Count = GetComponent<Text> ();         currentCucumberCount = 0;     }           void Update () {          cucumbers = GameObject.FindGameObjectsWithTag ...

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.