MCPcopy Create free account
hub / github.com/FlaxEngine/FlaxEngine / OnEnable

Method OnEnable

Source/Engine/Audio/AudioSource.cpp:512–541  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

510}
511
512void AudioSource::OnEnable()
513{
514 _prevPos = GetPosition();
515 _velocity = Vector3::Zero;
516
517 // Add source
518 ASSERT_LOW_LAYER(!Audio::Sources.Contains(this));
519 Audio::Sources.Add(this);
520 GetScene()->Ticking.Update.AddTick<AudioSource, &AudioSource::Update>(this);
521#if USE_EDITOR
522 GetSceneRendering()->AddViewportIcon(this);
523#endif
524
525 // Restore playback state
526 if (Clip)
527 {
528 if (_savedState != States::Stopped)
529 Play();
530 if (_savedState == States::Paused)
531 Pause();
532
533 SetTime(_savedTime);
534
535 if (_savedState != States::Stopped && UseStreaming())
536 RequestStreamingBuffersUpdate();
537 }
538
539 // Base
540 Actor::OnEnable();
541}
542
543void AudioSource::OnDisable()
544{

Callers

nothing calls this directly

Calls 5

GetSceneFunction · 0.85
OnEnableFunction · 0.85
GetPositionFunction · 0.50
ContainsMethod · 0.45
AddMethod · 0.45

Tested by

no test coverage detected