Unity freezes in play mode after I click

I have a script that used to work but now unity freezes in play mode after I initiate that script by clicking.
Here is the code:

using System.Collections;
using System.Collections.Generic;
using System.ComponentModel.Design.Serialization;
using UnityEngine;

public class SpawnerSample : MonoBehaviour
{
    public GameObject ObjectToSpawn;
    [SerializeField]
    float radius;
    void Update()
    {
        if (Input.GetMouseButton(0))
        {
            for (int angleY = 0; angleY <= 360; angleY += 90)
            {
                for (int angleZ = 0; angleZ <= 360; angleY += 90)
                {
                    Spawn(0, angleY, angleZ);
                }
            }
        }
    }

    void Spawn(int angleX, int angleY, int angleZ)
    {
        Vector3 direction = Quaternion.Euler(0, angleY, angleZ) * Vector3.right;
        Vector3 spawnPosition = transform.position + direction * radius;
        Instantiate(ObjectToSpawn, spawnPosition, Quaternion.identity);
    }
}

Your second for is also incrementing angleY += 90

I’m guessing it’s a copy / paste issue and should work if you replace angleY with angleZ in that inner for loop :slight_smile: