Indiversity by daniellanner - 1

Tools

A collection of tools and code snippets for the Unity Engine.

Unknown VersionMIT LicenseUpdated 17 days agoCreated on April 26th, 2020
Go to source

A collection of tools and code snippets for the Unity Engine. The dev branch is home to unfinished or untested tools which are subject of frequent changes, but feel free to browse.

Coroutine Animations

Avoid writing boilerplate code for procedural animations. Provides method chaining for optional behaviour. Example of use:

using io.daniellanner.indiversity;
public class ExampleClass : MonoBehaviour
{
  public void ExampleMethod()
  {
    Vector3 from = Vector3.zero;
    Vector3 to = Vector3.to;

    var translation = new CoroutineTransformPosition(transform, from, to)
      .SetDuration(2.5f)
      .SetDelay(.5f)
      .SetInterpolation(new EaseInterpolation())
      .SetRepeat(3)
      .SetCallback( () => Debug.Log("Finished"));
      
     StartCoroutine(translation.GetIEnumerator());
  }
}

Implemented support:

  • Transform Position
  • Transform Rotation
  • Transform Scale
  • Transform Wiggle
  • RectTransform AnchoredPosition
  • RectTransform SizeDelta
  • UI.Graphic Color
  • Material Shaderproperty

Functionality is very simple to extend.

Result

A lightweight way for communicating safe results when returned from a method. Example of use:

using io.daniellanner.indiversity;

public Result<float> SafeReturn()
{
  // if some error
  return Result<float>.FALSE;
  
  // if computed correctly
  float result = 1;
  return Result(result).AsSafe();
}

static int Main(string[] args)
{
  var myfloat = SafeReturn();
  if(myfloat)
  {
    float value = myfloat.Value;
  }
  
  return 0;
}
Show all projects by daniellanner