Announcement

Collapse
No announcement yet.

Making attached component editable

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    Making attached component editable

    Hi guys

    I have a component that I'm attaching to actors in a map. Right now it seems to be locked down, despite declaring everything I want to edit as UPROPERTY():



    The member is set to public and used like this:

    Code:
    UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Lighting") ERenderResolution RenderResolution = ERenderResolution::RR_AUTO;
    So I think the problem isn't the member above, it's actually the way I'm attaching the new component to the actor:

    Code:
    OctaneComponent = NewObject<UOctaneComponent>(Actor);
    OctaneComponent->RegisterComponent();
    
    OctaneComponent->SetFlags(RF_MarkAsNative);
    Is there anything else I need to do to this to get it to be editable?

    #2
    OctaneComponent->bEditableWhenInherited = true; or something of that sort.

    Comment


      #3
      Gotcha, thanks!

      Comment


        #4
        That didn't do it I'm afraid. There don't seem to be any other properties relevant to making it editable either.

        Comment


          #5
          Scratch that, I had to click the parent to see and edit the property. Thanks again!

          Edit: and as quickly as it was there, it's gone again. I'm so confused. I can even see the modified value in the component but I can't find the enabled dropdown again in any other objects.
          Last edited by Antidamage; 05-19-2016, 10:44 PM.

          Comment


            #6
            where are you calling this code (in a function, constructor, etc)?
            Self-Learning to program, Open to advice!

            Comment


              #7
              I'm setting this in the constructor:

              Code:
              	SetFlags(RF_MarkAsNative | RF_Dynamic | RF_Standalone);
              	MarkAsEditorOnlySubobject();
              
              	bEditableWhenInherited = true;
              	bWantsBeginPlay = false;
              	PrimaryComponentTick.bCanEverTick = true;
              And this after spawning a new object:

              Code:
              OctaneComponent = NewObject<UOctaneComponent>(Actor);
              OctaneComponent->RegisterComponent();
              I've been moving things around and trying different things so those flags are random guesses.

              Comment


                #8
                I believe you set that bool right after you attach the component to the actor. Right?

                In my code i set it after I set my attach pointer.

                Of course, I am setting it to false to deny access to the component properties. So I think you should be able to edit the component by default.

                Code:
                ObjectSocketSprite->AttachTo(VisualMesh, "StopSignSocket");        
                ObjectSocketSprite->bSelectable = false;
                ObjectSocketSprite->bEditableWhenInherited = false;

                Comment


                  #9
                  hm in the actor your attaching it to have your tried declaring it in it's header im pretty sure you have idk im not good at this

                  ex:
                  Code:
                  UPROPERTY(BlueprintReadWrite, VisibleDefaultsOnly, Category = )
                  class UOctaneComponent* OctaneComponent;
                  pls note im still terrible at programming and all code is as is >_<
                  Self-Learning to program, Open to advice!

                  Comment


                    #10
                    Not possible as I have no control over what kind of actor the component is attached to.

                    I had this working when adding the properties to an actor directly which was cool, but it seems more complicated to try to get the actor to display properties for a component.

                    Comment


                      #11
                      Originally posted by IllpIll View Post
                      I believe you set that bool right after you attach the component to the actor. Right?

                      In my code i set it after I set my attach pointer.

                      Of course, I am setting it to false to deny access to the component properties. So I think you should be able to edit the component by default.

                      Code:
                      ObjectSocketSprite->AttachTo(VisualMesh, "StopSignSocket");        
                      ObjectSocketSprite->bSelectable = false;
                      ObjectSocketSprite->bEditableWhenInherited = false;
                      Hmm good idea, I'll try that. I'm not doing an attach, just providing the actor as an Outer. It's not a scene component so doesn't need anything other than to have that actor as the owner (I think!)

                      Comment


                        #12
                        Moving things back out to beyond when the component is registered also didn't seem to make a difference. Bit of a mind****, I wish I knew how it managed to work for a few seconds.

                        Comment


                          #13
                          Maybe I don't get the specific but is there a reason why you go for newObject() instead of CreateDefaultSubObject () ?

                          I thought newObject () is rather if your owner is not an actor...

                          Comment


                            #14
                            I didn't know that. What constitutes a default subobject though? Most of these actors are actually static mesh actors with a static mesh. I don't think I want to replace the static mesh behaviour with something else - I'm just adding an extra component that provides additional editor functionality to that actor.

                            Comment


                              #15
                              Try this instead of NewObject:
                              OctaneComponent = CreateDefaultSubobject<UOctaneComponent>(TEXT("Descriptive Text Goes Here"));

                              I believe in the following code you are creating a new Actor Object? I am not very skilled with c++ either but if this component is a child of the main actor class and only used to add additional functionality that it should be a SubObject. Again, I do not know if I am near correct in my assumptions.
                              Code:
                              OctaneComponent = NewObject<UOctaneComponent>(Actor);
                              OctaneComponent->RegisterComponent();

                              Comment

                              Working...
                              X