Jump to content
  • Advertisement

Prastiwar

Member
  • Content count

    5
  • Joined

  • Last visited

Community Reputation

7 Neutral

About Prastiwar

  • Rank
    Newbie

Personal Information

Social

  • Github
    Prastiwar
  1. In this article tutorial you'll learn how to fix any error you'll ever get. I believe it's definitely not one of these boring articles, let it go and read it two times. Have fun. Hope you'll learn something
  2. Some thoughts about ECS Part 1: Unity ECS - briefly about ecs Part 2: Unity ECS - project design Part 3: Unity ECS - operations on Entities Part 4: Unity ECS - ECS and Jobs The rule of thumb explanation How does ComponentSystem often look like: public class SomeSystem : ComponentSystem { private struct Group { public readonly int Length; public EntityArray Entities; public ComponentDataArray<SomeComponent> SomeComponents; } [Inject] private Group m_group; // Inject the group entities with given components protected override void OnUpdate() { float dt = Time.deltaTime; // Nice cached deltaTime, we're on main thread, so we can use Unity's API for (int i = 0; i < m_group.Length; i++) { // some operates on data } } // System was enabled (ComponentSystemBase.Enabled = true) protected override void OnStartRunning() { // probably some more caches for optimization, preparation for Updates } // System was disabled (ComponentSystemBase.Enabled = false) protected override void OnStopRunning() { // probably some clean up } } Let's take a look at this first: struct Group { public readonly int Length; public EntityArray Entities; public ComponentDataArray<Foo> Foos; public ComponentDataArray<Bar> Bars; } What is group? Group is filter of all Entities in active world that have Foo and Bar component It's like array of matching entities with references to all specific given components. So, group is like EntityArray but with references to components, EntityArray itself is just array of Entities (and entity is just an index). Group is constructed with a set of required components, subtractive components. It's also synced. Why do we have Length field? Isn't Foos.Length the same? Yes, you are rigth! They're the same. Length is length of EntityArray, so also Length of Foos and Bars, because each entity has Foo and Bar component It's more obvious in this case: for(int i; i < m_group.Length; i++) { // Using m_group.Foos.Length or m_group.Bar.Length would be a bit confusing in this case // because we iterate over all entities and can get access to ANY of their components } To summarize - every array in injected group would have same Length, because it's length of Entities and each entity has every given component. Separation of Length field is just for convenience. How to manage indexing? The injection magic. for(int i; i < m_group.Length; i++) // iterate over all entities from group { // It's safe to iterate like that, because every array in group has the same length // and indexing is also injected(synced) in that way to use it exactly like this: var actualEntity = m_group.Entities[i]; // Actual iterating Entity var actualFoo = m_group.Foos[i]; // Foo component "attached" to actualEntity var actualBar = m_group.Bards[i]; // Bar component "attached" to actualEntity } How do I manage lifetime of systems? Well, you don't really need to! Unity takes care about that. Systems track injected groups and will be disabled if there are no matching Entities and will be enabled if there appears one as well. But if you really want to, take a look upwards, see OnStartRunning and OnStopRunning ? I mentioned ComponentSystemBase.Enabled = true which is probably what are you looking for. It's property that allows you to active/disable system manually. Systems don't update in order I want Convenience attributes for rescue! Since all systems are updated on the main thread, you need to think about order of updates, there are some attributes to help you with it: [UpdateAfter(typeof(OtherSystem))], [UpdateBefore(typeof(OtherSystem))], [UpdateInGroup(typeof(UpdateGroup))] where UpdateGroup is empty class. You can even control update before/after Unity's phases by typeof(UnityEngine.Experimental.PlayerLoop.FixedUpdate) or other phases in same namespace. How can I get access to system I want? You can just inject it just like [Inject] private YourSystem yourSystem; easy as that. You can also use World.Active.GetExistingManager<YourSystem>() or if you're not sure if it exists but it should, use World.Active.GetOrCreateManager<YourSystem>() Why to use EntityArray in system? What can I do with this index? Since systems most often operates on components, not directly on entities, it raises question "Why do I even need this index". Saying "it's just and index" doesn't mean that is not usable at all. It's very important integer. If you haven't tried Unity's ECS implementation, you probably don't know where is it needed. It's needed among others for functionality from EntityManager that holds EntityData and controls adding/removing (and much more) components from a given entity. But actually you don't want to add/remove components via EntityManager. You'd rather do it after update to not break the group (you'll get error about accessing deallocated nativearray), so you want to use PostUpdateCommands (EntityCommandBuffer). More about that in one of futures part of article. World vs EntityManager EntityManager is not weird, magic class, it's ScriptBehaviourManager and "merges" entities and their components. In ECS we have a lot of managers. ComponentSystem is also ScriptBehaviourManager ! World holds all managers in one piece. We could colloquially say it manages the managers. I know what's your question - yes, we can create multiple worlds, sounds interesting, isn't it? Maybe we'll take a look at this in future. ComponentData and SharedComponentData. What's the difference? The difference is trivial, ComponentData is just a component, SharedComponentData is as it says, component shared between different Entities. Very good explanation you can read in docs: So, with same IComponentData (eg. Position) changes from Entity0 won't change Position from Entity1, ut with same SharedComponent (eg. Renderer) if you change material from Entity0, it'll change also material from Entity1. However you don't really want to change SharedComponents a lot, actually very rarely. More details THERE. Well, there is one more difference - ComponentData have to be blittable. Oryginally published at: https://connect.unity.com/p/part-1-unity-ecs-briefly-about-ecs Go further: Part 2: Unity ECS - project design Give me some feedback in comment section, don't worry I won't hate you if you show me some "anomaly" in my article. If you enjoy my article - like it and follow me. It'll motivate me to write more articles. See you.
  3. Prastiwar

    Unity dropping Monodevelop a let down for small indie?

    Fair enough, I totally agree with it. Unreal blueprints are powerful enough to make a game without struggling with coding. So, that's why I can't understand it - because I've never had any crash and freeze, VS solution doesn't need to be rebuilt, I can save and switch to Unity which recompiles scripts and voila. IntelliSense works like a charm. VS freezes editor only while it's loading, not a big thing. Some people can have problems with software, that's understandable. Right. If I had those problems I wouldn't choose it too. I believe it's just move to get more modern computer, to not stuck back, but it's not so big move to high-tech, VS is not that heavy. I think big companies should go for modern, stable and mature development. It had to be finally done. All software will be obsolete someday. 2018 is a modern version, BUT you still can use 2017 version for a long time (LTS idea) and use MonoDevelop. As I mentioned above, so you can use MonoDevelop, but in 2017, which will be supported for a while. I think if they left it without support in newer Unity's version, it would be problematic in short time (a lot of bugs and lack of stability). I'd sum it up to If you use older hardware, use older software. Older hardware you have, older software you'll use.
  4. Prastiwar

    Unity dropping Monodevelop a let down for small indie?

    Wait, installing VS with unreal is 4.20 feature, you need to install it outside Unreal's downloader before 4.20 My comparison where Target Platform is just Android (all sizes are from downloaders) VS install outside downloader to be fair since it doesn't come with Unreal. before 4.20 (and it's "cheaper") Unity 2018.1.5f1: Core = ~2 GB Android Support = ~1 GB VS Unity Tools = ~3 GB Unity HUB(preview) = ~200 MB VS Community = ~1 GB Project size scalability: wow, is small complete project 100 MB? Total: ~7 GB Ease of use: Big advantage, fast prototyping, Indie as main target. Lowest price LAPTOP to work with engine comfortable*: 700$ Game Quality Scalability: Yeah, that's big con of this engine (from 2018 graphics is priority for next year) Unreal 4.19.2: Core = ~9 GB Editor symbols for debugging = ~17 GB Android Support = ~5 GB Windows 10 SDK needed = ~3 GB Epic Launcher = ~500 MB VS Community = ~1 GB Project size scalability: well, I've not worked with Unreal much, because of my laptop (or unreal optimization?) so can only say 200 MB is not even starting. Total: ~35 GB Ease of use: Big disadvantage, main target game is AAA. Lowest price LAPTOP to work with engine comfortable*: +1200$ Game Quality Scalability: Yeah, that's a big advantage of this engine (most beautiful) * Saying comfortable I mean 30fps is the lowest possible fps Yeah, HDD's are really cheap, but I think we are talking about SSD's, which are not cheap at all. I can't imagine working on the engine that is installed on HDD. Then it brings up why it isn't used to replace Monodevelop or any lightweight editor that isn't scary for inexperienced programmers. Unity has ambitions to be bigger and target higher and higher. VS is the main target with the highest support since it's the most powerful IDE, but it doesn't mean others are not supported at all, however, I'd like to see editor alternatives included in downloaders, it'd be nice. I've never understood this impression of heaviness, VS and MonoDevelop UI are almost the same for me. In fact, VS loads ~5 sec longer than MonoDevelop, but I don't find it a big difference. When I started programming I chose VS because it was much more friendly for me. My first editor I've tried was MonoDevelop (tried for a week), but autocompletion, navigation etc. was so bad then I switched to VS and said "wow this IDE reads from my mind"
  5. Prastiwar

    Unity dropping Monodevelop a let down for small indie?

    Well when working on remote teams like hobby projects, then this can be a real problem. Lots of team member could be working from locations with less than ideal internet or working on old computers. And 20 GB difference between Unreal and Unity you say it's almost the same size? I use 5 years old laptop with 120gb SDD. Small size of hardware is important for me, but not as important as comfortable work. MonoDevelop is very oldish and doesn't really help you programming as VS does. VS speeds up workflow a lot. 20GB more on Unreal is a big difference for me. I wouldn't say it's almost the same size. However Unreal is like 1000% more heavy than Unity since you can't work on it on (not even much) older computer. However I just checked, Unity takes 4 GB(with SDK's, JDK's etc.), VS doesn't even take 2 GB (most of it I have on another drive). Unreal is 45 GB, So it's even bigger difference ~40 GB MonoDevelop in Unity was used by a really small group of people, it's not a shame to switch to modern IDE and discontinue the old one. There are some alternatives to outdated MonoDevelop, you can try VSCode which is lightweight and fast and IS SUPPORTED by Unity pretty well. Also, I've heard that someone uses Sublime Text with Unity autocomplete plugin.
  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!