public override void OnInspectorGUI() { DrawDefaultInspector(); SlotInspector slotInspector = (SlotInspector)target; var mapBehaviour = slotInspector.MapBehaviour; var map = mapBehaviour.Map; if (mapBehaviour == null) { return; } var position = slotInspector.GetPosition(); GUILayout.Label("Position: " + position); if (!mapBehaviour.Initialized) { if (GUILayout.Button("Initialize Map")) { mapBehaviour.Initialize(); mapBehaviour.Map.GetSlot(position); } return; } if (GUILayout.Button("Reset Map")) { mapBehaviour.Clear(); mapBehaviour.Initialize(); mapBehaviour.Map.GetSlot(position); } GUILayout.Space(10f); var slot = map.GetSlot(position, false); if (slot == null) { if (GUILayout.Button("CreateSlot")) { map.GetSlot(position); } } else { this.showEditor(slot, mapBehaviour); } }
public override void OnInspectorGUI() { DrawDefaultInspector(); SlotInspector slotInspector = (SlotInspector)target; var mapBehaviour = slotInspector.MapBehaviour; var map = mapBehaviour.Map; if (mapBehaviour == null) { return; } var position = slotInspector.GetPosition(); GUILayout.Label("Position: " + position); if (!mapBehaviour.Initialized) { if (GUILayout.Button("Initialize Map")) { mapBehaviour.Initialize(); } return; } var slot = map.GetSlot(position, false); if (slot == null) { if (GUILayout.Button("CreateSlot")) { map.GetSlot(position); } return; } if (slot.Collapsed) { GUILayout.Label("Collapsed: " + slot.Module); GUILayout.Space(20f); GUILayout.Label("Add exclusion rules:"); BlockBehaviourEditor.CreateNeighborExlusionUI(slot); return; } GUILayout.Label("Possible modules: " + slot.Modules.Count() + " / " + mapBehaviour.Modules.Count()); GUILayout.Label("Entropy: " + slot.Modules.Entropy); if (GUILayout.Button("Collapse Random")) { slot.CollapseRandom(); mapBehaviour.BuildAllSlots(); } var prototypes = new Dictionary <ModulePrototype, List <Module> >(); foreach (var module in slot.Modules.ToArray()) { var proto = module.Prototype; if (!prototypes.ContainsKey(proto)) { prototypes[proto] = new List <Module>(); } prototypes[proto].Add(module); } foreach (var proto in prototypes.Keys) { var list = prototypes[proto]; GUILayout.BeginHorizontal(); EditorGUILayout.PrefixLabel(proto.gameObject.name + " (" + (100f * list.Sum(module => module.Prototype.Probability) / slot.Modules.Sum(module => module.Prototype.Probability)).ToString("0.0") + "%)"); foreach (var module in list) { if (GUILayout.Button("R" + module.Rotation)) { slot.Collapse(module); mapBehaviour.BuildAllSlots(); } } GUILayout.EndHorizontal(); } }
static void DrawGizmoForMyScript(SlotInspector target, GizmoType gizmoType) { Gizmos.color = Color.blue; Gizmos.DrawWireCube(target.MapBehaviour.GetWorldspacePosition(target.GetPosition()), Vector3.one * InfiniteMap.BLOCK_SIZE); }
static void DrawGizmoForMyScript(SlotInspector target, GizmoType gizmoType) { Gizmos.color = Color.blue; Gizmos.DrawWireCube(target.MapGenerator.GetWorldspacePosition(target.GetPosition()), Vector3.one * MapGenerator.BlockSize); }
public override void OnInspectorGUI() { DrawDefaultInspector(); SlotInspector slotInspector = (SlotInspector)target; var mapGenerator = slotInspector.MapGenerator; if (mapGenerator == null) { return; } if (!mapGenerator.Initialized) { if (GUILayout.Button("Initialize Map")) { mapGenerator.Initialize(); } return; } var position = slotInspector.GetPosition(); GUILayout.Label("Position: " + position); var slot = slotInspector.MapGenerator.GetSlot(position, false); if (slot == null) { if (GUILayout.Button("CreateSlot")) { mapGenerator.GetSlot(position); } return; } if (slot.Collapsed) { GUILayout.Label("Collapsed: " + slot.Module); return; } GUILayout.Label("Possible modules: " + slot.Modules.Count() + " / " + mapGenerator.Modules.Count()); if (GUILayout.Button("Collapse Random")) { slot.CollapseRandom(); mapGenerator.BuildAllSlots(); } var prototypes = new Dictionary <ModulePrototype, List <Module> >(); foreach (var module in slot.Modules.ToArray()) { var proto = module.Prototype; if (!prototypes.ContainsKey(proto)) { prototypes[proto] = new List <Module>(); } prototypes[proto].Add(module); } foreach (var proto in prototypes.Keys) { var list = prototypes[proto]; GUILayout.BeginHorizontal(); EditorGUILayout.PrefixLabel(proto.gameObject.name); foreach (var module in list) { if (GUILayout.Button("R" + module.Rotation)) { slot.Collapse(module); mapGenerator.BuildAllSlots(); } } GUILayout.EndHorizontal(); } }