Skip to content

tylertomaseski/Unity-Convenience-Extensions

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

9 Commits
 
 
 
 
 
 

Repository files navigation

Unity-Convenience-Extensions

Some convenience extensions I use in every project. It's just one file, grab it and throw it in your project!

  • byte[].ToByteArray() and struct.BuildFrom(byte[] bytes)
    • Shorthand converting structs to and from byte arrays.
  • Transform.TransformPointUnscaled(Vector3 position) and Transform.InverseTransformPointUnscaled(Vector3 position)
    • Translate and rotate a position without using the transform's scale.
  • Transform.Reset(), Transform.ZeroAll(), and Transform.ZeroPosRot()
    • Sets local position to 0, rotation to 0, and sometimes scale to (1, 1, 1). Reset and ZeroAll are identical.
  • GameObject.GetCreateComponent<T>()
    • Get a component on this gameobject. If it doesn't exsit, then add one and return it.
  • List.GetRandom() and T[].GetRandom()
    • Returns a random element from an array or list.

Usage

All of these methods appear as methods, as if they were built into Unity. As an example, you can call this.GetCreateComponent<SpriteRenderer>() from a MonoBehavior. Just download the Extensions.cs file and add it to your Unity project.

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages