public static void ShowWindow(EnvironmentalPainter painter, int prefabIndex) { DistributionMapExporterGUI window = GetWindow <DistributionMapExporterGUI>(); window.painter = painter; window.prefab = painter.Settings.GetPrefabs()[prefabIndex]; window.titleContent = new GUIContent("Distribution Map Exporter"); window.fileName = string.Format("{0}-{1}-{2}", window.painter.Terrain.name, window.prefab.name, "DistributionMap"); window.ShowUtility(); }
public static void ShowWindow(EnvironmentalPainter painter, int prefabIndex) { MassPlacementGUI window = GetWindow <MassPlacementGUI>(); window.terrain = painter.Terrain; window.painter = painter; window.prefabIndex = prefabIndex; window.prefab = painter.Settings.GetPrefabs()[prefabIndex]; window.density = painter.Settings.density; window.scaleMin = painter.Settings.scaleMin; window.scaleMax = painter.Settings.scaleMax; window.maxRotation = painter.Settings.maxRotation; window.titleContent = new GUIContent("Mass Placement"); window.ShowUtility(); }
private void OnGUI() { EditorGUILayout.LabelField("Prefab", prefab.name); EditorGUI.BeginChangeCheck(); Texture2D t = EditorGUILayout.ObjectField("Distribution Map", map, typeof(Texture2D), false) as Texture2D; bool hasChanged = EditorGUI.EndChangeCheck(); if (hasChanged && t != null) { try { t.GetPixel(0, 0); validTexture = true; map = t; } catch { validTexture = false; map = null; } } if (!validTexture) { EditorGUILayout.HelpBox("Please assign a Read/Write Enabled texture!", MessageType.None, false); } density = EditorGUILayout.IntSlider("Density", density, 1, 100); densityMultiplier = EditorGUILayout.Slider("Density Multiplier", densityMultiplier, 0f, 1f); scaleMin = EditorGUILayout.FloatField("Scale Min", scaleMin); scaleMax = EditorGUILayout.FloatField("Scale Max", scaleMax); maxRotation = EditorGUILayout.FloatField("Max Rotation", maxRotation); followNormals = EditorGUILayout.Toggle("Follow Normals", followNormals); keepOldObjects = EditorGUILayout.Toggle("Keep Old Objects", keepOldObjects); if (EditorCommon.RightAnchoredButton("OK")) { if (painter == null) { painter = terrain.EnvironmentalPainter; } EnvironmentalPainter.MassPlacementProcessor massPlacementProcessor = new EnvironmentalPainter.MassPlacementProcessor( painter.Terrain, map, density, densityMultiplier, scaleMin, scaleMax, maxRotation, followNormals); Matrix4x4[] matrices = massPlacementProcessor.CalculatePlacementData(); painter.MassPlacing(prefabIndex, matrices, keepOldObjects); } GUI.enabled = true; }