General Utilities in Core

Alex Marcolina edited this page Jun 6, 2017 · 3 revisions

Pardon our dust! This page is still under construction.

Garbageless LINQ queries using Query()

using Leap.Unity.Query

private List<GameObject> _gameObjectCollection = new List<GameObject>();

private GameObject SecondObjectNamedFoo() {
  return _gameObjectCollection.Query()
                              .Where(o => o.name.Equals("Foo"))
                              .Skip(1)
                              .FirstOrDefault();
}

Simple animation using Tween

using Leap.Unity.Animation

private void OneShotTweenUp() {
  Tween.Single()
       .Target(this.transform)
       .ByLocalPosition(Vector3.up)
       .OverTime(3F)
       .OnReachEnd(() => { Debug.Log("I'm done tweening!"); });
}

Generic (Non-MonoBehaviour) Pooling with Pool

Pool anything that can be constructed with a new keyword. This can save you having to hold a lot of private buffer list variables in your MonoBehaviours, for example. (Unfortunately, this does not work with any MonoBehaviours, but it does work with GameObjects.)

private void MyFunctionNeedsATemporaryList() {
  List<int> myTempList;
  try {
    myTempList = Pool<List<int>>.Spawn();
    for (int i = 0; i < 10; i++) myTempList.Add(i);
    Debug.Log("I've got a pooled list: " + myTempList);
  }
  finally {
    myTempList.Clear(); // Clear the list before returning it to the pool!
    Pool<List<Int>>.Recycle(myTempList);
  }
}

Data Structures

  • RingBuffer
  • SmoothedVector3
  • SmoothedFloat
  • DeltaBuffer
You can’t perform that action at this time.
You signed in with another tab or window. Reload to refresh your session. You signed out in another tab or window. Reload to refresh your session.
Press h to open a hovercard with more details.