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"

Office Holiday

Epic Games' offices will be on holiday from June 22nd to July 7th. During this period support will be limited. Our offices will reopen on Monday, July 8th. 

How can I allow a material to be changed from the Editor in an Actor Derived Class?

After following and adding to the Procedural Mesh Generation Tutorial on the Wiki I have a procedurally generated Quad, that has UV's and also has a Material assigned to it during Construction. I have added a UPROPERTY for a UMaterial (Now that shows up in the editor). Also in the constructor it is that very material that I load the material into, then "SetMaterial" on my mesh component with. My Class declaration looks like this:

 UCLASS()
 class AGeneratedFloorQuad : public AActor
 {
     GENERATED_UCLASS_BODY()
 
     UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = Materials)
     UMaterial *GroundMaterial;
 
     TSubobjectPtr<UGeneratedMeshComponent> mesh;
     float HALF_SIZE = 500.f;
 
 };
 

And in the constructor:

 {
 ... left out vert crap
 static ConstructorHelpers::FObjectFinder<UMaterial> mat(TEXT("/Game/Materials/Tri_Proj"));
     GroundMaterial = mat.Object;
     mesh->SetGeneratedMeshTriangles(triangles);
     mesh->SetMaterial(0, GroundMaterial);
     mesh->MarkRenderStateDirty();
     RootComponent = mesh;
 }
 

When I change the material in the editor it changes the material shown in the properties box, but not on the mesh component of the actor. How do I go about making it change the material on the mesh component of the actor?

Product Version: Not Selected
Tags:
more ▼

asked May 16 '14 at 01:30 PM in C++ Programming

avatar image

JohnnyBeans78
97 9 9 16

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

1 answer: sort voted first

PostEditChangeProperty

What you want is described here:

https://answers.unrealengine.com/questions/44652/how-do-you-find-out-which-option-was-changed-in-th.html

I've done this myself so I know it works

You can override this function to check for your when your property is changed and then update the component yourself.

the key part is GetNameCPP which = the variable name:

 //Actual property name! like "TileName"
 UE_LOG(Victory,Warning, TEXT("prop changed ~Name~ %s"), *PropertyThatChanged->GetNameCPP());

Rama

more ▼

answered May 16 '14 at 10:49 PM

avatar image

Rama
10.6k 446 343 1086

avatar image JohnnyBeans78 May 16 '14 at 11:03 PM

This is exactly what I was looking for. I knew there had to be some sort of event to hook into, or in this case override. You are the man Rama. If I still drank, and you lived close I would buy you a beer or 10. Thank You.

(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