A simple SetObject in EOnInit crashes WB after you restart WB and load into the world for the first time. Looks like different Meshes to set crash more often than others. Somewhat random. This is in a new and empty project. I also sent the crash report with the link of this ticket.
Here the Component I used:
class SetObjectTestClass : ScriptComponentClass { } class SetObjectTest : ScriptComponent { [Attribute("", UIWidgets.ResourcePickerThumbnail, "", "et")] protected ResourceName m_sPrefabToTakeMeshFrom; //------------------------------------------------------------------------------------------------ VObject GetPrefabVObject(ResourceName prefab) { IEntityComponentSource itemComponentSource = SCR_BaseContainerTools.FindComponentSource(Resource.Load(prefab), "MeshObject"); if (!itemComponentSource) return null; ResourceName resourceNameObject; itemComponentSource.Get("Object", resourceNameObject); if (!resourceNameObject) return null; return Resource.Load(resourceNameObject).GetResource().ToVObject(); } //------------------------------------------------------------------------------------------------ override void EOnInit(IEntity owner) { VObject vobject = GetPrefabVObject(m_sPrefabToTakeMeshFrom); if (!vobject) return; owner.SetObject(vobject, ""); } //------------------------------------------------------------------------------------------------ override void OnPostInit(IEntity owner) { SetEventMask(owner, EntityEvent.INIT); } }
If you set the mesh with this:
//------------------------------------------------------------------------------------------------ override void _WB_AfterWorldUpdate(IEntity owner, float timeSlice) { if (m_NewVObject) owner.SetObject(m_NewVObject, ""); }
you get no mesh or a random debug mesh instead of the new mesh or it also crashes the WB