GithubHelp home page GithubHelp logo

fredwen2008 / edriven Goto Github PK

View Code? Open in Web Editor NEW

This project forked from dkozar/edriven

0.0 1.0 0.0 402 KB

Unity3d event driven framework

Home Page: http://edriven.dankokozar.com/

License: MIT License

C# 97.99% Smalltalk 2.01%

edriven's Introduction

eDriven Framework

Event-driven / asynchronous framework for Unity3d.

Author: Danko Kozar

Concept

  • eDriven framework is the result of 10 years of programming experience, self-education and research.
  • This framework turns Unity into an asynchronous system.
  • It’s inspired by RIA (Rich Internet Applications) frameworks, such as Apache Flex and other Actionscript and Javascript frameworks.
  • The idea behind building a framework was to bring the event-driven (publish-subscribe type of) programming paradigm to Unity.
  • There have been a number of libraries for Unity, but I decided to go with my own. That’s because I wanted to build additional libraries upon my event-dispatching system and wanted the total control.
  • .NET framework events were not appropriate.
  • There are two parallel event-dispatching systems inside eDriven:
    1) Signals
    2) Events
  • Signals are inspired by Robert Penner’s Signals and are used for framework internals. Signals are faster than events because there’s no instantiation involved. Also, your class isn’t required to inherit some base (dispatcher) class.
  • Events are more common and are inspired by DOM Level 3 Events. They support event bubbling, which is the important feature for GUI. The class that needs to dispatch events must inherit from EventDispatcher class.

Event syntax

button.AddEventListener(MouseEvent.CLICK, ClickHandler);

private void ClickHandler(Event e) // eDriven.Core.Events.Event
{
	Button button = e.Target as Button;
	Debug.Log("Clicked button with label: " + button.Text);
	
	// or
	MouseEvent me = (MouseEvent)e; // we got to know the type of the Event
	Point position = me.GlobalPosition;
	Debug.Log("Clicked at position: " + position);
}

Signal syntax

button.ClickSignal.Connect(ClickSlot);

private void ClickSlot(params object[] parameters)
{
	// do something with parameters (we got to know the number of parameters and each one's type)
}

Core classes and utilities

eDriven framework contains a number of classes:

  • SystemManager (emits system signals)
  • SystemEventDispatcher (dispatches system events)
  • MouseEventDispatcher (dispatches mouse events)
  • KeyboardMapper (easy mapping for keyboard gestures)
  • CallbackQueue (implements queuing of async operations)
  • TaskQueue (sequences async operations)
  • PowerMapper (maps strings to stuff)
  • AudioPlayerMapper (maps strings to AudioPlayers)
  • Cache (caches stuff)
  • ObjectPool (prevents instantiation and garbage collection problems)
  • Timer (handy source of timed events)
  • HttpConnector (loads stuff from the web and triggers responders when finished)
  • JavascriptConnector (talks with a host web page)

… and many others. They all serve the purpose of the framework: making the asynchronous, event-driven programming possible with Unity.

Resources

edriven's People

Contributors

dkozar avatar

Watchers

 avatar

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.