Beispiel #1
0
        public override void OnInspectorGUI()
        {
            AudioClip currentClip = _audioEvt.AudioClip;

            base.OnInspectorGUI();

            if (currentClip != _audioEvt.AudioClip && _audioEvt.AudioClip != null && !_audioEvt.Loop)
            {
                if (_audioEvt.LengthTime > _audioEvt.AudioClip.length)
                {
                    Undo.RecordObject(_audioEvt, null);
                    _audioEvt.Length = Mathf.RoundToInt(_audioEvt.AudioClip.length * _audioEvt.Sequence.FrameRate);
                    FSequenceEditorWindow.RefreshIfOpen();
                }
            }

            serializedObject.Update();

            EditorGUILayout.PropertyField(_audioClip, _audioClipUI);
            EditorGUILayout.PropertyField(_volume, _volumeUI);
            EditorGUILayout.PropertyField(_loop, _loopUI);
            EditorGUILayout.PropertyField(_speedDeterminesPitch, _speedDeterminesPitchUI);

            _startOffset.intValue = Mathf.Clamp(_startOffset.intValue, 0, _audioEvt.GetMaxStartOffset());
            EditorGUI.BeginChangeCheck();
            EditorGUILayout.IntSlider(_startOffset, 0, _audioEvt.GetMaxStartOffset(), _startOffsetUI);
            if (EditorGUI.EndChangeCheck())
            {
                if (FSequenceEditorWindow.instance != null)
                {
                    FSequenceEditorWindow.instance.Repaint();
                }
            }
            serializedObject.ApplyModifiedProperties();
        }