public AbsorberController SpawnAbsorber(GridElementController container, AbsorberType type) { var prefab = ItemsMap.Absorbers.FirstOrDefault((p) => p.Type == type).Prefab; var absorber = Instantiate(prefab, container.transform, false); return(absorber); }
private void RenderItemsManagmentMenu() { EditorGUILayout.BeginHorizontal(); selectedAbsorberType = (AbsorberType)EditorGUILayout.EnumPopup(selectedAbsorberType); selectedReflectorType = (ReflectorType)EditorGUILayout.EnumPopup(selectedReflectorType); selectedEmitterType = (EmitterType)EditorGUILayout.EnumPopup(selectedEmitterType); EditorGUILayout.EndHorizontal(); EditorGUILayout.BeginHorizontal(); { SetEnabled(selectedAbsorberType != AbsorberType.None); if (GUILayout.Button("Spawn")) { TrySetEntityToSpawn(new LevelEntity() { Type = EntityType.Absorber, AbsorberType = selectedAbsorberType }); } ResetEnabled(); } { SetEnabled(selectedReflectorType != ReflectorType.None); if (GUILayout.Button("Spawn")) { TrySetEntityToSpawn(new LevelEntity() { Type = EntityType.Reflector, ReflectorType = selectedReflectorType }); } ResetEnabled(); } { SetEnabled(selectedEmitterType != EmitterType.None); if (GUILayout.Button("Spawn")) { TrySetEntityToSpawn(new LevelEntity() { Type = EntityType.Emitter, EmitterType = selectedEmitterType }); } ResetEnabled(); } EditorGUILayout.EndHorizontal(); }