2016. 2. 22. 05:54

유니티에서 사운드 재생 하기 위해 만든 매니저입니다.


간단한 사운드부터 거리설정 및 포지션 설정 사운드까지 지원합니다.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
public class SoundManager : MonoBehaviour
{
 
    public AudioClip[] BGMSounds;
    public AudioClip[] EffectSounds;
 
    public bool isSfxMute = false;
    [Range(0.0f, 1.0f)]
    public float sfxVolume = 1.0f;
 
    public Vector3 SoundPlayPosition;
 
    float DefaultMinDistance = 10.0f;
    float DefaultMaxDistance = 30.0f;
    public void SimplePlayBGM(int Index)
    {
        PlaySfx(BGMSounds[Index]);
    }
    public void SimplePlayEffect(int Index)
    {
        PlaySfx(EffectSounds[Index]);
    }
    public void PlaySfx(AudioClip sfx, Vector3 _pos, float _MinDistance, float _MaxDistance, float _Volume)
    {
        if (isSfxMute) return;
 
        GameObject SoundPlayObject = new GameObject("Sfx_" + sfx.name);
        SoundPlayObject.transform.position = _pos;
 
        AudioSource _AudioSource = SoundPlayObject.AddComponent<AudioSource>();
        _AudioSource.clip = sfx;
        _AudioSource.minDistance = _MinDistance;
        _AudioSource.maxDistance = _MaxDistance;
        _AudioSource.volume = sfxVolume;
 
        _AudioSource.Play();
 
        Destroy(SoundPlayObject, sfx.length);
    }
    public void PlaySfx(AudioClip sfx)
    {
        PlaySfx(sfx,SoundPlayPosition, DefaultMinDistance, DefaultMaxDistance, sfxVolume);
    }
    public void PlaySfx(AudioClip sfx, float _MinDistance, float _MaxDistance)
    {
        PlaySfx(sfx,SoundPlayPosition, _MinDistance, _MaxDistance, sfxVolume);
    }
    public void PlaySfx(AudioClip sfx, Vector3 _pos)
    {
        PlaySfx(sfx, _pos, DefaultMinDistance, DefaultMaxDistance, sfxVolume);
    }
    public void PlaySfx(AudioClip sfx, Vector3 _pos, float _MinDistance, float _MaxDistance)
    {
        PlaySfx(sfx, _pos, _MinDistance, _MaxDistance, sfxVolume);
    }
    public void PlaySfx(AudioClip sfx, Vector3 _pos, float sfxVolume)
    {
        PlaySfx(sfx, _pos, DefaultMinDistance, DefaultMaxDistance, sfxVolume);
    }
}
cs


Posted by 시리시안
2016. 2. 22. 05:53

첨부 파일에 패키지 드립니다.

제가 만든게 아니고, 외국 사이트에서 받은건데..

출처를 알게되면 바로 수정하겠습니다.


spine-unity.unitypackage



Posted by 시리시안
2016. 2. 22. 05:51



저번글에 이어서 봅시다.
이번 글에서는 스파인 좌측 기능에 대해서 볼껍니다.
SkeletonAnimation를 보면 여러 기능을 가지고있네요.
차례대로
스킨, 레이어,어드밴스안에 메시기능과
Z축 거리 노말 연산, 등..
그리고 애니메이션과 루프 타임스케일이 있네요.

위에서부터 봅시다.

스킨은 말그대로 스파인 디자이너가 넣어준 스킨을 교체합니다.
레이어는.. 굳이 설명 안해도 될꺼같네요

어드밴스 부분을 봅시다.
서브매시를 다루는 부분과
Z Spacing이 있네요

먼저 서브메시를 다루는건.. 음.. 내용이 좀 길어 질테니
로 대신합니다.

영상을 그대로 보시고 따라하시면 손쉽게 익히실수 있습니다.

그다음 Z Spacing을 봅시다.
3D뷰로 바꾸고 숫자를 조절하면 바로 알수있을꺼애요




이처럼 2D공간내에서 벌어지게 됩니다.
사용법은.. 서브메시를 이용할때 사용하셔도되고,
일부만 들어가는 파티클 작업이나, 라이트 작업에 사용하셔도됩니다.

그외 노말 과 탄젠트 계산법은 생략할게요.

애니메이션 네임과 루프와 타임스케일은 전부 아실꺼라 생각합니다~


Posted by 시리시안