シューズロッカーが1ブロック8つまでだったので、1クラス8人にしました。
校舎の都合で教室は6つしかないので、6組まで。
部活の着替え用にロッカー室を作りたいけど、48個もロッカーを並べる作業はやりたくないので、
editor拡張で並べます。
あらかじめロッカーはprefabのlockerと用意しておきます。
教室や学校の周囲のフェンスも、同様にeditor拡張で配置しています。
using System.Collections; using System.Collections.Generic; using UnityEngine; using UnityEditor; public class setClassRooms : EditorWindow { [MenuItem("Window/Set ClassRooms")] static void Init() { setClassRooms window = (setClassRooms)EditorWindow.GetWindow(typeof(setClassRooms)); window.Show(); } void OnGUI() { if (GUILayout.Button("Set Lockers")) setter4(); } void setter4() { GameObject parent = GameObject.Find("lockers"); GameObject pf = (GameObject)Resources.Load("locker"); Quaternion rot = Quaternion.Euler(0, 0, 0); Quaternion rot2 = Quaternion.Euler(0, 180, 0); for (int y = 0; y <= 4; y++) { for (int x = 0; x <= 10; x++) { GameObject ob; Vector3 pos = new Vector3(x*0.6f, 0, y*1.6f); Vector3 pos2 = new Vector3(x*0.6f, 0, 1.6f*(y-0.7f)); if ((y % 2) == 0) { ob = Instantiate(pf, Vector3.zero, rot2, parent.transform); ob.transform.localPosition = pos2; ob.transform.localRotation = rot; } else { ob = Instantiate(pf, Vector3.zero, rot, parent.transform); ob.transform.localPosition = pos; ob.transform.localRotation = rot2; } int num = (x + y * 11 + 1); ob.name = ob.name.Replace("(Clone)", num.ToString() ); } } } }