Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Created AudioClip Variable, Reference, and Collection types #64

Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions Assets/PR Test Content.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

19 changes: 19 additions & 0 deletions Assets/PR Test Content/AudioClipCollection.asset
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
%YAML 1.1
%TAG !u! tag:unity3d.com,2011:
--- !u!114 &11400000
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 0}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: d289013f46a3b234986332177bde3edf, type: 3}
m_Name: AudioClipCollection
m_EditorClassIdentifier:
DeveloperDescription:
_value:
_list:
- {fileID: 8300000, guid: 26585c599866cff4c939fae7228e36d1, type: 3}
- {fileID: 8300000, guid: 28a05bfa495abe44c91dbb29fbd1a1a9, type: 3}
8 changes: 8 additions & 0 deletions Assets/PR Test Content/AudioClipCollection.asset.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

43 changes: 43 additions & 0 deletions Assets/PR Test Content/AudioClipReferenceTest.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
using ScriptableObjectArchitecture;
using UnityEngine;
using UnityEngine.UI;

namespace PR_Test_Content
{
public class AudioClipReferenceTest : MonoBehaviour
{
[SerializeField]
private Button _button;

[SerializeField]
private AudioSource _audioSource;

[SerializeField]
private bool _useRandomClickNoise;

[Header("Data")]
[SerializeField]
private AudioClipReference _clickAudioClipReference;

[SerializeField]
private AudioClipCollection _randomAudioClipCollection;

private void Start()
{
_button.onClick.AddListener(OnClick);
}

private void OnClick()
{
var clip = _useRandomClickNoise
? _randomAudioClipCollection[Random.Range(0, _randomAudioClipCollection.Count)]
: _clickAudioClipReference.Value;

if (!_audioSource.isPlaying)
{
_audioSource.clip = clip;
_audioSource.Play();
}
}
}
}
11 changes: 11 additions & 0 deletions Assets/PR Test Content/AudioClipReferenceTest.cs.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading