CodeBlanks Logo Icon CodeBlanks

Editing with the Inspector

Learn to edit component values in the Inspector window.

Inspector window

The Inspector window displays all details of the item selected in the Hierarchy or Project panel. When a GameObject is selected, its name, tag, layer, and all attached components are listed here.

// Transform fields visible in Inspector:
// Position: (0, 0, 0)
// Rotation: (0, 0, 0)
// Scale:    (1, 1, 1)

Developers can edit numerical values of components directly through these fields in the window.

Inspector fields and SerializeField

In your C# scripts, public variables automatically appear as editable fields in the Inspector window. To keep a variable private yet expose it in the Inspector, use the [SerializeField] attribute.

public float speed = 5.0f;
[SerializeField] private int health = 100;

This allows you to quickly test and balance gameplay mechanics from the Inspector without editing code.

Practice Print Inspector field values

Define speed (value 5.5) and health (value 100) representing two Inspector fields. Print Speed: 5.5 | Health: 100 to the console.

Starter code

Player.cs
using System;

class Program
{
    static void Main()
    {
        // speed ve health alanlarını tanımlayıp yazdır
    }
}

Sample solution

Player.cs
using System;

class Program
{
    static void Main()
    {
        double speed = 5.5;
        int health = 100;
        Console.WriteLine("Speed: " + speed + " | Health: " + health);
    }
}

Expected output

Speed: 5.5 | Health: 100

Questions and answers

Review the lesson questions together with their answers. To test yourself, solve the lesson interactively.

1 What happens to modifications made in the Inspector window while the game is running in Play mode?

  • Unity automatically compiles the entire project from scratch.
  • All components in the scene are instantly deleted.
  • When exiting Play mode, values revert back to their pre-test state. Correct answer
  • Changes are permanently saved to disk and cannot be undone.

Explanation: Inspector modifications during Play mode are temporary; they revert to original values when playback stops.

2 Expose private variable to Inspector

Question
[____] private float jumpForce = 8.5f;
Answer
[SerializeField] private float jumpForce = 8.5f;

Explanation: The [SerializeField] attribute allows private fields to appear in Unity's Inspector panel.

3 Inspector terms

Term Meaning
Inspector Panel editing selected object components
SerializeField Shows private variables in the Inspector
Transform Fields Position, rotation and scale input boxes
Play Mode Runtime mode where values are tested

All lessons in Beginner