Giter Club home page Giter Club logo

Comments (6)

roboryantron avatar roboryantron commented on July 20, 2024 6

I am glad that people have reached the need for arguments, it is the natural next step!

If you want to head down this path, you need a GameEvent definition and then extend it with a GameObjectGameEvent : GameEvent. To leverage a listener with a Unity event, you will need to define new listener class and a Unity event that takes GameObject as well. I tend to end up with int, bool, and float events as well as other custom types.

The version of events that I built in the studio supports argument passing by way of generics and code generation to avoid boilerplate code definition. There is a dropdown to select the event type (it reflects all applicable types from the assembly) and will auto-gen classes if necessary. When dropping an event into a listener, it will automatically change the type of the listener to one that handles that event. I can not share the source for all of this, but the concepts are still valid.

from unite2017.

roboryantron avatar roboryantron commented on July 20, 2024 1

Nice catch! They kind of grew into each other over time. My current implementation has variable extending event, making them even more similar. and allowing for more code reuse including the code-gen stuff for new types.

I consulted with a lot of our designers concerning the idea of just making them the same thing. but everyone wanted the semantic split between event and variable.

from unite2017.

Mixtrate avatar Mixtrate commented on July 20, 2024

I'm trying to connect this question with #8. the set references a gameobject maybe? so can an event do this as well?

My understanding of this is not complete.
image

from unite2017.

IsaiahKelly avatar IsaiahKelly commented on July 20, 2024

Since GameEvent is just a ScriptableObject you could eaisly modify it and the GameEventListener and the UnityEvent Response to take an argument which contains the data you wish to pass along (GameObject, float, Vector3, etc.).

from unite2017.

IsaiahKelly avatar IsaiahKelly commented on July 20, 2024

@roboryantron One small question: What's the actual difference between a GameEvent and a Variable in your production system? With your example code I quickly realized that I could just transplant the GameEvent listener code into a Variable to remove the need for an Update method to check for changes, but doesn't that mean I just changed the Variable into a GameEvent that now passes a parameter?

from unite2017.

IsaiahKelly avatar IsaiahKelly commented on July 20, 2024

Interesting... Yeah, extending variable from event makes sense because you can think of an event as a kind of parameterless variable. Which is basically what I was going to make them in my own implementation. I have no problem with just calling them all variables, but I can see how a designer would prefer the separation.

I'd also just like to say that I find your designer friendly approach to things incredibility refreshing. It feels like so many programmers are really hostile towards the idea of giving designers any kind of power. I'm sure their views are somewhat justified, but it's really nice to find a programmer that has faith in the designer and wants to empower them. I can only guess this is because you've seen the war from both sides. 😉

Thanks for sharing all this knowledge with the community! Your latest Unit talk is probably the best one I've ever seen, and that's including the new job systems talk. 😁

from unite2017.

Related Issues (11)

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.