当前位置:网站首页>Unity screenshot method
Unity screenshot method
2022-06-30 05:10:00 【Shannan HSY】
Here is my summary 、 stay u3d Medium , Three screen capture methods :
1、 Use Application Under class CaptureScreenshot Method .
This method , What is intercepted is the picture of the whole game at a certain frame , Or a full screen shot .
a、 Not for a camera (camera) The picture of , A screenshot .
b、 Screenshot of partial screen , It's not convenient to implement , It's also inefficient , It is not recommended to use... In the project :
although CaptureScreenshot What about this method , Don't do it yourself . But we can take the route of saving the country by curving to realize it . This is the idea : You can use this method to capture a full screen first , Then get the screenshot through the path ; Next, we will use the related graphic classes to , Take a partial area of this screenshot and save it , So you can get a partial screenshot . I will not realize it here , But those who are interested can try , It must be possible .

2、 The method of this second screenshot is , Use Texture2d Class , It can also realize the screenshot function .
Cut a full-screen ( Here's the picture , notes : Yes ui):
CaptureScreenshot2( new Rect( Screen.width*0f, Screen.height*0f, Screen.width*1f, Screen.height*1f));

Cut the middle 4 Divided ( Here's the picture ):
CaptureScreenshot2( new Rect( Screen.width*0.25f, Screen.height*0.25f, Screen.width*0.5f, Screen.height*0.5f));

Here are a few Texture2d Class method , There are also some points to pay attention to in use , See for yourself .
Of course , This method does not need to implement the function of screenshot for a certain camera . But key interfaces have emerged , It is Texture2d.ReadPixels(), Let's not talk about this paragraph , Let's look down !3、 This third method , The best , You can take a screenshot of a certain camera .
In this case , I can cut off , my Avatar What you see in the game scene ,UI Interface ( Use a special camera Show ) What is not supposed to be . Do that , We should separate them into one camera To display ui Interface , With another camera The camera displays the scene picture . then , We only take screenshots of the scene camera . So the key point is : How to take a screenshot of a camera . A new class used here is RenderTexture.
The code is as follows :
I won't say more , Find the relevant information by yourself , Because I don't understand either !
It goes straight to the picture above .
nothing ui Full screen view of :

Only ui Full screen view of :
Yes ui There is a full screen picture of the scene ( Only these two cameras are specified , The relevant tips are in the code “//ps” in ):

Source :http://blog.csdn.net/anyuanlzh/article/details/17008909;
边栏推荐
- 0 foundation starts self-study unit notes control direction becomes larger
- Unity a* road finding force planning
- Unity3d realizes Google Digital Earth
- Unity script life cycle and execution sequence
- Initial environment configuration of the list of OpenGL super classic (version 7) vs2019
- mmcv常用API介绍
- 003-JS-DOM-Attr-innerText
- GoLand No Tests Were Run : 不能使用 fmt.Printf() <BUG>
- Unity multiple UI page turning left and right
- Configuration and use of controllers and routes in nestjs
猜你喜欢
随机推荐
PWN Introduction (2) stack overflow Foundation
Under what conditions does the Z-index attribute expire?
Unity packaging failure solution
Unity 3D model operation and UI conflict Scrollview
力扣(LeetCode)180. 连续出现的数字(2022.06.29)
Passing values between classes using delegates and events
C # equipment synthesis
力扣977. 有序数组的平方
Unity script life cycle and execution sequence
The difference between SVG and canvas
力扣2049:统计最高分的节点数目
Unrealeengine4 - about uobject's giant pit that is automatically GC garbage collected
Unity dotween plug-in description
Solution to Autowired annotation warning
JS 数组的排序 sort方法详解
[notes] unity Scrollview button page turning
Unity animator does not clip animation to play animation in segments
Log writing specification
Detailed explanation of sorting sort method of JS array
Nestjs配置静态资源,模板引擎以及Post示例









