Code Monkey home page Code Monkey logo

unityessentials's Introduction

UnityEssentials

Essentials scripts for Unity.

Version: 0.0.1

Creator: Thomas Cocchiara aka ThomasSquall

Usage

NOTE: a GameManager object should be always present in your scene to make some functionality work fine

TouchManager

The TouchManager utility allows you to fasten develop touch based games, it is also capable to use the mouse click when in Unity Editor to help you debug better.

Example 1:

gameObject.BindToTouch(() => { Debug.Log(gameObject); });

In this first example each time the gameObject will be touched the gameObject info will be written to the console.

Example 2:

if (TouchManager.ScreenTouched()) Debug.Log("Screen touched");

In the second example each time the Screen will be touched The "Screen touched" string will be written to the console. Some other methods can be found inside the TouchManager class.

GameStateManager

The GameStateManager helps you to Save and Load the game very easily and efficiently. It serialize and deserialize the GameVariables class using the core PlayerPrefs functions of Unity. Let's say for example that you have created a GameVariable called MoneyAmount using the following syntax:

GameVariables.Update("MoneyAmount", 1500);

and now you want to save the game for a later usage. The following syntax will do the trick:

GameStateManager.Save();

now you want to log the differences of money amount between a new game and the loaded one, just do:

// 0 is the default value.
Debug.log("Money Amount at beginning: " + GameVariables.Get("MoneyAmount", 0));
GameStateManager.Load();
Debug.log("Money Amount after game loaded: " + GameVariables.Get("MoneyAmount", 0));

If you had a previously saved game you should see the difference.

PS: You can find more utilities inside the repository and more are coming soon

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.