Giter VIP home page Giter VIP logo

Comments (6)

soraphis avatar soraphis commented on May 24, 2024

shouldn't be that much of a problem.
I've implemented it in my fork: soraphis@20ac23e

using C# events. The important part is to ensure that events are unregistered. this could be a problem within the editor, but I think my usage of 'OnAfterDeserialize' should fix this

from unity-atoms.

AdamRamberg avatar AdamRamberg commented on May 24, 2024

First of all, the IGameEvent interface is totally unnecessary. It's a left over from when I started the project. Will remove it in a future commit.

Regarding the IGameEventListener, that is a different issue. I have actually tried the same approach as @soraphis is doing in this fork. However, this did hurt performance way too much and it's unfortunately not a viable option (even though it is much more elegant code-wise). Maybe I did something wrong and it's worth a second try? Or maybe there are any other approaches to this problem (can't think of any now though)? I agree with you @mutmedia that it is really awkward when using 2 events of the same type in the same class.

from unity-atoms.

AdamRamberg avatar AdamRamberg commented on May 24, 2024

Removed IGameEvent in 16ab226

from unity-atoms.

soraphis avatar soraphis commented on May 24, 2024

However, this did hurt performance way too much and it's unfortunately not a viable option

oO thats interesting.
i just looked a bit around and found this article: https://jacksondunstan.com/articles/3043

first: I would not have thought that events would get worse with repeaded use within a short timespan, but I think the conclusion of this article is pretty fitting.

Now that we’ve established which is faster—interfaces—the question becomes: should you bother? Interfaces are definitely more work to set up, harder to read, more error-prone, and more difficult to integrate into your code.
Say your game had a thousand callbacks per frame. That’d be a lot of callbacks, but still 100,000 times less than this article’s test results show. Even in the slowest case—events with multiple callback functions—you’d only be using 0.00749 milliseconds to call all the callbacks.

from unity-atoms.

AdamRamberg avatar AdamRamberg commented on May 24, 2024

@soraphis Will read the article when I get time this weekend!

I could definitely try doing the move again and then try it in my current game project. If the performance / framerate is not hurt then great, but if it is noticeable it's unfortunately a no go.

from unity-atoms.

AdamRamberg avatar AdamRamberg commented on May 24, 2024

GameEvents are now using C# events since commit d551947 (branch canary). Seems like no noticeable performance hit when implementing it. Not sure why I got such a performance hit last time (probably did something stupid in the implementation).

Thanks for the input everyone! Closing the issue.

from unity-atoms.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.