示例#1
0
        private void PlaySound(IntPtr tag,
                               IntPtr data, float volume, float pan, float pitch,
                               bool mode3D, float x, float y, float z, float distance)
        {
            if (data == IntPtr.Zero)
            {
                return;
            }
            var resource = EffekseerSoundResource.FromIntPtr(data);

            if (resource == null)
            {
                return;
            }

            EffekseerSoundInstance optimalInstance = null;

            foreach (var instance in childInstances)
            {
                if (!instance.CheckPlaying())
                {
                    optimalInstance = instance;
                    break;
                }
                else if (optimalInstance == null || instance.lastPlayTime < optimalInstance.lastPlayTime)
                {
                    optimalInstance = instance;
                }
            }
            if (optimalInstance != null)
            {
                optimalInstance.Stop();
                optimalInstance.Play(tag.ToString(), resource, volume, pan, pitch, mode3D, x, y, z, distance);
            }
        }
示例#2
0
        public static EffekseerSoundResource LoadAsset(string dirPath, string resPath)
        {
            AudioClip clip = AssetDatabase.LoadAssetAtPath <AudioClip>(EffekseerEffectAsset.NormalizeAssetPath(dirPath + "/" + resPath));

            EffekseerSoundResource res = new EffekseerSoundResource();

            res.path = resPath;
            res.clip = clip;
            return(res);
        }
示例#3
0
        public static bool InspectorField(EffekseerSoundResource res)
        {
            EditorGUILayout.LabelField(res.path);
            var result = EditorGUILayout.ObjectField(res.clip, typeof(AudioClip), false) as AudioClip;

            if (result != res.clip)
            {
                res.clip = result;
                return(true);
            }
            return(false);
        }
示例#4
0
 public void Play(string tag, EffekseerSoundResource resource,
                  float volume, float pan, float pitch,
                  bool mode3D, float x, float y, float z, float distance)
 {
     this.audioTag      = tag;
     this.lastPlayTime  = Time.time;
     transform.position = new Vector3(x, y, z);
     audio.spatialBlend = (mode3D) ? 1.0f : 0.0f;
     audio.volume       = volume;
     audio.pitch        = Mathf.Pow(2.0f, pitch);
     audio.panStereo    = pan;
     audio.minDistance  = distance;
     audio.maxDistance  = distance * 2;
     audio.clip         = resource.clip;
     audio.Play();
 }