Git Product home page Git Product logo

unityutilities's Introduction

UnityUtilities

A collection of C# scripts to assist with frequent Unity use cases

Verified working on Unity 2019.2.10f1.

List Extensions

ListExtensions.cs

A collection of useful functions that can be called directly on lists.

RandomEntry

List<int> myList = [1, 2, 3, 4];
Debug.Log(myList.RandomEntry());
// Will return either 1, 2, 3, or 4

RandomIndex

List<int> myList = [1, 2, 3, 4];
Debug.Log(myList.RandomIndex());
// Will return either 0, 1, 2, or 3

Debug.Log(myList.RandomIndex(1));
// Will return either 0, 2, or 3

ExtractComponent

List<GameObject> candyObjects = new List<GameObject>(GameObject.FindGameObjectsWithTag("Candy"));
// Build a list of game objects to extract components from
List<CandyComponent> candies = candyObjects.ExtractComponent<CandyComponent>();
// Returns a list of CandyComponents attached to gameobjects in candyObjects
List<Transform> candyTransforms = candyObjects.ExtractComponent<Transform>();
// Returns a list of Transforms attached to gameobjects in candyObjects

Transform Extensions

TransformExtensions.cs

LinearShake

StartCoroutine(Camera.main.transform.LinearShake(2f, 2f, Axis.XY));
// Will cause the camera to shake for 2 seconds on the x and y axis individually
// Will stop the camera shake if the game's Time.timeScale is set to 0

StartCoroutine(transform.LinearShake(4f, 8f, Axis.ALL, false));
// Will cause this game object to shake for 4 seconds on all three axis
// Will continue to run even if the game's Time.timeScale is set to 0

Bitmask Extensions

BitmaskExtensions.cs

ReturnRandomBit

Debug.Log(5.ReturnRandomBit());
// Will return either 1 or 4

unityutilities's People

Contributors

djfdat avatar

Watchers

 avatar

unityutilities's Issues

Freeze Animation extension method

Create a freeze animation extension method in the FreezeExtensions class that will pause an animation for a certain number of frames.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.