Add tutorial note sfx

This commit is contained in:
Jens Pitkänen 2020-04-21 01:30:20 +03:00
parent fa9e736a3d
commit deacdd8d3f
11 changed files with 219 additions and 2 deletions

View File

@ -495,6 +495,7 @@ GameObject:
- component: {fileID: 4011034688995518088} - component: {fileID: 4011034688995518088}
- component: {fileID: 7219523719308697115} - component: {fileID: 7219523719308697115}
- component: {fileID: 5868126559231260333} - component: {fileID: 5868126559231260333}
- component: {fileID: 544281022505091268}
m_Layer: 5 m_Layer: 5
m_Name: Tutorial m_Name: Tutorial
m_TagString: Untagged m_TagString: Untagged
@ -549,5 +550,108 @@ MonoBehaviour:
m_Name: m_Name:
m_EditorClassIdentifier: m_EditorClassIdentifier:
ToggleKey: 101 ToggleKey: 101
AnimationDuration: 0
Toggled: 1 Toggled: 1
AnimationLerpFactor: 10
OpenClips:
- {fileID: 8300000, guid: 79aaac9df59cca344b1f07fccf60d640, type: 3}
- {fileID: 8300000, guid: a4ca1210b462e3647928fd3b37e7651f, type: 3}
CloseClips:
- {fileID: 8300000, guid: dfa31c493251ea548a01b21d5486c77a, type: 3}
- {fileID: 8300000, guid: a5b1e1505cdb3d2449d5d24f20fe2b50, type: 3}
--- !u!82 &544281022505091268
AudioSource:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 6286624448002602506}
m_Enabled: 1
serializedVersion: 4
OutputAudioMixerGroup: {fileID: -6009061206453669325, guid: 032de345950918c4e89684078c6a7213,
type: 2}
m_audioClip: {fileID: 0}
m_PlayOnAwake: 0
m_Volume: 1
m_Pitch: 1
Loop: 0
Mute: 0
Spatialize: 0
SpatializePostEffects: 0
Priority: 128
DopplerLevel: 1
MinDistance: 1
MaxDistance: 500
Pan2D: 0
rolloffMode: 0
BypassEffects: 0
BypassListenerEffects: 0
BypassReverbZones: 0
rolloffCustomCurve:
serializedVersion: 2
m_Curve:
- serializedVersion: 3
time: 0
value: 1
inSlope: 0
outSlope: 0
tangentMode: 0
weightedMode: 0
inWeight: 0.33333334
outWeight: 0.33333334
- serializedVersion: 3
time: 1
value: 0
inSlope: 0
outSlope: 0
tangentMode: 0
weightedMode: 0
inWeight: 0.33333334
outWeight: 0.33333334
m_PreInfinity: 2
m_PostInfinity: 2
m_RotationOrder: 4
panLevelCustomCurve:
serializedVersion: 2
m_Curve:
- serializedVersion: 3
time: 0
value: 0
inSlope: 0
outSlope: 0
tangentMode: 0
weightedMode: 0
inWeight: 0.33333334
outWeight: 0.33333334
m_PreInfinity: 2
m_PostInfinity: 2
m_RotationOrder: 4
spreadCustomCurve:
serializedVersion: 2
m_Curve:
- serializedVersion: 3
time: 0
value: 0
inSlope: 0
outSlope: 0
tangentMode: 0
weightedMode: 0
inWeight: 0.33333334
outWeight: 0.33333334
m_PreInfinity: 2
m_PostInfinity: 2
m_RotationOrder: 4
reverbZoneMixCustomCurve:
serializedVersion: 2
m_Curve:
- serializedVersion: 3
time: 0
value: 1
inSlope: 0
outSlope: 0
tangentMode: 0
weightedMode: 0
inWeight: 0.33333334
outWeight: 0.33333334
m_PreInfinity: 2
m_PostInfinity: 2
m_RotationOrder: 4

View File

@ -2,16 +2,20 @@
using System.Collections.Generic; using System.Collections.Generic;
using UnityEngine; using UnityEngine;
[RequireComponent(typeof(CanvasGroup))] [RequireComponent(typeof(AudioSource))]
public class TutorialController : MonoBehaviour { public class TutorialController : MonoBehaviour {
public KeyCode ToggleKey; public KeyCode ToggleKey;
public bool Toggled = true; public bool Toggled = true;
public float AnimationLerpFactor = 10f; public float AnimationLerpFactor = 10f;
public AudioClip[] OpenClips;
public AudioClip[] CloseClips;
private RectTransform Rect; private RectTransform Rect;
private AudioSource Audio;
private void Awake() { private void Awake() {
Rect = GetComponent<RectTransform>(); Rect = GetComponent<RectTransform>();
Audio = GetComponent<AudioSource>();
} }
private void Start() { private void Start() {
@ -21,10 +25,23 @@ public class TutorialController : MonoBehaviour {
private void Update() { private void Update() {
if (Input.GetKeyDown(ToggleKey)) { if (Input.GetKeyDown(ToggleKey)) {
Toggled = !Toggled; Toggled = !Toggled;
if (Toggled) {
Audio.PlayOneShot(GetRandomClip(OpenClips));
} else {
Audio.PlayOneShot(GetRandomClip(CloseClips));
}
} }
Vector2 Pos = Rect.anchoredPosition; Vector2 Pos = Rect.anchoredPosition;
Pos.y = Mathf.Lerp(Pos.y, Toggled ? -100 : (Rect.rect.height + 10), AnimationLerpFactor * Time.deltaTime); Pos.y = Mathf.Lerp(Pos.y, Toggled ? -100 : (Rect.rect.height + 10), AnimationLerpFactor * Time.deltaTime);
Rect.anchoredPosition = Pos; Rect.anchoredPosition = Pos;
} }
private AudioClip GetRandomClip(AudioClip[] clips) {
if (clips.Length > 0) {
return clips[Random.Range(0, clips.Length)];
} else {
return null;
}
}
} }

8
Assets/Sounds/Paper.meta Normal file
View File

@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 068c7d786b798594a9fdc803ef6ad6ea
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

Binary file not shown.

View File

@ -0,0 +1,22 @@
fileFormatVersion: 2
guid: dfa31c493251ea548a01b21d5486c77a
AudioImporter:
externalObjects: {}
serializedVersion: 6
defaultSettings:
loadType: 0
sampleRateSetting: 0
sampleRateOverride: 44100
compressionFormat: 1
quality: 1
conversionMode: 0
platformSettingOverrides: {}
forceToMono: 1
normalize: 0
preloadAudioData: 1
loadInBackground: 0
ambisonic: 0
3D: 1
userData:
assetBundleName:
assetBundleVariant:

Binary file not shown.

View File

@ -0,0 +1,22 @@
fileFormatVersion: 2
guid: a5b1e1505cdb3d2449d5d24f20fe2b50
AudioImporter:
externalObjects: {}
serializedVersion: 6
defaultSettings:
loadType: 0
sampleRateSetting: 0
sampleRateOverride: 44100
compressionFormat: 1
quality: 1
conversionMode: 0
platformSettingOverrides: {}
forceToMono: 1
normalize: 0
preloadAudioData: 1
loadInBackground: 0
ambisonic: 0
3D: 1
userData:
assetBundleName:
assetBundleVariant:

Binary file not shown.

View File

@ -0,0 +1,22 @@
fileFormatVersion: 2
guid: 79aaac9df59cca344b1f07fccf60d640
AudioImporter:
externalObjects: {}
serializedVersion: 6
defaultSettings:
loadType: 0
sampleRateSetting: 0
sampleRateOverride: 44100
compressionFormat: 1
quality: 1
conversionMode: 0
platformSettingOverrides: {}
forceToMono: 1
normalize: 0
preloadAudioData: 1
loadInBackground: 0
ambisonic: 0
3D: 1
userData:
assetBundleName:
assetBundleVariant:

Binary file not shown.

View File

@ -0,0 +1,22 @@
fileFormatVersion: 2
guid: a4ca1210b462e3647928fd3b37e7651f
AudioImporter:
externalObjects: {}
serializedVersion: 6
defaultSettings:
loadType: 0
sampleRateSetting: 0
sampleRateOverride: 44100
compressionFormat: 1
quality: 1
conversionMode: 0
platformSettingOverrides: {}
forceToMono: 1
normalize: 0
preloadAudioData: 1
loadInBackground: 0
ambisonic: 0
3D: 1
userData:
assetBundleName:
assetBundleVariant: