Browse Source

Click sound when buttons are clicked

master
Christopher 8 years ago
parent
commit
f6fe5885c4
  1. 27
      Assets/Fungus/Scripts/Components/SaveGameHelper.cs
  2. 1230
      Assets/FungusExamples/SaveGame/SaveExample.unity
  3. 1028
      Assets/FungusExamples/SaveGame/SaveGameCanvas.prefab

27
Assets/Fungus/Scripts/Components/SaveGameHelper.cs

@ -16,8 +16,17 @@ namespace Fungus
[SerializeField] protected bool restartDeletesSave = false; [SerializeField] protected bool restartDeletesSave = false;
[SerializeField] protected AudioClip buttonClickClip;
[SerializeField] protected SaveGameObjects saveGameObjects = new SaveGameObjects(); [SerializeField] protected SaveGameObjects saveGameObjects = new SaveGameObjects();
protected AudioSource clickAudioSource;
protected virtual void Awake()
{
clickAudioSource = GetComponent<AudioSource>();
}
protected virtual void Start() protected virtual void Start()
{ {
var saveManager = FungusManager.Instance.SaveManager; var saveManager = FungusManager.Instance.SaveManager;
@ -56,24 +65,38 @@ namespace Fungus
} }
protected void PlayClickSound()
{
if (clickAudioSource != null)
{
clickAudioSource.Play();
}
}
#region Public methods #region Public methods
public SaveGameObjects SaveGameObjects { get { return saveGameObjects; } } public SaveGameObjects SaveGameObjects { get { return saveGameObjects; } }
public virtual void Save() public virtual void Save()
{ {
PlayClickSound();
var saveManager = FungusManager.Instance.SaveManager; var saveManager = FungusManager.Instance.SaveManager;
saveManager.Save(); saveManager.Save();
} }
public virtual void Load() public virtual void Load()
{ {
PlayClickSound();
var saveManager = FungusManager.Instance.SaveManager; var saveManager = FungusManager.Instance.SaveManager;
saveManager.Load(); saveManager.Load();
} }
public virtual void Rewind() public virtual void Rewind()
{ {
PlayClickSound();
var saveManager = FungusManager.Instance.SaveManager; var saveManager = FungusManager.Instance.SaveManager;
saveManager.Rewind(); saveManager.Rewind();
} }
@ -88,11 +111,15 @@ namespace Fungus
saveManager.Delete(); saveManager.Delete();
} }
PlayClickSound();
SceneManager.LoadScene(startScene); SceneManager.LoadScene(startScene);
} }
public virtual void LoadScene(string sceneName) public virtual void LoadScene(string sceneName)
{ {
PlayClickSound();
SceneManager.LoadScene(sceneName); SceneManager.LoadScene(sceneName);
} }

1230
Assets/FungusExamples/SaveGame/SaveExample.unity

File diff suppressed because it is too large Load Diff

1028
Assets/FungusExamples/SaveGame/SaveGameCanvas.prefab

File diff suppressed because it is too large Load Diff
Loading…
Cancel
Save