How to gracefully Reset DOTS at runtime

1) How to gracefully reset DOTS at runtime
2) The shader rotated by the vertex shader cannot work properly on the image
3) FrameBuffer Fetch displays full purple on the mobile phone that supports it
4) In the Unity system, the Android side judges Is the GamePad file in


This is the 328th UWA technical knowledge sharing push, which selects hot topics in the UWA community, covers UWA Q&A, community posts and other technical knowledge points, to help everyone master and learn more comprehensively.

Script

Q: The DOTS environment is 1.0.0 preview
Requirements: Combat in units of "rounds", stand-alone mini-games.

At present, I need to manually pull up all the systems at StartCombat, and manually disable all systems at EndCombat. These systems are all in the Default Inject World, and the functions can barely be realized, but they are not elegant enough.

Since DOTS projects are very rare, and basically all examples have not considered this problem (they all seem to enter the battle after clicking to run the game, without considering the "round" as a unit), so I ask everyone for an elegant approach.

A: The issue of this problem shows that the design ideas of the ECS system are not well understood. The NativeContainer (that is, State, data related to the bureau) saved in the System needs to be manually ResetSystem.

The real ECS design idea should be that the System does not contain any State at all, so you can’t save trouble. Take the previous XXXManager design idea: The XXXManager design idea refers to a single instance with a Map, and there are N methods to add, delete, and modify Check this map.

Therefore, a system with a pure method set not only does not need Reset, but can even dynamically reload code segments. We only need to destroy all Entity CMPs to complete Reset.

Thanks to the subject Liu Taiyan @UWA Q&A Community for providing an answer


Rendering

Q: The overall idea is to realize the controllable rotation of the image in the UI, but found that when the Shader is placed on the Image, once it moves, it will be completely messed up. I have tried to enable DisableBatching, but what is the problem? Tried scaling as well, still have similar issues.

float4 flip_base(float4 vertex, float2 uv)
{
float2 pos;
float2 center = float2(0,0); // 这个地方可以通过 BaseEffect 通过CPU 计算后 uv1传入,这里简化了。
// 尝试过的缩放
 //vertex.xy *= _FlipProgress;
//return vertex;

float2 dt = (vertex.xy - center.xy) * 100;
float len = sqrt(dot(dt, dt));
float theta = -len * _FlipProgress * pi;
float2x2 rot =
{
cos(theta), sin(theta),
-sin(theta) ,cos(theta)
};
dt = mul(rot, dt);
pos = dt + center;
vertex.xy = pos;
return vertex;
}

v2f vert(appdata v)
{
v2f o;
o.uv = v.uv;
float4 vertex = flip_base(v.vertex, o.uv);
o.vertex = UnityObjectToClipPos(vertex);
return o;
}

The sample project is as follows:
https://uwa-public.oss-cn-beijing.aliyuncs.com/answer/attachment/public/113133/1677233402885.unitypackage

In response to the above problems, experienced friends are welcome to go to the community to exchange and share


Rendering

Q: FrameBuffer Fetch displays full purple on mobile phones that are confirmed to support it, whether it is Color Fetch or Depth Fetch. May I ask if there is anything missing in my DepthFetch implementation?

In response to the above problems, experienced friends are welcome to go to the community to exchange and share


Android

Q: How does Google Play on the Android side judge the existence of a GamePad? Do you have any good methods? Overseas GamePad may also exist in multiple locations, such as an external memory card?

A: To check whether the GamePad exists on the Android device, you can use the API provided by the Android system to check all the input devices connected to the device and find out whether there is a GamePad input device.

This method can only detect hardware GamePad devices connected to the device. For overseas GamePad, if the file is stored on the device, you need to use the file system API to check, otherwise you need to rely on the hardware API to check the connected GamePad device. At the same time, this code fragment needs to add a permission declaration in the AndroidManifest.xml file to search in the external storage device.

Thanks to Qingfeng Yifeng@UWA Q&A Community for providing answers

The cover image comes from the Internet


That's all for today's sharing. Of course, there is no limit to life but no limit to knowledge. In the long development cycle, these questions you see may be just the tip of the iceberg. We have already prepared more technical topics on the UWA Q&A website, waiting for you to explore and share together. You who love progress are welcome to join, maybe your method can solve the urgent needs of others; and the "stone" of other mountains can also attack your "jade".

Official website: www.uwa4d.com
Official Q&A community: answer.uwa4d.com

 

Guess you like

Origin blog.csdn.net/UWA4D/article/details/129580561