Skip to content
Snippets Groups Projects
Select Git revision
  • 5e781de821dc78616943f57be4bac1b13a5fefa2
  • master default protected
  • feature/build
  • develop
  • VA_v2022a
  • v2021.a
  • v2020.a
  • v2019.a
  • v2018.b
  • v2017.c
  • v2017.a
  • v2016.a
12 results

VAUSoundSource.cs

Blame
  • Code owners
    Assign users and groups as approvers for specific file changes. Learn more.
    VAUSoundSource.cs 1.87 KiB
    using UnityEngine;
    using UnityEditor;
    using System.Collections;
    using System.Collections.Generic;
    using VA;
    
    public class VAUSoundSource : MonoBehaviour {
        
        public int AuralizationMode = 1;
        [Range(0.0f, 10.0f)]
        public int Volume = 1;
        public string SignalSource = "";
        private VANet _VA = null;
        private int SoundSource;
        private bool islooping;
        private bool ismuted;
    
        // Use this for initialization
        void Start()
        {
            _VA = VAUAdapter.VA;
            SoundSource = _VA.CreateSoundSource(this.name, AuralizationMode, Volume);
            islooping = GetComponent<AudioSource>().loop;
            if (GetComponent<AudioSource>() != null)
            {
                SignalSource = _VA.CreateAudiofileSignalSource( AssetDatabase.GetAssetPath(GetComponent<AudioSource>().clip), this.name + "_signal");
                _VA.SetSoundSourceSignalSource(SoundSource, SignalSource);
                Debug.Log(SignalSource + " connected to SoundSource " + SoundSource);
                _VA.SetAudiofileSignalSourcePlaybackAction(SignalSource, 2);
                _VA.SetAudiofileSignalSourceIsLooping(SignalSource, islooping);
            }
        }
    
        // 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);
            ismuted = GetComponent<AudioSource>().mute;
            _VA.SetSoundSourceMuted(SoundSource, ismuted);
            //_VA.SetSoundSourceVolume(SoundSource, Volume); <- flaot ändern
            
        }
    
        //void OnDestroy()
        //{
        //    //_VA.DeleteSoundSource(SoundSource);
        //    //_VA.DeleteSignalSource(SignalSource);
        //}
    
    }