Using Unity's new Entity Component System - unity3d

I would like to ask when to use ECS. My logic is telling me, that I should use it only when I need to control a larger amount of objects. Am I right, or should I use it everywhere?

My logic is telling me, that I should use it only when I need to
control a larger amount of objects.
Not really but it helps when it's used to control many objects. This is not the only or main objective of ECS. See the list reasons why ECS should be used below:
Performance
Memory Management
Build Size
It's not only used when you are working with many objects, it's also used to manage the memory. It reduces the amount of memory required when ECS is used than when the Unity's component system is used. Also, it reduces the build size too. With ECS, you can reduce the build size of your project. ECS makes it possible to use Unity's API as modules, You can decide which modules to include in the build therefore reducing the project size. For example, you can decide to remove the physics system if you don't need it in your project.
Finally, ECS is really important when it comes to building lightwight projects. For example, if you want to build a lightweight game or interactive program that would run on other smaller devices as an Ad, ECS should be used here since it will reduce the size of the Ad, loading time, the memory footprint. You should watch this video and visit the Unity's ECS page to learn more about it.
So,when should you use ECS?
When you need performance, want to conserve memory, reduce the build size of your project or create a lightweight program. Of-course there are many other uses of it. It's still new and we will find out more about it very soon.

Related

Is it better to have plugins loaded at runtime or direct code integration?

I'm in the process of making an app which I was hoping could have optional modules/plugins depending on what the user needs. Concretely, the host application would be lightweight (mostly a text/markdown editor) and I'd add the ability to use plugins. However, some plugins could be fairly heavy (for example a 3D viewer).
Would it be better to have plugins loaded at runtime at the cost of performance or to directly integrate those with the main code with an ability to turn them off at the cost of space? Ideally I'd want both high performance and low volume, but if I had to pick one I'd choose performance.
Feel free to suggest alternatives! I'm not too familiar with modular programming :)

Unity3D's upcoming ECS vs current hierarchy

Intro
I've been following Unity3D's DOTS development for a while now and I've been doing a few tutorials on getting ECS going. However, nowhere have I found it to be clear that Unity3D is deprecating their current GameObject/Hierarchy approach and replacing it with the new Entity/ECS approach.
Theories
At present, it seems like a hybrid between the two, so anything that typically belongs in a object pool or could cause memory fragmentation (projectiles, items, respawning units, etc.) uses Entity/ECS, and the rest still use GameObject/Hierarchy.
This seems less than ideal to me since the non-optimal approach will block going to the next frame where the optimal one will wait. Where if only ECS was used, you will get a lot more frames out, which is kinda the point...
On the other hand, having to onboard designers and animators to use something like ECS would just be expensive (at the moment) and much more technical. The current ECS window in the editor is not really intuitive and less a tool than simply a result output.
Question
So my question is, does Unity3D plan to keep the hybrid approach and if so, how do we choose whether to use an entity or a gameobject? Or if they are going with the ECS only approach, will the current entity editor window be changed to accommodate designers/animators?

Unity: how to integrate external compression into build pipeline

Background
Hello everybody, I am a beginner in Unity and I am planning on building a small mobile game. Because size is such a critical factor in small hand held devices, I have searched for ways to reduce the resulting APK/IPA file.
One solution I have encountered is to use proprietary compression algorithms by providers like https://kraken.io/.
I was wondering if it was possible to replace Unity's built-in image compression solution with API calls to https://kraken.io/
Question
Is it possible to write custom build scripts that loop over the resulting build and replace the respective image files with the ones outputted by kraken?
Could anyone point me in the right direction on how one would achieve this? Any suggestions or help will be much appreciated.
You can reduce the disk space by enabling Use Crunch Compression on your textures. This will behave similarly to what Kraken does. One limitation is that textures must be power of 2.
Here's a screenshot of a texture from Kraken with similar results when it comes to file size.
Note that the pixel counts is lower in Unity due to PoT conversion.
Although file size is important, there are other aspects to keep in mind when building your game: keeping draw calls down by using automatic or manual batching and loading assets on demand.
Addressable Assets is a way to externalize and manage game assets to handle dependencies for on-demand loading and content updates.
For batching, it depends on the type of game you are creating. For 2D you can use sprite atlassing. Also Texture Packer is a good solution I have used in the past.
hth.

How can i add custom behavior using pure ECS (Entity Component System) in Unity?

We are currently making our dream game with thousands fast dying zombies.
Problem is - we are making it for mobile devices.
Hybrid ECS is not enough, cuz even 100-200 low poly zombies is to heavy for render even after ultimate optimization.
Solution is use only pure ECS. Followed this tutorial i can spawn now 2-3k zombies on 40-50fps on low end devices.
But, im stuck on adding behavior. I just cant add it on each entity. By getting this tutorial as example - how to add custom behavior like AI scripts/systems for each cube?
I tried to add "system" on it, but it applies only on GameObject that u use for getting copy's.
P.S. I dont want to use external ECS frameworks, cuz im sure in future Unity built-in ECS will be the ultimate "from box" solution.
You don't. With Unity ECS you register systems. Systems work on entities that have certain components attached. E.g. you can create a system that processes all Zombies (e.g. all entities with a "Zombie" component) and execute some logic for them in each tick. The trick with ECS is that you do not handle each entity separately but you run logic for all entities that share certain criteria. This is why it is so fast, but it requires to let go of the Monobehaviour approach, mentally. I found this tutorial helpful in getting some start of actually implementing logic: http://infalliblecode.com/unity-ecs-survival-shooter-part-1/
It's not 100% up-to-date but it should be enough to get you an idea how things roll with ECS.

what are the benefits of using smaller temporary views vs larger persistent views on memory mapped files

i am fiddling to make my own storage engine, it is mostly for my own education.
so far i have a very good working solution with memory mapped files, but something is bothering me and i dont want to get bit by this later. i am basically mapping a view of my whole file and only create a new view if i have to resize the file. i know that this approach has one obvious drawback: maximum size, for now but i can live with that, i really dont intend to store data exceeding gigabytes.
but are there other considerations? how does this one large mapping interact with the os memory management routines, what about the long run? are there performance and fragmentation issues that i could run into by using this approach?
using smaller views over areas of the file i need will certainly remove the limit of the size of the database i can make, but then that is an extra layer of management i have to do in my storage engine, that i would rather avoid if i could.
i have only just scratched the top of an iceberg, and if someone could be my radar i could surely avoid some fatal crash!