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"

Can't edit Mesh in the Editor with UPROPERTY

Header File

 UCLASS()
 class MIKETEST_API AMyTriggerBox : public AActor
 {
     GENERATED_BODY()
     
 public:    
     AMyTriggerBox(const FObjectInitializer& ObjectInitializer);
 
 protected:
     virtual void BeginPlay() override;
 
 public:    
     virtual void Tick(float DeltaTime) override;    
 
 private:
     class UBoxComponent* _box;
 
     UPROPERTY(EditDefaultsOnly)
     class UStaticMeshComponent* MeshComp;
     
 };

Cpp File

 #include "MyTriggerBox.h"
 #include "Components/BoxComponent.h"
 #include "Engine.h"
 
 AMyTriggerBox::AMyTriggerBox(const FObjectInitializer& ObjectInitializer) : Super(ObjectInitializer)
 {
      // Set this actor to call Tick() every frame.  You can turn this off to improve performance if you don't need it.
     PrimaryActorTick.bCanEverTick = true;
 
     _box = CreateDefaultSubobject<UBoxComponent>(TEXT("Box"));
     _box->SetHiddenInGame(false);
 
     _box->OnComponentBeginOverlap.AddDynamic(this, &AMyTriggerBox::OnBoxOverlapBegin);
     _box->OnComponentEndOverlap.AddDynamic(this, &AMyTriggerBox::OnBoxOverlapEnd);
 
     RootComponent = _box;
 
     UStaticMeshComponent* MeshComp = CreateDefaultSubobject<UStaticMeshComponent>(TEXT("TheMesh"));
 }
 

The Editor

alt text

Already tried with EditAnywhere. Same problem.

I don't want to make my MeshComp public, so I can't use BlueprintReadWrite

Product Version: UE 4.17
Tags:
ed.jpg (91.8 kB)
more ▼

asked Oct 11 '17 at 02:20 PM in Bug Reports

avatar image

devhobby
87 31 27 37

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

2 answers: sort voted first

Thank you for the screenshot. I see why you aren't able to edit it now. You are looking at this inside of a blueprint. If you wish for this UStaticMeshComponent to be accessible in Blueprints, you'll need to use the BlueprintReadWrite, or BlueprintReadOnly if you only want to see it, specifier in your UProperty declaration as well. It is also not always safe to assume that a Component is going to work the same way as a variable, as they are vastly different. There is not a gap of documentation in this respect, as there are resources that explain this such as this tutorial: https://docs.unrealengine.com/latest/INT/Videos/PLZlv_N0_O1gYup-gvJtMsgJqnEB_dGiM4/

Another thing to keep in mind is that UE4 is an ever changing engine. I understand that the lay out may have been different in 4.13 but there have been many changes since then. If you do wish for the editor to stay the same, there is nothing wrong with staying on an older version of the editor for development, as upgrading to a newer version will often pose problems for existing projects.

more ▼

answered Oct 16 '17 at 07:28 PM

avatar image

Matthew J ♦♦ STAFF
29.6k 525 85 402

avatar image devhobby Oct 16 '17 at 07:36 PM

