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

Method SetBaseMaterial

Source/Engine/Content/Assets/MaterialInstance.cpp:266–307  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

264}
265
266void MaterialInstance::SetBaseMaterial(MaterialBase* baseMaterial)
267{
268 if (baseMaterial != nullptr && baseMaterial->WaitForLoaded())
269 {
270 LOG(Warning, "Cannot set base material of {0} to {1} because it failed to load.", ToString(), baseMaterial->ToString());
271 return;
272 }
273
274 ScopeLock lock(Locker);
275
276 if (baseMaterial == _baseMaterial)
277 return;
278
279#if !BUILD_RELEASE
280 // Prevent recursion
281 auto mi = Cast<MaterialInstance>(baseMaterial);
282 while (mi)
283 {
284 if (mi == this)
285 {
286 LOG(Error, "Cannot set base material of {0} to {1} because it's recursive.", ToString(), baseMaterial->ToString());
287 return;
288 }
289 mi = Cast<MaterialInstance>(mi->GetBaseMaterial());
290 }
291#endif
292
293 // Release previous parameters
294 Params.Dispose();
295
296 // Set new value
297 if (_baseMaterial)
298 {
299 OnBaseUnset();
300 }
301 _baseMaterial = baseMaterial;
302 if (baseMaterial)
303 {
304 _baseMaterial = baseMaterial;
305 OnBaseSet();
306 }
307}
308
309void MaterialInstance::ResetParameters()
310{

Callers 6

CreateVirtualInstanceMethod · 0.80
OnMaterialLoadedMethod · 0.80
OnEndPlayMethod · 0.80
UpdateLayoutMethod · 0.80
setupProxyMethod · 0.80
ImportModelMethod · 0.80

Calls 4

WaitForLoadedMethod · 0.80
ToStringFunction · 0.50
ToStringMethod · 0.45
DisposeMethod · 0.45

Tested by

no test coverage detected