Announcement

Collapse
No announcement yet.

Prefabricator - Open Source Prefab Plugin

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

    Thanks for the continued updates Ali. I'll have a check next time I'm on that bit of my project and let you know if there are problems after updating the assets.

    Comment


      Originally posted by merkaba48 View Post

      I too am very interested in this functionality! I can store and retrieve a soft-object reference, but creating a prefab instance results in logic referring to the original object in the scene.

      I see the primary focus of Prefabricator is for visual elements, but being able to retain hard object references to actors/scene components also in the prefab would be incredibly useful.
      I have recently found some spare time and got back to the project where I needed this functionality. I have modified Ali Akbar's code in such a way that it now preserves the reference to the actors inside the prefab. Here is pretty much what I did:
      • I modified FPrefabricatorPropertyAssetMapping structure to store ItemID for the referenced actor (the ID is obtained from UPrefabricatorAssetUserData)
      • I store this ItemID inside UPrefabricatorProperty::SaveReferencedAssetValues()
      • I modified method FPrefabTools::LoadStateFromPrefabAsset such that it first spawns all the actors as placeholders and only restores their properties after all are spawned.
      • I take the list of spawned actors and forward it all the way to UPrefabricatorProperty::LoadReferencedAssetValues(TArray<AActor*> ChildActors)
      • Inside this method, I use the previously stored ItemID to identify the correct actor and change the ReferencedPath accordingly.
      I am willing to share the code if anyone is interested (and if Ali agrees), but I have not yet tested it properly so I may have broken something else along the way.

      Comment


        Originally posted by Jan Byška View Post

        I have recently found some spare time and got back to the project where I needed this functionality. I have modified Ali Akbar's code in such a way that it now preserves the reference to the actors inside the prefab. Here is pretty much what I did:
        • I modified FPrefabricatorPropertyAssetMapping structure to store ItemID for the referenced actor (the ID is obtained from UPrefabricatorAssetUserData)
        • I store this ItemID inside UPrefabricatorProperty::SaveReferencedAssetValues()
        • I modified method FPrefabTools::LoadStateFromPrefabAsset such that it first spawns all the actors as placeholders and only restores their properties after all are spawned.
        • I take the list of spawned actors and forward it all the way to UPrefabricatorProperty::LoadReferencedAssetValues(TArray<AActor*> ChildActors)
        • Inside this method, I use the previously stored ItemID to identify the correct actor and change the ReferencedPath accordingly.
        I am willing to share the code if anyone is interested (and if Ali agrees), but I have not yet tested it properly so I may have broken something else along the way.
        If Ali is ok Im very interested in your code.

        Comment


          Originally posted by Jan Byška View Post

          I have recently found some spare time and got back to the project where I needed this functionality. I have modified Ali Akbar's code in such a way that it now preserves the reference to the actors inside the prefab. Here is pretty much what I did:
          • I modified FPrefabricatorPropertyAssetMapping structure to store ItemID for the referenced actor (the ID is obtained from UPrefabricatorAssetUserData)
          • I store this ItemID inside UPrefabricatorProperty::SaveReferencedAssetValues()
          • I modified method FPrefabTools::LoadStateFromPrefabAsset such that it first spawns all the actors as placeholders and only restores their properties after all are spawned.
          • I take the list of spawned actors and forward it all the way to UPrefabricatorProperty::LoadReferencedAssetValues(TArray<AActor*> ChildActors)
          • Inside this method, I use the previously stored ItemID to identify the correct actor and change the ReferencedPath accordingly.
          I am willing to share the code if anyone is interested (and if Ali agrees), but I have not yet tested it properly so I may have broken something else along the way.
          Thank you Jan Byška.

          Originally posted by Jan Byška View Post
          (and if Ali agrees),
          This is an open source project, you can do what ever you want with it

          I'd love to incorporate this into the plugin. You can share the code (preferably as a pull request in github) and I'll test and integrate it
          Last edited by Ali Akbar; 02-04-2020, 11:24 AM.
          Dungeon Architect | Prefabricator

          Discord Support

          Comment


            I've made some major performance improvements to prefabricator and I'll push a new update tomorrow. It does the following:
            • Reduce the generation time of prefabs during creation and randomization. This is noticeable with larger nested prefab with thousands of children
            • Optimized the thumbnail Renderer. The thumbs are no longer realtime. They are instead rendered once and cached so this will not slow you editor down with larger prefabs

            Dungeon Architect | Prefabricator

            Discord Support

            Comment


              Originally posted by Ali Akbar View Post
              I've made some major performance improvements to prefabricator and I'll push a new update tomorrow. It does the following:
              • Reduce the generation time of prefabs during creation and randomization. This is noticeable with larger nested prefab with thousands of children
              • Optimized the thumbnail Renderer. The thumbs are no longer realtime. They are instead rendered once and cached so this will not slow you editor down with larger prefabs
              Good to hear about the performance improvements.

              Comment


                Originally posted by Ali Akbar View Post

                I'd love to incorporate this into the plugin. You can share the code (preferably as a pull request in github) and I'll test and integrate it
                I have cleaned up the code, updated it to the newest version and created two pull requests.

                The first one is dealing with the local actor references. As I said before I use ItemID to lookup the correct actor when restoring the actor state. However, it is way from perfect/finished and I don't think you want to pull it as is. The known limitations are:
                1. it does not support nested prefabs
                2. soft references are kept unchanged - but I consider this feature as it allows you to reference the same actor from all prefabs while hard references are prefab specific
                The second pull request is dealing with another issue I have run into recently. If I try to spawn a huge amount of prefabs at runtime that contains components with collisions set to Query and Physics the game starts to choke and eats up all the memory. Upon investigations, I found out that all the components are spawned on top of each other which causes PhysX to deal with the overlaps when the component is registered (or at least I think so) and significantly slows down. Therefore, I have disabled serialization of RelativeLocation for root components. The relative location of the root component is redundant anyway as it equals to the actor location. Restoring the relative location will essentially put all spawned components (from different prefabs instances) on top of each other even if the prefabs are spawned at different places.

                Both pull requests were tested separately and in combination on a limited number of prefabs in my project. It works for all of them but it may break something else, so please feel free to reject the pull requests. I just hope it will give you a starting point to improve the already very handy plugin.

                Comment

                Working...
                X