
Untitled
By: a guest on
Aug 3rd, 2012 | syntax:
C# | size: 0.85 KB | hits: 46 | expires: Never
public class SomeConsumer : MonoBehaviour
{
void floatsFromMic( float[] buf )
{
...
}
Start()
{
MySingleton.Instance.theDelegate += new MySingleton.MicCallbackDelegate( floatsFromMic );
}
}
using UnityEngine;
using System.Collections;
public class MySingleton : MonoBehaviour
{
public delegate void MicCallbackDelegate( float[] buf );
public MicCallbackDelegate theDelegate;
void Start ()
{
}
void Update ()
{
!!! gather floats
for( ? d in theDelegate.things )
FIRE d
}
public void DoSomething()
{
}
private static MySingleton _instance;
public static MySingleton Instance
{
get
{
if( _instance == null )
{
GameObject go = new GameObject( "MySingleton" );
_instance = go.AddComponent< MySingleton >();
}
return ( _instance );
}
}
}