public GunSoundSourceElement(GunSoundSetting soundSetting, GunSoundSetting.GunSoundElement setting, GunSoundSource source)
        {
            this.soundSetting = soundSetting;
            this.setting      = setting;
            this.source       = source;
            gameObject        = new GameObject(setting.name);
#if AimSoundInternal
            // gameObject.hideFlags = HideFlags.DontSave;
#else
            gameObject.hideFlags = HideFlags.HideAndDontSave;
#endif
            gameObject.transform.SetParent(source.transform, false);
            loopAudioSource      = CloneAudioSource(setting, gameObject);
            loopAudioSource.loop = true;
            var endClips = setting.endClips;
            for (int i = 0; i < endClips.Length; ++i)
            {
                if (endClips[i])
                {
                    _maxEndSoundDuration = Mathf.Max(_maxEndSoundDuration, endClips[i].length);
                }
            }

            if (setting.useLowPassFilter)
            {
                var audioLowPassFilter = gameObject.AddComponent <AudioLowPassFilter>();
                audioLowPassFilter.lowpassResonanceQ = setting.lowpassResonanceQ;
                audioLowPassFilter.customCutoffCurve = setting.lowPassFilterCurve;
            }
            // endAudioSource = CloneAudioSource(soundSetting.audioSource,gameObject);
        }
Пример #2
0
        public static void ShowInstantiateContextMenu(GunSoundSetting soundSetting, Vector3 spawnPoint)
        {
            var menu = new GenericMenu();

            // SkeletonAnimation
            menu.AddItem(new GUIContent("Create Gun Sound Source"), false, HandleComponentDrop, new SpawnMenuData {
                asset      = soundSetting,
                spawnPoint = spawnPoint,
            });

            menu.ShowAsContext();
        }
Пример #3
0
    void AddGunButton(AimSound.GunSoundSetting setting)
    {
        var button = Instantiate(gunButtonPrefab);

        button.text.text = setting.name;
        button.transform.SetParent(gunButtonParent);
        button.toggle.group = toggleGroup;
        button.toggle.onValueChanged.AddListener((value) =>
        {
            SetGun(setting);
        });
        gunButtons.Add(button);
    }
Пример #4
0
        static GunSoundSource CreateGunSoundGameObject(GunSoundSetting soundSetting, Vector3 position)
        {
            GameObject newGameObject  = new GameObject("AimSound Gun Sound Source(" + soundSetting.gameObject.name + ")");
            var        gunSoundSource = newGameObject.AddComponent <GunSoundSource>();

            gunSoundSource.setting = soundSetting;
            var transform = newGameObject.transform;

            transform.position = position;

            Selection.activeGameObject = newGameObject;

            Undo.RegisterCreatedObjectUndo(newGameObject, "Create Gun Sound GameObject");
            return(gunSoundSource);
        }
Пример #5
0
 void SetSetting(GunSoundSetting setting)
 {
     lastSetting = setting;
     for (int i = 0; i < elements.Length; ++i)
     {
         elements[i].Destroy();
     }
     if (setting)
     {
         if (setting)
         {
             setting.InitCheck();
         }
         var sounds = setting.sounds;
         elements             = new GunSoundSourceElement[sounds.Length];
         _maxEndSoundDuration = 0;
         for (int i = 0; i < sounds.Length; ++i)
         {
             elements[i]          = new GunSoundSourceElement(setting, sounds[i], this);
             _maxEndSoundDuration = Mathf.Max(_maxEndSoundDuration, elements[i].maxEndSoundDuration);
         }
     }
 }
Пример #6
0
 void SetGun(AimSound.GunSoundSetting setting)
 {
     gunSoundSource.setting = setting;
     shotCountObject.SetActive(!setting.isOneShot);
 }