-
Notifications
You must be signed in to change notification settings - Fork 223
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Support for more than just UTexture2D with RegisterTexture() #35
Comments
You might be the first person using it... at least the first that I know about. Other then a simple example, I don't use it much myself, just thought it would be good to support it ;) And yes, copying would be a nasty workaround. Right of the bat, I cannot tell you what exactly will be possible or necessary. If I find a bit of time this week, I will try it. But I can already tell you a few lines that will be deciding. If you look in the ImGuiWidget.cpp line 664: const FSlateResourceHandle& Handle = ModuleManager->GetTextureManager().GetTextureHandle(DrawCommand.TextureId); The resource handle is what I need to pass to Slate API to draw that texture. The texture id from draw command is the same one that you get in a handle after you register your texture, and the same one that you later pass to ImGui functions. That id is used to find a texture entry ( If you look at the For external functions this constructor is called with |
After a quick look, you could try this:
If everything compiles and works then this is it. |
So I tried your suggestion (second post) but it's not working, all I'm getting is a My guess is because the Slate brush creation fail, I recall having similar issues with UMG/Slate which I solved by creating a rather simple dynamic material instance and feeding it my texture. I then created the brush from the material with the right constructor. I'm wondering what would be the best course of action here, maybe being able to feed my own Slate brush to the TextureManager instead of letting it create it for me ? |
How would you create those brushes? Forgive me ignorance but other than in this plugin and occasional customization details, I don't use Slate that often (even less UMG). If all we need are different brushes or creation methods then maybe we could switch that based on a texture type. But ultimately, feeding your own brush could also be an option. P.S. If you could point me to a simple repro of one of your use cases then I could try it. Are there some engine assets that I could use for test? |
I think a solution could be to simply offer an overload with a You can take a look at the For the pink image, the problem was on my side : I'm releasing my image handles before ImGui has the time to draw them on screen, leading to the pink result. So my render targets work fine in the end with just the UTexture2D to UTexture change. :) |
OK, I'll look at those functions.
Oh yes, you cannot do that according to the contract ;) When it comes to copying resources (I somehow thought that you asked about that but I read your comment again and apparently you did not), it would be something to consider but in general, I'd prefer to avoid that. One reason is that when you have to register and unregister then we are in agreement what is the lifetime of those resources. By managing texture and handle you are in control of those resources. On the other hand, it could be possible to give an option to copy and it would be kept until you ask to remove it by unregistering a handle... so maybe I am over-restrictive here. Just came to that conclusion while writing this reply ;) So this might be something to think about. I'm not sure I like the idea of using UObject as I hate type-unsafe code, but definitely a few overloads would make sense. And in the worst case, if there is no better option UObject can also do. |
I tried to pass different objects, like materials, and while they got registered and resource created, the resulting image in ImGui was invisible. Not sure why that happens, I may need to debug it and maybe take a deeper look into the |
I confirm that materials work for me, but I made sure the material domain was set to Also I'm using
|
The TextureManager only handle UTexture2D objects and not Render Target textures (UTextureRenderTarget2D or UCanvasRenderTarget2D for example). Do you think it could be possible to add that support ? Those two class inherit from UTexture and not UTexture2D.
I have plenty of render targets that handle custom effects and I often display them on screen for debug. So being able to display them via ImGui would be very handy.
A workaround could be to use CreateTexture() to convert the render target resource, but that would require to do a copy (and an expensive one).
The text was updated successfully, but these errors were encountered: