Is there a way to SWAP all references of object A to object B in RUNTIME

Lets say i have 2 textures, A and B.

As an example, i have like 200 different actors and materials that reference texture A.

They all are placed in level, but now i need to change ALL the A refs to reference object B.

Everything is happening in runtime, i dont need to save these changes after my game stops

To change anything about a material runtime it must have that value set as a parameter in the material and you must create and assign a DynamicMaterialInstance of your material to each and every object using it.

Now I have no idea weather a bunch of objects can share the same Dynamic Material Instance. If they can, you can change the parameter in one place. If they can’t though and each object has it’s own instance then you are really out of luck.

If you are talking specifically for the texture, you can use a virtual texture and draw whatever you want on it.

There must be a way to replace the whole material shader runtime as I imagine it would be useful for the visual setting, but I don’t really know if and how.

Texture is just an example. it can be any UObject. Sure thing that i can create a texture parameter

depends on how your code is set up

in general you’ll have an array of references and you do a For Each loop that matches the references by some rule and sets the new reference

question is too vague to say much beyond that

The easiest solution ive got is to change the loaded asset memory adress’ value directly. I need some kind of a superfunction, that can be used with everything. No any dependensies in it.|

I dont know to create the first solution tho.

Why not just create a base actor and change the referenced texture in all actors of class?

Not possible. Im trying to make an Asset Localization plugin, that changes the localization of an asset in runtime.

The best answer I would have for that is look into how Lyra does it. Although those assets swapping wouldn’t be runtime to my knowledge. Sorry I can’t be of more help.

1 Like