Announcement

Collapse
No announcement yet.

Making attached component editable

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

    #16
    Also, this way I think if you call it in the constructor it is auto registered, the only time you would call RegisterComponent(); is if you are making property changes, etc... I think.

    Comment


      #17
      Oh right, CreateDefaultSubobject needs to be called in the constructor.

      So my setup is:

      1. User downloads UE plugin
      2. Opens existing scene
      3. Plugin walks existing scene attaching my component to actors of various kinds
      4. My component does stuff

      So there's no opportunity to do that, even if I wanted to replace their static mesh component as the default subobject and break their static mesh actor's transforms.

      I'm not fussed about where the property I'm trying to edit is, just that it's editable. It's OK for it to be on the component rather than the actor. I'm just confused as to what else it needs to be a "native component" like the restriction tooltip says.

      Comment


        #18
        I looked into the code that generates that tooltip a while ago, and it seemed pretty arbitrary to me. Like it was an imposed limitation that shouldn't really be necessary. Anyway, from what I remember, it means that in practice you can't edit component properties for dynamically added components (those created with NewObject as opposed to CreateDefaultSubobject). As you say, for your situation, you have no choice about that.

        As for what causes component properties to sometimes show up directly on the details panel of the parent actor, I've never worked that out.

        Comment


          #19
          Fun. Thanks for the reply, I guess I'll make a new inspector.

          Comment


            #20
            Wait, that sounds like too much work. I think I'll just make a new StaticMeshActor class and replace whatever I find with it, transferring over all the properties. Does that sound reasonable?

            My first hurdle is that there's a LOT of data in a static mesh actor to copy over, not just the static mesh itself. I need to maintain render settings, collision settings, all of that sort of thing. Is there a way to create a new object based on another object? My new AMyStaticMeshActor class inherits directly from AStaticMeshActor - what's the best way to either change or copy an object that already exists?
            Last edited by Antidamage; 05-22-2016, 08:13 PM.

            Comment


              #21
              No doubt there are some routines in the engine for doing that kind of property and subobject copying, but I'm afraid I've not tried anything similar myself so can't help you there.

              I'd be wary of going that route though - you open up a world of pain whenever Epic make any changes to the engine's AStaticMeshActor class.
              If I'm understanding right that all you really need to add is editor interaction functionality and not any custom data or logic to the actors, you really want to avoid making any changes to the makeup of the actors in the level. Your best bet would be to make an editor extension that just provided a new tool window for manipulating the selected actor (if compatible). But yeah, anything like that is quite an effort, especially the first time.

              Comment


                #22
                Yeah, as I looked into it it became obvious that I should just add a dropdown that knows about the currently selected actor or component. It's either deal with the pain of framework **** or the pain of slate. Neither is a great option but the latter should eventually work consistently.

                Comment


                  #23
                  Did you ever get this figured out? I've been running into the same issue... And I've narrowed it down to why it's not working, but I'm looking for a workaround.

                  You can edit the component only if you declare it in the header file first... However if you declare an array of components, they are not editable for some reason... Which is what I'm trying to work through right now.

                  Comment


                    #24
                    Originally posted by Rainbow.Warrior View Post
                    Did you ever get this figured out? I've been running into the same issue... And I've narrowed it down to why it's not working, but I'm looking for a workaround.

                    You can edit the component only if you declare it in the header file first... However if you declare an array of components, they are not editable for some reason... Which is what I'm trying to work through right now.
                    Same here ! one year later
                    Did you find a solution ?

                    Best regards

                    Comment


                      #25
                      As far as I know there's no solution.

                      Comment


                        #26
                        I know it's an old thread but just in case for anyone looking for a solution, here's mine:

                        Code:
                        Actor->SetRootComponent(Component);
                        Actor->AddInstanceComponent(Component); // call AddInstanceComponent after attaching it to an actor

                        Comment


                          #27
                          If a component adds dynamically and you need editable fields in the details panel, then after NewObject you need to use
                          Code:
                          spawnActor-> RemoveOwnedComponent (comp);
                          comp-> CreationMethod = EComponentCreationMethod :: Instance;
                          spawnActor-> AddOwnedComponent (comp);
                          I did it for an actor that had no components and I created a component for instances

                          Code:
                              FActorSpawnParameters Params;
                              AActor *spawnActor = World->SpawnActor(AActor::StaticClass(), Params);
                          
                              UInstancedStaticMeshComponent *comp = NewObject< UInstancedStaticMeshComponent>(spawnActor);
                              spawnActor->SetRootComponent(comp);
                          
                              spawnActor->RemoveOwnedComponent(comp);
                              comp->CreationMethod = EComponentCreationMethod::Instance;
                              spawnActor->AddOwnedComponent(comp);
                          
                          ....
                              comp->SetMobility(EComponentMobility::Movable);
                              comp->SetWorldLocation(mesh[0]->GetActorLocation(), false);
                              comp->SetMaterial(0, mat0);
                              comp->SetStaticMesh(StaticMesh);
                          
                              comp->RegisterComponent();
                          Result

                          Click image for larger version  Name:	20190124_183027.png Views:	1 Size:	120.9 KB ID:	1576523
                          Last edited by Babush61; 01-24-2019, 11:45 AM.
                          Plugin for HISM and ISMC https://www.unrealengine.com/marketp...nstance-editor

                          Comment

                          Working...
                          X