Announcement

Collapse
No announcement yet.

TMap<> Replication - exposing to Unreal reflection.

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

    TMap<> Replication - exposing to Unreal reflection.

    Would it be possible to expose TMap to reflection system and by extension to replication ?

    I have run my self in cases where I'd really like to have some sort of ordered list, where order of data is important and should be maintained. One of that case is mapping input to action bar and/or inventory where I really need to maintain certain order of items.

    I have hacked solution around by using Struct with ID variable, but it's not efficient, since something like TArray can be only be really searched linearly, and by that can't be really used for bigger amounts of data and still be efficient.
    https://github.com/iniside/ActionRPGGame - Action RPG Starter kit. Work in Progress. You can use it in whatever way you wish.

    #2
    Bumping because I need this as well.

    For my GameState, I'd like to create a dictionary/map where the teams are the keys and values are the scores. TMap replication would be great for this, because now I have resort to a not-so-nice alternative.

    Comment


      #3
      Bump.

      Could we get at least information, if that's possible/planned or just not wort time working on exposing it back to reflection/editor ?

      I just found another use case where using TMap would be benficial. In UDataAsset for storing information about items, where they could be fast searched.
      Currently I use TArray, but you can imagine that linear search with more than 100 items might start to be problematic when there need to be performed several of such searches at once.
      https://github.com/iniside/ActionRPGGame - Action RPG Starter kit. Work in Progress. You can use it in whatever way you wish.

      Comment


        #4
        Triple Bump!

        Please add blueprint/network support for all important container types. Arrays are nice and all but... it's arrays, and they are very limited.

        I really figured this would have been a higher priority for epic since container types are fundamental and their use-cases are enormous.

        @iniside:

        I do recall reading somewhere on answerhub that it can be implemented in custom source and has been by some users but I have yet to find any source showing the implementation. After checking the source it looks like to implement TMap for BP and replication you need to add support for UE4's serialization and reflection yourself and the replication part should be a snap. It's the first parts that seem daunting. I wish I could do it myself but my c++ is very limited as the bulk of my experience is in managed languages (c# mainly).

        Comment


          #5
          Hi all,

          Just a quick update to let you know that this feature is being worked on and we're hoping to have something in a near-future release.

          There have repeated demands and several attempts over the years to address this; it's certainly not a 'snap'. The first iteration will likely just involve basic serialisation and reflection, with deeper editor and BP support coming later.
          Senior Core Programmer, UE4, Epic Games UK

          Comment


            #6
            Originally posted by Steve Robb View Post
            Hi all,

            Just a quick update to let you know that this feature is being worked on and we're hoping to have something in a near-future release.

            There have repeated demands and several attempts over the years to address this; it's certainly not a 'snap'. The first iteration will likely just involve basic serialisation and reflection, with deeper editor and BP support coming later.
            That's awesome to hear! Even basic exposed functionality will be much better than not exposed at all!
            https://github.com/iniside/ActionRPGGame - Action RPG Starter kit. Work in Progress. You can use it in whatever way you wish.

            Comment


              #7
              That's great news! Implementing a UMapProperty and supporting TMap replication was on my todo list in 1998. :-)

              Comment


                #8
                Sorry to bump such an old thread but is there any update on this? Being able to serialize maps so they can be used in the editor would be a serious plus.
                - Dev Blog - Twitter - Facebook - Google+

                Comment


                  #9
                  Initial support for TMap properties was added recently: https://github.com/EpicGames/UnrealE...baf027b851dcf7

                  This should be regarded as WIP, but it currently supports reflection, text conversion, garbage collection and delta serialisation.

                  Editor support is basic - currently maps just show up as text edit fields - but we're hoping to improve on that in the near future:

                  Code:
                  UPROPERTY(EditAnywhere, Category=TestMap)
                  TMap<int32, FString> LetsSeeIfThisWorks;
                  
                  LetsSeeIfThisWorks.Add(0, "Test: 1");
                  LetsSeeIfThisWorks.Add(1, "Test: 3");
                  Click image for larger version

Name:	tmap.png
Views:	1
Size:	4.0 KB
ID:	1075017

                  No blueprint support yet.

                  Steve
                  Senior Core Programmer, UE4, Epic Games UK

                  Comment


                    #10
                    Awesome! Thank you!

                    Comment


                      #11
                      Bump, any new info on TMap reflection and replication?

                      Comment


                        #12
                        We've got a big thread going at the moment on Multiplayer / Networking feature list and hardening pass. See my sig and someone post it there!

                        EDIT: If TMaps support serialization - then I believe they also support replication. You'll have to test that though, I'm not 100%

                        EDIT 2.0: I'm wrong.
                        Last edited by TheJamsh; 05-14-2017, 06:28 AM.

                        Comment


                          #13
                          Hi,

                          I was just attempting to use this and was getting to a deprecated function call (This one, https://docs.unrealengine.com/latest...tem/index.html).

                          Well, the source said it was deprecated, though the docs don't reflect that. This was on 4.10.1. Did I set something up incorrectly to cause it to go down that codepath or is there an issue there?

                          It also appeared that I can't use UStructs as keys to TMaps if I want them to replicate. This gave compiler errors saying it's unsupported.

                          Cheers,

                          Alan.

                          Comment


                            #14
                            UStructs as TMap keys are supported but you have to provide certain operator overloads / a key hash
                            https://forums.unrealengine.com/show...ap-with-struct

                            You shouldn't have to manually call NetSerialize on the TMap - that should happen on it's own when the actor gets its next replication pass

                            Comment


                              #15
                              UStructs can't be used as map keys if the map is declared as a UPROPERTY.

                              As for the other issue @skyphyr, did you find anything out? I just ran into this myself. I can only guess that TMap replication is still unsupported. Or has anyone else managed to get it working somehow?

                              Comment

                              Working...
                              X