VAUSoundSource.cs 1.76 KB
Newer Older
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
using UnityEngine;
using UnityEditor;
using System.Collections;
using System.Collections.Generic;
using VA;

public class VAUSoundSource : MonoBehaviour {
    private int SoundSource;
    public int AuralizationMode = 1;
    [Range(0.0f, 100.0f)]
    public double Volume = 70;
    public string SignalSource = "";
    private VANet _VA = VAUAdapter.VA;

    // Use this for initialization
    void Start()
    {
        SoundSource = _VA.CreateSoundSource(this.name, AuralizationMode, Volume); 
        if (GetComponent<AudioSource>() != null)
        {
            SignalSource = _VA.CreateAudiofileSignalSource( AssetDatabase.GetAssetPath(GetComponent<AudioSource>().clip), this.name + "_signal");
            _VA.SetSoundSourceSignalSource(SoundSource, SignalSource);
            Debug.Log(SignalSource);
            _VA.SetAudiofileSignalSourcePlaybackAction(SignalSource, 2);
        }
        //if( SignalSource == "" )
        //{
        //    AudioClip AudioSourceClip = GetComponent<AudioSource>().clip;
        //    string SignalSourcePath = AssetDatabase.GetAssetPath(AudioSourceClip);
        //    Debug.Log(SignalSourcePath);
        //    //SignalSource = _VA.LoadAudiofileSignalSource(SignalSourcePath);
        //}

        //if ( SignalSource != "" )
        //    _VA.SetSoundSourceSignalSource(SoundSource, SignalSource);
    }

    // Update is called once per frame
    void Update()
    {
        //position and oritentation -> VA
        Transform t = GetComponent<Transform>();
        _VA.SetSoundSourcePosition(SoundSource, t.transform.position.x, t.transform.position.y, -t.transform.position.z);
        _VA.SetSoundSourceOrientationYPR(SoundSource, -t.transform.rotation.eulerAngles.x, -t.transform.rotation.y, t.transform.rotation.eulerAngles.z);
        
    }



}