• Home
  • Contact
  • Careers
  • Socialize With Us:
  • Send us Mail
  • Follow us on Twitter
  • Join our Facebook Group
  • /
  • Linkedin
  • /
  • Vimeo Videos
  • /
  • Youtube
  • /
  • RSS Feed
  • Search Site

  • About UsAwards & Bio
  • PortfolioOur Latest Work
  • TrainingTips & Tutorials
  • BlogGreat Articles

You are here: Home / Tag: DevDiary

Tag Archive for: DevDiary

Unity3D Dev Diary: uEventDispatcher

Category: RMC News     |     Tags: Debugging, DevDiary, Testing, Unity3D

About RMC & Unity3D

Rivello Multimedia Consulting (RMC) provides consulting services for applications and games. RMC specializes in Unity3D development (see our work here). Please contact us today with any questions, comments, and project quotes.

uEventDispatcher

Problem

Unity3D is a great gaming IDE and runtime. Like any tool I use regularly, I have many constructive criticisms as well. For example, there is no adequate one-to-many messaging system. The UnityEngine includes BroadcastMessage & SendMessage but it is not adequate and has many public, deserved criticisms.

Solution

Streamline messaging between classes using uEventDispatcher.

Benefits include;

  1. Easily add/remove and dispatch custom communication
  2. Strongly-typed data payload
  3. Compiler properly warns you about major misuse cases (mistyping, etc…)
  4. Works within any class type and requires no special ‘Interface’ or ‘Inheritance’
  5. Does not rely on reflection (slow performance) like BroadcastMessage/SendMessage

Usage

Here is an example that shows the COMPLETE API of uEventDispatcher.

[code]

//————————————–
// Imports
//————————————–
using UnityEngine;
using System.Collections;
using com.rmc.events;

//————————————–
// Class
//————————————–
public class TestEventDispatcher : MonoBehaviour
{

//————————————–
// Properties
//————————————–
// PRIVATE
private EventDispatcher eventDispatcher;

//————————————–
// Methods
//————————————–

// PUBLIC
/// <summary>
/// Start this instance.
/// </summary>
void Start ()
{

//CREATE
eventDispatcher = new EventDispatcher (this);

//ADD 0, 1, 2, OR MORE LISTENERS…
eventDispatcher.addEventListener (TestEvent.TEST_EVENT_NAME, _onCustomEvent1); //default is EventDispatcherAddMode.DEFAULT
eventDispatcher.addEventListener (TestEvent.TEST_EVENT_NAME, _onCustomEvent2, EventDispatcherAddMode.SINGLE_SHOT);

//TEST REMOVE
//eventDispatcher.removeAllEventListeners();
//eventDispatcher.removeEventListener (TestEvent.TEST_EVENT_NAME, _onCustomEvent1);

//TEST HAS
//Debug.Log (" hasEventListener(): " + eventDispatcher.hasEventListener (TestEvent.TEST_EVENT_NAME, _onCustomEvent1));

//TEST EVENT SETUP FROM 3 DIFFERENT SCOPES
eventDispatcher.dispatchEvent (new TestEvent (TestEvent.TEST_EVENT_NAME));

}

//————————————–
// Events
//————————————–
public void _onCustomEvent1 (IEvent iEvent)
{
Debug.Log (" 1. _onCustomEvent1(): " + iEvent);
}

public void _onCustomEvent2 (IEvent iEvent)
{
Debug.Log (" 2. _onCustomEvent2(): " + iEvent);
}

}

[/code]

Status

The project is now complete and live on the AssetStore. It is free. Check it out today!

Unity3D Dev Diary: uMOM 1

Category: RMC News     |     Tags: Debugging, DevDiary, Testing, Unity3D

About RMC & Unity3D

Rivello Multimedia Consulting (RMC) provides consulting services for applications and games. RMC specializes in Unity3D development (see our work here). Please contact us today with any questions, comments, and project quotes.

uMOM

Problem

Unity3D is a great gaming IDE and runtime. Like any tool I use regularly, I have many constructive criticisms as well. For example, there is no default Main.main() type ‘hook’ to centralize the entry into your runtime and no default way for UI and code to persist from scene to scene. I created a monolithic ‘SimpleManager’ class (see my HD training course video on architectures for more on that), however it is purposefully limited in scale. It is essentially a single manager packed with disparate responsibilities (sound, levels, object pooling, etc…). I knew there was a better solution.

Solution

Welcome to the Unity3D Manager of Managers (uMOM), pronounced as /you-mom/. I’m currently developing uMOM for the AssetStore.

