bool CAnimation::_togglePreviewMode(bool enabled) { bool isRunning = SceneManager::instance().isRunning(); if(enabled) { // Cannot enable preview while running if (isRunning) return false; if(!mPreviewMode) { // Make sure not to re-enable preview mode if already enabled because it rebuilds the internal Animation // component, changing its ID. If animation evaluation is async then the new ID will not have any animation // attached for one frame. This can look weird when sampling the animation for preview purposes // (e.g. scrubbing in editor), in which case animation will reset to T pose for a single frame before // settling on the chosen frame. restoreInternal(true); mPreviewMode = true; } return true; } else { if (!isRunning) destroyInternal(); mPreviewMode = false; return false; } }
void CAnimation::onEnabled() { if(mPreviewMode) { destroyInternal(); mPreviewMode = false; } if(SceneManager::instance().isRunning()) restoreInternal(false); }
void CAnimation::restoreInternal(bool previewMode) { if (mInternal != nullptr) destroyInternal(); mInternal = Animation::create(); mAnimatedRenderable = SO()->getComponent<CRenderable>(); if (!previewMode) { mInternal->onEventTriggered.connect(std::bind(&CAnimation::eventTriggered, this, _1, _2)); mInternal->setWrapMode(mWrapMode); mInternal->setSpeed(mSpeed); mInternal->setCulling(mEnableCull); } _updateBounds(); if (!previewMode) { if (mDefaultClip.isLoaded()) mInternal->play(mDefaultClip); mPrimaryPlayingClip = mInternal->getClip(0); if (mPrimaryPlayingClip.isLoaded()) { if (_scriptRebuildFloatProperties) _scriptRebuildFloatProperties(mPrimaryPlayingClip); } } setBoneMappings(); if(!previewMode) updateSceneObjectMapping(); if (mAnimatedRenderable != nullptr) mAnimatedRenderable->_registerAnimation(static_object_cast<CAnimation>(mThisHandle)); }
void CCharacterController::onDisabled() { destroyInternal(); }
void CAudioSource::onDisabled() { destroyInternal(); }
void CAudioSource::onDestroyed() { destroyInternal(); }
void CAnimation::onDestroyed() { destroyInternal(); }
void CAnimation::onDisabled() { destroyInternal(); }
void CRigidbody::onDisabled() { destroyInternal(); }
void CRigidbody::onDestroyed() { destroyInternal(); }
void ScriptHandleSliderBase::destroy() { ScriptHandleSliderManager::instance().unregisterSlider(this); destroyInternal(); }
void CCollider::onDisabled() { destroyInternal(); }
void CCollider::onDestroyed() { destroyInternal(); }