public LayerEntry GetLayerEntry(LayerConfig layerConfig) { for (var i = 0; i < _layerList.Count; i++) { if (_layerList[i].LayerConfig != layerConfig) { continue; } return(_layerList[i]); } Debug.LogWarning("No LayerEntry for Layer " + layerConfig.name + " :'("); return(null); }
// Animation private void DoAnimation(Layer layer, float delay) { UIAction action = LayerManager.Instance.GetToggledStatus(layer); if (layer == Layer.None) { return; } // Fade In Animation if (action == UIAction.Show) { // enable triggers OpenAnimations via Animator this.Show(layer); // sound LayerEntry layerEntry = LayerManager.Instance.GetLayerEntry(layer); if (layerEntry == null) { Debug.LogWarning("Layer named " + layer + " not found"); return; } LayerConfig UIConfig = layerEntry.LayerConfig; if (UIConfig != null) { // play each animation foreach (var anim in UIConfig.OpenAnimations) { anim.Object.Play(anim.State); } if (UIConfig.OpenSound != "") { SoundManager.Instance.Play(UIConfig.OpenSound, SoundManager.SoundType.Soundeffect, false, 0.5f); } } LayerManager.Instance.SetAction(layer, action); } // Fade Out animation else { //bool isAnimation = false; // check if UIConfig Component exists LayerEntry layerEntry = LayerManager.Instance.GetLayerEntry(layer); if (layerEntry == null) { Debug.LogWarning("Layer named " + layer + " not found"); return; } LayerConfig UIConfig = layerEntry.LayerConfig; if (UIConfig != null) { // play each animation foreach (var anim in UIConfig.CloseAnimations) { //isAnimation = true; anim.Object.Play(anim.State); } // sound if (UIConfig.CloseSound != "") { SoundManager.Instance.Play(UIConfig.CloseSound, SoundManager.SoundType.Soundeffect, false, 0.5f); } } // save for delayed animation //if (isAnimation == false) if (delay == 0) { this.Hide(layer); LayerManager.Instance.SetAction(layer, action); } else { AddHideLayerList(layer); } } }
public void Switch(LayerConfig layerConfig, UIAction action = UIAction.Show, float delay = -1) { Switch(LayerManager.Instance.GetLayerEntry(layerConfig).Layer, action, delay); }