Basic MonoBehaviour
C#
using UnityEngine;

public class MyScript : MonoBehaviour
{
    void Start()
    {
        Debug.Log("Hello Unity!");
    }

    void Update()
    {
        // Your code here — runs every frame
    }
}

Line-by-Line Explanation

Line 1 'using UnityEngine' imports all Unity types — required in every Unity script.
Line 3 MonoBehaviour is the base class for all Unity components. Your script must inherit from it.
Line 5 Start() is called once when the script is first enabled. Use it for initialization.
Line 7 Debug.Log() prints to the Unity Console. Essential for debugging.
Line 10 Update() is called every frame. Put your game logic here (input, movement, etc.).