fix(UAT): only trigger callback when instance is created from scripting (#11283) 7564ef1fcb

Co-authored-by: hernan <hernan@rive.app>
This commit is contained in:
bodymovin
2025-12-15 23:28:19 +00:00
parent 81984a8c89
commit 5f503f6f8c
4 changed files with 11 additions and 2 deletions

View File

@@ -1 +1 @@
f32a23806c0ba3bab2eb697ff29bfb30471aef81
7564ef1fcba0c6b2c387c52734c5590774c81f60

View File

@@ -277,7 +277,7 @@ private:
uint32_t findViewModelId(ViewModel* search) const;
#ifdef WITH_RIVE_TOOLS
ViewModelInstanceCreated m_viewmodelInstanceCreatedCallback = nullptr;
bool m_triggerViewModelCreatedCallback = true;
bool m_triggerViewModelCreatedCallback = false;
#endif
};
} // namespace rive

View File

@@ -27,6 +27,9 @@ public:
ViewModelInstance* instance(const std::string& name);
rcp<ViewModelInstance> createInstance();
void file(File* value) { m_file = value; };
#ifdef WITH_RIVE_TOOLS
File* file() { return m_file; };
#endif
ViewModelInstance* defaultInstance();
size_t instanceCount() const;
std::vector<ViewModelProperty*> properties() { return m_Properties; }

View File

@@ -233,7 +233,13 @@ int ScriptedViewModel::instance(lua_State* L)
{
if (m_viewModel)
{
#ifdef WITH_RIVE_TOOLS
m_viewModel->file()->triggerViewModelCreatedCallback(true);
#endif
auto instance = m_viewModel->createInstance();
#ifdef WITH_RIVE_TOOLS
m_viewModel->file()->triggerViewModelCreatedCallback(false);
#endif
lua_newrive<ScriptedViewModel>(L, L, m_viewModel, instance);
}
return 1;