Пример #1
0
 public static IObservable <KeyboardEvent> CreateKeyboard(IList <KeyCode> pollableKeys)
 {
     return(UnityObservable.CreateUpdate <KeyboardEvent>(observer =>
     {
         for (int i = 0; i < pollableKeys.Count; i++)
         {
             var key = pollableKeys[i];
             if (Input.GetKeyDown(key))
             {
                 observer.OnNext(new KeyboardEvent(KeyboardEvent.EventType.Down, key));
             }
             else if (Input.GetKeyUp(key))
             {
                 observer.OnNext(new KeyboardEvent(KeyboardEvent.EventType.Up, key));
             }
         }
     }));
 }
Пример #2
0
 public static IObservable <Vector3> MouseMove()
 {
     return(UnityObservable.CreateUpdate <Vector3>(observer => observer.OnNext(Input.mousePosition))
            .DistinctUntilChanged(Vector3Comparer.Instance));
 }
Пример #3
0
 public static IObservable <Unit> UpdateTicks()
 {
     return(UnityObservable.CreateUpdate <Unit>(observer => observer.OnNext(Unit.Default)));
 }
Пример #4
0
 public static IObservable <float> UpdateTicks(Func <float> deltaTime)
 {
     return(UnityObservable.CreateUpdate <float>(observer => observer.OnNext(deltaTime())));
 }