void CreateObject(Vector3 pos)
    {
        if (selGridInt == 1)
        {
            ClearObjectsAtPosition(Vector3Int.RoundToInt(pos));
        }
        else
        {
            GameObject prefab = prefabs[selGridInt - 2];

            newGameObject = PrefabUtility.InstantiatePrefab(prefab as GameObject) as GameObject;
            newGameObject.transform.position = pos;

            newGameObject.transform.parent = level.transform;

            int z = 0;
            switch (rotateInt)
            {
            case 0:
                z = 0;
                break;

            case 1:
                z = 90;
                break;

            case 2:
                z = 180;
                break;

            case 3:
                z = 270;
                break;
            }

            newGameObject.transform.eulerAngles = new Vector3(0, 0, z);

            Vector3 p = newGameObject.transform.position;
            if (spawnHeight < p.z)
            {
                newGameObject.transform.position = new Vector3(p.x, p.y, -Mathf.Abs(spawnHeight));
            }

            Utils.AvoidIntersect(newGameObject.transform);

            if (playModeActive)
            {
                LevelPlayModePersistence.SaveNewObject(newGameObject);
            }

            Undo.RegisterCreatedObjectUndo(newGameObject, "Create object");
        }

        Refresh();

        isDirty = true;
    }
 void GetPlayModeJobs()
 {
     LevelPlayModePersistence.Job[] jobs = LevelPlayModePersistence.GetJobs();
     foreach (LevelPlayModePersistence.Job job in jobs)
     {
         if (job.name == "clear")
         {
             ClearObjectsAtPosition(Utils.Vec3ToInt(job.position));
         }
         else
         {
             PlayModeCreateObject(job.name, job.position, job.eulerAngles);
         }
     }
 }