Guest User

Untitled

a guest
Aug 3rd, 2012
79
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.85 KB | None | 0 0
  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. }
Advertisement
Add Comment
Please, Sign In to add comment