Book Image

Extending Unity with Editor Scripting

Book Image

Extending Unity with Editor Scripting

Overview of this book

Table of Contents (18 chapters)
Extending Unity with Editor Scripting
Credits
Foreword
About the Author
About the Reviewers
www.PacktPub.com
Preface
Index

Implementing the gizmo grid


When you open the script Level.cs. You will see the following code:

using UnityEngine;

namespace RunAndJump {
  public partial class Level : MonoBehaviour {

    [SerializeField]
    public int _totalTime = 60;
    [SerializeField]
    private float gravity = -30;
    [SerializeField]
    private AudioClip bgm;
    [SerializeField]
    private Sprite background;

    public int TotalTime {
      get { return _totalTime; }
      set { _totalTime = value; }
    }

    public float Gravity {
      get { return gravity; }
      set { gravity = value; }
    }

    public AudioClip Bgm {
      get { return bgm; }
      set { bgm = value; }
    }

    public Sprite Background {
      get { return background; }
      set { background = value; }
    }
   }
}

This script holds the variables that you saw in the inspector and the properties to access and change these values.

Note

As you may have noticed, making your variables public is not the only way to expose them in the...