I'm looking into progressive draw to canvas in flutter.
I know about CustomPainter, but somehow the canvas gets cleared between the two paint events.
What I'm looking is to add just changes to the canvas, not drawing everything that has to be drawn on canvas. Imagine a sketch app where I'd just add new lines to the canvas instead of redrawing it each time paint is requested.
Related
I'm using Unity 2022.1.23f1 and the Universal Render Pipeline. I have a render texture, set to 480x270 with point filtering, to get a cool pixelated effect. In my scenes, I output the camera into the pixelated render texture and render it in a raw image under a Screen Space Overlay canvas. This makes it so that everything is rendered in 480x270.
Everything worked perfectly fine in the main gameplay, as there aren't any UI buttons to press. However, in my main menu scene I have three UI buttons for starting the game, accessing the options menu and quitting the game. The main menu is in 3D, featuring a desk with a monitor on it. I thought it would be cool to have the UI buttons look like they're on the monitor, which is why I made a World Space canvas, where I positioned the three UI buttons on the monitor.
I thought it would be easy to make the buttons interactable, but they don't work. I'm sure it's because the pixelation effect is blocking the UI buttons on the World Space canvas.
I removed the pixelation effect, along with the Screen Space Overlay canvas which holds it, and the buttons worked perfectly.
I googled the problem and found someone saying to remove the Graphic Raycaster component in the Scren Space Overlay Canvas, but that didn't work. I also turned off "Raycast Target" in the pixelation effect's raw image gameobject, but that also didn't work.
Is there any way to make it so that I can interact with the UI buttons in the World Space canvas, while also having the Screen Space Overlay canvas with the pixelation effect? Any help - or even suggestions to make a better pixelation effect - would be appreciated!
I just added 3D Text on my scene and it is invisible on the background of Canvas, that is "Render Mode: Screen Space - Camera". How i can make it visible on background of my canvas?
There are 2 ways to fix this:
Change the Sorting Layer of the obstructing object to be one behind that of the text, or change the Order in layer of the obstructing object to be lower than that of the canvas.
OR
Create a new canvas with a higher Sorting Layer (you may need to create a new one) or Order in Canvas and place the text in the new canvas.
As an example, here I have my normal text in a lower canvas, but I created an overlay canvas for text that absolutely must go above everything else.
I find that the second solution is a better general solution for the issue, as in the first solution you have to change the layers for every object in the scene that might obstruct your text.
Does anyone know how to make a transparent canvas in custom paint in Flutter? I have some drawings on one canvas and others on a different canvas. I want to merge these two canvases (2 layers) as one. However, since the canvas is not transparent, this seems to be impossible in Flutter. I wonder if this can be done by using paint BlendMode?
Is it possible to take a screenshot of the screen using flame and flutter? So when the user clicks a button, it will share the screenshot with anyone he chooses to share it to.
Since you are specifically using flame, you are in luck! Flame renders your game on the canvas. Your game render method takes a canvas and draws a frame of your game.
Normally the canvas provided is the device screen, but can easily call the render method yourself with a different canvas, say, an image.
final PictureRecorder recorder = PictureRecorder();
final Rect rect = Rect.fromLTWH(0.0, 0.0, game.size.width, game.size.height);
final Canvas c = Canvas(recorder, rect);
game.render(c);
final image = await recorder.endRecording().toImage(game.size.width, game.size.height);
Then you can save that image on, let's say, a file, or in memory.
Now note that this will render only your game, and will render the exact frame you are in when you call this. But I assume that is what you want since you specifically tagged this question with flame. There might be better ways of screenshooting with Flutter in general, but using flame, this is the best way.
I am trying to post an image of my game hero to facebook. So I instantiate the prefab which contains number of UI elements, icons and texts.
I'd like to get a Texture2D or image data from it so I could send that as a payload to my facebook plugin.
If it was visible in camera and it wasn't a UI element I would get its texture from the camera, if I let it appear on the screen the full screen camera won't be looking at it, because it is rendered using canvas. Also canvas is also looking at other objects around it because this prefab doesn't occupy full screen.
I may be wrong but I don't think that you can render the UI on a texture. It doesn't seem ideal, but you could use CaptureScreenshot, then load the image and cut the part you want based on the resolution of Screen.