Example #1
0
        public static void PlayGlobally(this AudioClip Clip, float Volume, float Pitch = 1f)
        {
            var gameObject = new GameObject("One shot audio");
            var Source     = gameObject.AddComponent(Il2CppSystem.Type
                                                     .GetTypeFromHandle(RuntimeReflectionHelper
                                                                        .GetRuntimeTypeHandle <AudioSource>())).Cast <AudioSource>();

            Source.clip         = Clip;
            Source.spatialBlend = 0f;
            Source.volume       = Volume;
            Source.pitch        = Pitch;
            Source.Play();
            Object.Destroy(gameObject,
                           Clip.length * ((double)Time.timeScale < 0.00999999977648258
                                        ? 0.01f
                                        : Time.timeScale));
        }
Example #2
0
        public static void PlayPositioned(this AudioClip Clip, Vector3 Position, float Volume)
        {
            var gameObject = new GameObject("One shot audio");
            var Source     = gameObject.AddComponent(Il2CppSystem.Type
                                                     .GetTypeFromHandle(RuntimeReflectionHelper
                                                                        .GetRuntimeTypeHandle <AudioSource>())).Cast <AudioSource>();

            Source.clip               = Clip;
            Source.spatialBlend       = 1f;
            Source.rolloffMode        = AudioRolloffMode.Linear;
            Source.transform.position = Position;
            Source.volume             = Volume;
            Source.Play();
            Object.Destroy(gameObject,
                           Clip.length * ((double)Time.timeScale < 0.00999999977648258
                                        ? 0.01f
                                        : Time.timeScale));
        }