The purpose of uMOM lean;

The uMOM package allows developers to add one or many reusable, custom manager classes to the project. Each ‘start’ automatically, have a predictable lifecycle (reset, add, update, remove), optionally receive ‘update()’ calls, optionally run during edit mode, and optionally persist between scenes. Managers operate as singletons and can easily address each other to collaborate.

Types of uMOM Managers

Really anything is possible, but here is the short list of use cases I will address first. Use some of mine or none of mine – then create your own. Most any existing mananger class you have can easily be converted for compatibility here. 

  • uEventManager -Streamline messaging between classes. Replace the need for Unity’s clunky ‘SendMessage’ and instead dispatch strongly typed objects. (The uEventManager will also be available separately).
  • Store references to audio clips (drag-n-drop) and control audio playback via C# from one place.
  • GUIManager – Layout UI which optionally persists between scenes. Centralize the controls to handle clicks, etc…
  • PoolManager – Optimize your run-time performance by persisting GameObject or prefab instances in RAM and displaying them as needed.
  • LevelManager – Queue up levels and perform transitions (e.g. fade-in-out) between them.
  • GameManager – While other managers are not project specific, this one likely is. Here you manage the core game mechanics, how the user wins and loses, store the score, etc…
  • SaveManager: Takes care of saving and loading user preferences and achievements.
  • MenuManager: Controls all menus, managing their animations, their contents, and their behaviors. Perhaps it heavily uses the GUIManager for layout.
  • Much, much, more…

The instructions of uMOM are concise;

  • 1. Select an existing uMOM manager class (from me, from the community) or create a new uMOM manager which subclasses BaseManager (which extends ScriptableObject). The class acts basically as an interface (because interfaces don’t serialize in Unity3D), allowing you maximum freedom in how you implement.
  • 2. Use the uMOM Unity Editor Window (See Figure 1) for all your needs. All compatible scripts in your project, regardless of folder location are shown here.
  • 3. Click ‘Convert’ (one time only) for the desired script. This efficiently creates a new ScriptableObject (e.g. MyManager.asset) for the original MonoScript (e.g. MyManager.cs)
  • 4. Click ‘Add’ (one time only) for the desired script. It is that step that actually puts your manager into use. Cool! You can click ‘Remove’ if you don’t want the manager to be in-use anymore.
  • 5. Edit your manager class source code however you like. No need to repeat the steps, your changes are hot-updated to the project. All this works in Edit Mode Or Play Mode.
Figure 1. (In Progress)

Figure 1. (In Progress)

 

Problems & BUGS!

During development I have hit many obstacles. All my issues continue to exist, even with the recent Unity 4.2.x release. Developing Unity Editor tools is a unique challenge compared to straight game development and it is unlike any other platforms I’ve used before. I’m sure all of these challenges can be solved.

I would LOVE some help resolving these issues. See this list (I’ll record a video soon if that would help you) and please comment below if you have confidence to solve any one area. I can share the code with you. I ask that any assistance be Work for Hire. Unfortunately on this particular project there is no partnership or co-ownership available. Once I have the project working, I plan to offer it as a premium package in the AssetStore.

1. Serialization

The uMOM class directly edits its public properties (as it should, right?). The many editor classes edit the SerializedObject and SerializedProperty of uMOM’s public properties (as it should right?). However in many places I see that I must STOP, change a value with a click in the uMOM Editor Window, then PLAY to have a change persist. Otherwise the change is lost next time I play/pause.

I have no workaround and I assume the issue is within my code. IDEAS?

2. Finding ‘All’ Assets

The uMOM Editor Window shows a list of all compatible MonoScripts (meaning all MonoScripts in Project window which extend BaseManager). That works. However, the programmatic listing of all compatible ScriptableObjects (meaning all ScriptableObjects in the Project window which have a type of a compatible MonoScript) is not so easy. Unity returns the ‘loaded’ (loose term) instances I want, but not ALL of them. The issue is well known (here, and here, and here, and more).

The common workaround I read online is to manually (with mouse) or programmatically (loop through all assets and call AssetDatabase.Load… [this crashes Unity IDE] or Selection.objects [This works inconsistently]… to ‘refresh’ the assets it can find). Manually = works but is not a long-term solution. Programmatically does not work.

Based on research I think this is a known Unity bug that Resources.FindObjectsOfTypeAll() and its deprecated equivalent Object.FindObjectsOfTypeAll, just do not really give you ‘all’. IDEAS?

Please Vote!