I already know the playlist you linked me: some replies above, I linked one video ( https://youtu.be/ator4Vk4-FU?t=9m18s ) that shows how she creates a StaticMeshComponent and is able to assign a 3D Model to it

alt text

In MY case, I can only do that with a StaticMesh, and NOT a StaticMeshComponent

alt text

What's the difference between the two?

44.jpg (12.3 kB)
55.jpg (18.6 kB)
avatar image Matthew J ♦♦ STAFF Oct 16 '17 at 07:53 PM

I just put this same setup together myself and I'm not even seeing the same issue you're seeing. Are you sure you're checking in the right spot? This is the setup I used and this is what I'm seeing when I click on the component in the blueprint:

alt text

This is in 4.17. The constructor only has:

 MeshComp = CreateDefaultSubobject<UStaticMeshComponent>(TEXT("MeshComp"));

Also, as I mentioned before, there have been many changes since 4.13 so the layout is different. If you look at the tags on that Playlist, it created even longer ago, in 4.10

meshcomp.png (46.8 kB)
avatar image devhobby Oct 16 '17 at 07:58 PM

expanding the screenshot field of view, it should look the same to both of us

alt text

But still, the girl in the video see the StaticMesh "Browser" instead of the white drop-down menu at the top..... maybe it's just a different version........

666.jpg (275.6 kB)
avatar image Matthew J ♦♦ STAFF Oct 16 '17 at 07:58 PM

There is no difference. It's just the difference between 4.10 and 4.17

avatar image Matthew J ♦♦ STAFF Oct 16 '17 at 07:59 PM

You also must take into account the fact that you are also missing specifiers that are being used for the StaticMeshComponent in the tutorial. You can see its declaration here: https://youtu.be/ator4Vk4-FU?t=370

avatar image devhobby Oct 16 '17 at 08:10 PM

The only difference with the video is that SHE uses VisibleAnywhere and I use EditDefaultsOnly

WITH EDIT-DEFAULTS-ONLY alt text

WITH VISIBLE-ANYWHERE alt text

With EditDefaultsOnly (screenshot 1) I see a lot more things than VisibleAnywhere. But I can also see the NAME OF THE VARIABLE (identifier) that I gave: MeshComp

With VisibleAnywhere (screenshot 2) I only see the part where I'm allowed to choose a StaticMesh for my StaticMeshComponent BUT I can't see the name of the variable that I gave (MeshComp). Instead, I just see "StaticMesh"

ALSO, with VisibleAnywhere the Category of the Component is no longer "MyMesh" as I decided through the code and as EditDefaultsOnly correctly shows...

Is there a logic behind all this?

777.jpg (217.3 kB)
666.jpg (205.9 kB)
avatar image Matthew J ♦♦ STAFF Oct 16 '17 at 08:36 PM

You're also missing that she is also using meta = (AllowPrivateAccess = "true") which is very important when using a Private variable, or one set to VisibleAnywhere.

Although, I agree that the Mesh should not be editable when the VisibleAnywhere specifier is being used. I'll be looking into that, but your original issue (of not being able to edit your mesh) should be solved, so I'll be marking this as resolved. I'll update here with whatever information I find about the other problem.

avatar image devhobby Oct 16 '17 at 08:37 PM

Actually my code looks like this:

  private:    
         UPROPERTY(EditDefaultsOnly, BlueprintReadOnly, Category = "My Mesh", meta = (AllowPrivateAccess = "true"))
         UStaticMeshComponent* MeshComp;
     
         UPROPERTY(EditDefaultsOnly, Category = "Trigger")
         float Delay;
     
         UPROPERTY(EditDefaultsOnly, Category = "My Mesh") 
         UStaticMesh* MyMesh;

So yes, there IS the meta

avatar image Matthew J ♦♦ STAFF Oct 16 '17 at 08:44 PM

You can't omit information and expect me to know :), anyway I'll continue looking into this as I said.

avatar image Matthew J ♦♦ STAFF Oct 17 '17 at 08:50 PM

Hey Devhobby,

After looking into the functionality of VisibleAnywhere, I've entered a bug report for the fact that you are still able to edit the properties of a Component when it is marked with that specifier. You can find the bug report here: UE-51397

Have a nice day!

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

try to make it "Protected" instead of "Private"

more ▼

answered Oct 13 '17 at 05:24 PM

avatar image

TestyRabbit
204 6 5 12

avatar image devhobby Oct 13 '17 at 07:10 PM

Already did that. No luck.

avatar image TestyRabbit Oct 13 '17 at 07:21 PM

Hmm...maybe this answer can help you out?

avatar image devhobby Oct 13 '17 at 07:56 PM

I googled a lot before posting this issue. Didn't find any working solution and posted here.

avatar image TestyRabbit Oct 13 '17 at 08:48 PM

So what have you tried. You've tried changing it to protected/public. Where are you trying to change the information. I'm going to load your code into my own project and see what's going on.

avatar image devhobby Oct 13 '17 at 08:50 PM

EditAnywhere, EditDefaultsOnly... I've tried these combination too... nothing works

avatar image TestyRabbit Oct 13 '17 at 09:32 PM

I think you should re-read the answer I linked above. What are you trying to edit about the component? If you'd like to change the mesh, you do that in the TriggerBox as there is a property called Mesh Comp (See image)alt text

avatar image devhobby Oct 14 '17 at 11:29 AM

Yes, I know that. But I can't do anything if I click on TheMesh (Inherited) I'd like to change those settings

avatar image devhobby Oct 16 '17 at 12:37 PM

This video shows what I want to achieve: https://youtu.be/ator4Vk4-FU?t=9m18s

At 9:18, she can choose what should the Mesh be through the Blueprint-derived class in the Editor!

avatar image devhobby Oct 13 '17 at 08:01 PM

EVEN IF THE PROPERTY IS PUBLIC, the issue persists!

avatar image Matthew J ♦♦ STAFF Oct 16 '17 at 03:45 PM

Hello devhobby,

I'm bit confused by some of your code and it could be what's causing the issue. I notice that you declare your UProperty in your .h here:

 UPROPERTY(EditDefaultsOnly)
      class UStaticMeshComponent* MeshComp;

But when you go to use CreateDefaultSubobject to populate it, you aren't setting it, you're declaring yet another UStaticMeshComponent called MeshComp as well,

 UStaticMeshComponent* MeshComp = CreateDefaultSubobject<UStaticMeshComponent>(TEXT("TheMesh"));

If you remove the "UStaticMeshComponent*" from the start of this line, it may fix your problems. The compiler is likely ignoring the original one that was declared in the .h and showing you this one, which is not a UProperty.

avatar image devhobby Oct 16 '17 at 04:23 PM

Hello, thanks for the answer.

By the time, I deleted those lines and my constructor only contains

RootComponent = MeshComp;

For testing purposes, I added another UProperty of type UStaticMesh*

THAT appears!

But the UStaticMeshComponent does not!

alt text

1233.jpg (336.9 kB)
avatar image Matthew J ♦♦ STAFF Oct 16 '17 at 04:37 PM

You still have the UPROPERTY set to Private and are also not using BlueprintReadWrite or a Category, which could help, depending on where you're looking. With the screenshot you're providing, I cannot tell which Details panel this is. Also, a Static Mesh Component would show up in the Components list, not in the same place as a normal Static Mesh or a Float value.

Can you show the constructor? If it is only containing RootComponent = MeshComp;, that's also an issue as your UStaticMeshComponent needs to be initiated, using CreateDefaultSubobject, it just needs to be done correctly.

avatar image devhobby Oct 16 '17 at 06:53 PM

alt text

UProperty is set to private even for the float variable and for the StaticMesh. So I don't see the reason why it shouldn't work for the MeshComponent.

Also, each of them has a category assigned.

As you can see there IS the MeshComponent on the left, but in an older project from Unreal Engine 4.13, I have the StaticMeshComponent behaving like the current StaticMesh: a box where I could choose the 3D Model to apply.

For the "it just needs to be done correctly".

Well... there is a HUGE leak of documentation about using Unreal Engine with C++.

Yes, there are the basics.... but many times it's HARD to even find the documentation of an UE API class.

Not to talk about the Multiplayer... let's just pretend I didn't talk about it...

13.jpg (305.5 kB)
avatar image Akami7 Oct 16 '17 at 05:33 PM
      UPROPERTY(EditDefaultsOnly,Category "My Mesh")
      class UStaticMeshComponent* MeshComp;

Just for my education. Why are you using "class" with an object declaration within the .h ? Try without it and maybe the editor will catch your mesh.

avatar image Matthew J ♦♦ STAFF Oct 16 '17 at 06:05 PM

Using "class" allows for him to forward declare a class that has not been included in the .h file. This allows him to declare the property in his .h, and only include the necessary file in his .cpp.

However, I agree. This shouldn't be needed for UStaticMeshComponent at least as it shouldn't need to be forward declared unlike UBoxComponent would.

avatar image Akami7 Oct 16 '17 at 06:25 PM

Thank you very much Matthew for you response.

(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