Search in
Sort by:

Question Status:

Search help

  • Simple searches use one or more words. Separate the words with spaces (cat dog) to search cat,dog or both. Separate the words with plus signs (cat +dog) to search for items that may contain cat but must contain dog.
  • You can further refine your search on the search results page, where you can search by keywords, author, topic. These can be combined with each other. Examples
    • cat dog --matches anything with cat,dog or both
    • cat +dog --searches for cat +dog where dog is a mandatory term
    • cat -dog -- searches for cat excluding any result containing dog
    • [cats] —will restrict your search to results with topic named "cats"
    • [cats] [dogs] —will restrict your search to results with both topics, "cats", and "dogs"

Changing Material from Code crashes when exiting (ESC/Stop)

I wanted to change the material on the blocks in the first person template. In the constructor I have the following:

static ConstructorHelpers::FObjectFinder Material(TEXT("MaterialInstanceConstant'/Game/FirstPerson/Materials/M_Tech_Hex_Tile_Pulse_Inst.M_Tech_Hex_Tile_Pulse_Inst'"));

if (Material.Object != NULL) { TheMaterial = (UMaterial*)Material.Object; } In the event method, i set the material the following way:

TheMaterial_Dyn = UMaterialInstanceDynamic::Create(TheMaterial, this);

Itr->SetMaterial(0, TheMaterial_Dyn);

When I press the 'Q' key (the one I bount to the event) the material is changed accordingly, no problem yet. Exiting the game in the editor (ESC/Stop) gives me an access violation error.

Sometimes it breaks in the StaticMeshRenderer.cpp (line 2018):

OutMeshBatch.MaterialRenderProxy = Material->GetRenderProxy(bUseSelectedMaterial,bUseHoveredMaterial);

Sometimes it breaks in the ShaderBaseClasses.cpp (line 129), which is just "UE_LOG("

If I destroy the Actors before exiting I don't get the error.

What am I doing wrong? Do I need to edit the material at some point, do I need to import the material differently?

Product Version: UE 4.8
more ▼

asked Jul 08 '15 at 09:10 AM in Rendering

avatar image

3 1 2 5

(comments are locked)
10|2000 characters needed characters left
Viewable by all users

1 answer: sort voted first

Seems like I found the answer:

When creating the Material, I used UMaterialInstanceDynamic::Create(TheMaterial, this)

Using this was wrong, should have used Itr->GetOuter() instead, since I was setting the UObject Outer wrong

more ▼

answered Jul 08 '15 at 11:58 AM

avatar image

3 1 2 5

(comments are locked)
10|2000 characters needed characters left
Viewable by all users
Your answer
toggle preview:

Up to 5 attachments (including images) can be used with a maximum of 5.2 MB each and 5.2 MB total.

Follow this question

Once you sign in you will be able to subscribe for any updates here

Answers to this question