x

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"

Materials created using UMaterialInstanceDynamic::Create cause crashes after a period of time.

Hey everyone,

Problem

This method causes the game to crash after what seems to be exactly 60 seconds. I have isolated it down to the UMaterialInstanceDynamic* objects, as the game does not crash if I use the base UMaterialInstance* objects.

Code snippet of the offending UMaterialInstanceDynamic.

Background

In one of my Slate widgets, I have a number of buttons that use dynamic materials. They all require different materials, as they all differ by a single parameter - the texture representing each button.

I have four material instances I have created in Blueprint, each which take in a texture parameter ("CustomTexture") and alter it to create the Normal, Pressed, Hovered and Disabled ButtonStyles.

Each button uses the UMaterialInstanceDynamic::Create function to create a new dynamic material for each of the four material instances, passing their respective texture in as a material parameter before saving those dynamic materials into an FButtonStyle struct used in the construction of said button.

Things that might matter

The UMaterialInstanceDynamic* objects created by the Create function are declared inside of a for loop. I don't think this is a problem as it LOOKS like they persist outside of said loop.

The UMaterialInstance* objects are created by the StaticLoadObject function, and are declared inside of the function. They work fine, which is why I didn't think the above was a problem.

The FButtonStyle* objects are created on the heap, and the pointers are saved out in another class owned by the AHUD class.

Product Version: Not Selected
Tags:
capture.png (16.6 kB)
more ▼

asked Jan 20 '15 at 07:38 AM in Rendering

avatar image

riandrake
156 8 10 12

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

2 answers: sort voted first
more ▼

answered Jan 21 '15 at 10:34 PM

avatar image

riandrake
156 8 10 12

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

So looks like TMap is no longer compatible with UPROPERTY. You must do a workaround by using TArray instead.

more ▼

answered Jan 13 '18 at 12:24 AM

avatar image

sytelus
274 17 32 50

(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