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"

How to change material on my StaticMesh via c++ code?

I try to change material on ma staticmesh but my unreal editor crashes when I try to load myproject. I guess I do something wrong :D

static ConstructorHelpers::FObjectFinder Material_Blue(TEXT("d/Game/Materials /M_Basic_Wall_red.M_Basic_Wall_red'")); if (Material_Blue.Succeeded()) { SphereVisual->SetMaterial(0, Material_Blue.Object); }

Product Version: UE 4.9
Tags:
more ▼

asked Sep 15 '15 at 10:47 AM in C++ Programming

avatar image

Nagini
1 1 3 5

avatar image staticvoidlol Sep 18 '15 at 08:29 AM

I'd guess you're trying to access ConstructorHelper in a non-constructor function? In that case, you can use StaticLoadObject to find your material instead.

(comments are locked)
10|2000 characters needed characters left

1 answer: sort voted first

Hello Nagini,

Can you post the callstack that you receive when the editor crashes? Also, where in your code is the snippet that you posted? If it's not in your constructor, that would cause a crash as ConstructorHelpers can only be used in the constructor.

more ▼

answered Sep 16 '15 at 09:14 PM

avatar image

Matthew J ♦♦ STAFF
31.8k 526 91 417

avatar image Nagini Sep 18 '15 at 01:49 PM

U are right, I did use ConstructorHelpers in non-contructor function. Thanks guys for help, I will try to solve this :)

(comments are locked)
10|2000 characters needed characters left
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