static void Init() { Clear(); MapBlockTool.Init(); float cubeX = EditorPrefs.GetFloat("BlockCube X", 1f); float cubeY = EditorPrefs.GetFloat("BlockCube Y", 1); float cubeZ = EditorPrefs.GetFloat("BlockCube Z", 1.75f); _cubeSize = new Vector3(cubeX, cubeY, cubeZ); _sceneSizeX = EditorPrefs.GetInt("BlockSceneSize X", 30); _sceneSizeZ = EditorPrefs.GetInt("BlockSceneSize Z", 30); string winPath = EditorUtiliTool.UnityPath2WinAbs(BlocksPrefabsDir); string[] dirPaths = Directory.GetDirectories(winPath); for (int i = 0; i < dirPaths.Length; i++) { string blockTypePath = dirPaths[i]; if (string.IsNullOrEmpty(blockTypePath)) { continue; } string typeName = Path.GetFileName(blockTypePath); _blocksTypes.Add(typeName); string[] blockPaths = Directory.GetFiles(blockTypePath, "**.prefab", SearchOption.AllDirectories); _blockPathsDic.Add(typeName, blockPaths); } SetBlockMenuData(); }
static void Clear() { MapBlockTool.Clear(); _blocksTypes.Clear(); _blockPathsDic.Clear(); _blocksDic.Clear(); _blockPage.Clear(); }
static void SceneInfoArea() { GUILayout.BeginHorizontal(); { GUILayout.Label("场景格子", GUILayout.Width(50)); if (GUILayout.Button("显示")) { _showGrid = true; } if (GUILayout.Button("隐藏")) { _showGrid = false; } } GUILayout.EndHorizontal(); GUILayout.BeginHorizontal(); { EditorGUI.BeginChangeCheck(); GUILayout.Label("格子尺寸", GUILayout.Width(50)); float cubeSizeX = EditorGUILayout.FloatField(_cubeSize.x); float cubeSizeY = EditorGUILayout.FloatField(_cubeSize.y); float cubeSizeZ = EditorGUILayout.FloatField(_cubeSize.z); cubeSizeX = Mathf.Clamp(cubeSizeX, float.MinValue, float.MaxValue); cubeSizeY = Mathf.Clamp(cubeSizeY, float.MinValue, float.MaxValue); cubeSizeZ = Mathf.Clamp(cubeSizeZ, float.MinValue, float.MaxValue); EditorPrefs.SetFloat("BlockCube X", cubeSizeX); EditorPrefs.SetFloat("BlockCube Y", cubeSizeY); EditorPrefs.SetFloat("BlockCube Z", cubeSizeZ); _cubeSize = new Vector3(cubeSizeX, cubeSizeY, cubeSizeZ); if (EditorGUI.EndChangeCheck()) { MapBlockTool.UpdateBlockPos(); } } GUILayout.EndHorizontal(); GUILayout.BeginHorizontal(); { GUILayout.Label("矩阵规格", GUILayout.Width(50)); int sceneSizeX = EditorGUILayout.IntField(_sceneSizeX); GUILayout.Label("X", EditorStyles.label); int sceneSizeZ = EditorGUILayout.IntField(_sceneSizeZ); sceneSizeX = Mathf.Clamp(sceneSizeX, int.MinValue, int.MaxValue); sceneSizeZ = Mathf.Clamp(sceneSizeZ, int.MinValue, int.MaxValue); EditorPrefs.SetInt("BlockSceneSize X", sceneSizeX); EditorPrefs.SetInt("BlockSceneSize Z", sceneSizeZ); _sceneSizeX = sceneSizeX; _sceneSizeZ = sceneSizeZ; } GUILayout.EndHorizontal(); GUILayout.BeginHorizontal(); { GUILayout.Label("层次调节", GUILayout.Width(50)); int floorNum = EditorGUILayout.IntField(_floorNum); _floorNum = Mathf.Clamp(floorNum, 0, 10); } GUILayout.EndHorizontal(); }