Don't like ads? PRO users don't see any ads ;-)
Guest

Untitled

By: a guest on Aug 3rd, 2012  |  syntax: C#  |  size: 0.85 KB  |  hits: 46  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. public class SomeConsumer : MonoBehaviour
  2. {
  3.         void floatsFromMic( float[] buf )
  4.         {
  5.                 ...
  6.         }
  7.        
  8.         Start()
  9.         {
  10.                 MySingleton.Instance.theDelegate += new MySingleton.MicCallbackDelegate( floatsFromMic );
  11.         }
  12. }
  13.  
  14.  
  15.  
  16. using UnityEngine;
  17. using System.Collections;
  18.  
  19. public class MySingleton : MonoBehaviour
  20. {
  21.         public delegate void MicCallbackDelegate( float[] buf );
  22.  
  23.         public MicCallbackDelegate theDelegate;
  24.        
  25.         void Start ()
  26.         {
  27.        
  28.         }
  29.        
  30.         void Update ()
  31.         {
  32.                 !!! gather floats
  33.                
  34.                 for( ? d in theDelegate.things )
  35.                         FIRE d
  36.         }
  37.        
  38.         public void DoSomething()
  39.         {
  40.            
  41.         }
  42.        
  43.         private static MySingleton _instance;
  44.         public static MySingleton Instance
  45.         {
  46.                 get
  47.                 {
  48.                         if( _instance == null )
  49.                         {
  50.                                 GameObject go = new GameObject( "MySingleton" );
  51.                                 _instance = go.AddComponent< MySingleton >();
  52.                         }
  53.                         return ( _instance );
  54.                 }
  55.         }
  56. }