You can vote on this known bug (problem #2 above) here “Make FindObjectsOfTypeIncludingAssets find all just like the object picker” to encourage the Unity team to fix this issue. If you have nothing else to vote on, please cast your votes this way!

Tag

3D AIR API AS3 AS3.5 AssetStore Augmented Reality Business C# Charity Debugging Design Patterns DevDiary ECS Architecture Experimental Flash Flex Game Design Game Design Prototypes Games GUI HTML5 Java Loom Mobile MVCS Architecture Optimization Project Planning PushButtonEngine ReactiveExtensions Review Robotlegs Smash Testing Unity3D UnityApplicantTest WordPress WordPress Plugin

Brazilean Developers

  • Abendita.com
  • dclick.com.br
  • dm9.com.br
  • Fellyph Cintra
  • IgorCosta.org
  • MonadaSolucoes.com.br
  • PossibleWorldwide.com.br
  • Unit9.com

Developers

  • Adobe Blogs
  • Ben Forta
  • Colin Moock
  • Enrique Duvos
  • Flash Mobile Blog
  • Jess Freeman
  • Kevin Hoyt
  • Lee Brimelow
  • Paul Trani
  • Quasimondo
  • Renaun Erickson
  • Ryan Stewart

Free Assets

  • Free Sounds
  • HasGrafics

HTML5 Games

  • Closure JS Library
  • Eloquent JS Manual
  • Game Framework – CraftyJS
  • Game Framework – EaselJS

Italian Developers

  • alchimedia.com
  • corlan.org/
  • creativesource.it
  • dimix.it
  • fabiobiondi.com
  • gnstudio.com
  • Interpreting-tech.com/bemobile/
  • leonardorisuleo.info
  • lucamascaro.info
  • mart3.org
  • mxml.it
  • nxn.it
  • pirosoft.it
  • Preload.it
  • sonnati.wordpress.com/
  • webgriffe.com

Products

  • Adobe.com
  • Amazon Kindle E-Reader
  • ElectroServer
  • F*CSS
  • Flash Development Toolkit (FDT)
  • O'Reilly PureMVC Book
  • Samsung Galaxy Tablet
  • Unity3D

RMC

  • RMC Consulting

Spanish Developers

  • Flash Adictos
  • HTML Cinqo
  • Tutoriales Flash

Tutorial

  • Active Tuts
  • AS3-to-Unity3D Training Videos
  • Doing 2D in Unity3D
  • Learning C#
  • Unity3D Tutorials

Unity3D Games

  • AS3-to-Unity3D Training Videos
  • Doing 2D in Unity3D
  • Learning C#
  • Matt Eley's Blog
  • Unity3D
  • Unity3D Tools
  • Unity3D Tutorials

Interesting links

Besides are some interesting links for you! Enjoy your stay :)

Latest Portfolio

  • Coins And PlatformsMarch 19, 2014, 6:04 am
  • Paddle SoccerMarch 2, 2014, 9:13 pm
  • Spider StrikeFebruary 21, 2014, 4:19 am
  • Custom Game System APIJuly 8, 2013, 8:05 am

Latest News

  • RMC Primer: Everything Virtual Reality (VR)September 3, 2016, 10:29 am
  • Unity3D Architectures: EntitasJuly 29, 2016, 11:15 pm
  • RMC Primer: Get A Job In Game DevelopmentAugust 19, 2015, 10:18 am
  • Unity UI: Overview – Part 1 of 3December 10, 2014, 9:55 am

Archive

  • September 2016
  • July 2016
  • August 2015
  • December 2014
  • April 2014
  • March 2014
  • February 2014
  • January 2014
  • December 2013
  • October 2013
  • September 2013
  • August 2013
  • July 2013
  • June 2013
  • May 2013
  • December 2012
  • October 2012
  • September 2012
  • July 2012
  • May 2012
  • April 2012
  • March 2012
  • February 2012
  • January 2012
  • December 2011
  • October 2011
  • September 2011
  • August 2011
  • June 2011
  • April 2011
  • March 2011
  • January 2011
  • December 2010
  • October 2010
  • September 2010
  • April 2010
  • March 2010
  • January 2010
  • October 2009
  • August 2009
  • June 2009
  • May 2009
  • April 2009
  • January 2009
  • December 2008
  • November 2008
  • August 2008
  • May 2008
  • April 2008
  • February 2008
  • January 2008
  • December 2007
  • November 2007
  • October 2007
  • August 2007
  • May 2007
  • January 2007
  • October 2006
  • April 2006
  • March 1999

© Copyright 2006 - 2023 - Rivello Multimedia Consulting - RMC by Samuel Asher Rivello