Editor crashes when creating UMaterialInstanceDynamic
The snippet of code below comes mainly from the procedural mesh generation wiki article, but I've attempted to assign a very simple default material to it, which instantly crashes the editor (when I recompile, and when I load the editor). No error message or information is presented.
The exact line it crashes at is 18, when the new instance is created.
The code I've been working with (entire class, based on default actor template):
I managed to fix the issue by changing line 18 to
answered Apr 01 '16 at 04:28 PM
You can also use (Material.Object, this) as you did in the beginning, if you call that outside of the constructor. the constructor you define in C++ pretty much runs for the CDO (class default object), while other instances just use copy-constructor and get the CDO as feed for copy.
It pretty much means that you need to create dynamic material instances outside of constructor, for example in PostInitProperties(), OnConstruction(), BeginPlay()... All of these run for each instance. I really advice to check out this link for better explanation: https://docs.unrealengine.com/en-us/Programming/UnrealArchitecture/Actors/ActorLifecycle
answered Mar 19 '18 at 05:27 PM
Follow this question
Once you sign in you will be able to subscribe for any updates here