Git Product home page Git Product logo

general-unity-utilities's Introduction

General Unity Utilities by itchyOwl

About the repository

This is a collection of general Unity code that I reuse from a project to another.

Most of the code is written by myself. Whenever I've used the work of someone else, I've tried to provide a reference to the source.

The code is licenced with MIT. Feel free to use it as you wish in your projects.

Also check out my blog at https://itchyowl.com and the assets that I've published on Unity Asset Store.

Dependencies

Unfortunately this repository is not very modular. But that's partly by design. The reason for not being modular here, is that much of the code is reused in multiple places. However, I may try to change this in future.

Many scripts depend on the extension methods found in the Extensions folder and the files in the General folder. Moreover, many UI scripts in the [UI] folder depend on the Tweener, which is found in the Auxiliary folder.

Important classes

Tweener is used as a base class by many scripts that rely on animating values and properties. It provides tweening functionality for just about anything, because it merely handles the tweening logic and leaves the rest to the user (via callbacks).

Tweener is not meant to replace the popular animation libraries like iTween or DOTween. Instead, it's designed to provide gegeneric, component oriented tweening behaviour that can be extended by class inheritance. I've used it for example to tween animation layers and to move objects in trajectories.

In the UI folder you can find GUIManager, which is a singleton class. It's designed to work as a simple manager that can be placed into any project as it is. Currently if provides methods for displaying screen space notifications and floating UI messages following a 3d target. It also handles all the window selection logic for you. For most projects, I've created a more specific manager that inherits GUIManager.

I'm not a huge fan of the singleton pattern, but in some cases it's just unavoidable. Singleton provides GetInstance() method that updates the instance to a more specific type. Use this method, in the derivative manager, so the instance is automatically updated for you.

The GUI settings should be defined in a GUIPreset or a ScriptableObject that inherits that class. New ScriptableObjects can be created with ScriptableObjectFactory, which uses reflection to find all the ScriptableObjects in the project.

The purpose of UIElementFactory and UIDictionaryElementFactory is to manage dynamically created UI elements for example placed under a Scroll View. The elements can be anything. However, these factories are designed to work together with UISelector, which handles the selection logic of toggleable ui elements. UIToggleIcon is an example of toggleable ui element.

There's also UIDraggableElement to provide draggable functionality, useful for example in inventories. If you'd like to create an inventory with these classes, consider creating a custom icon class that inherits UIToggleIcon and defining a reference to the icon data in that class.

For saving and loading files, there's the static FileManager class that can handle both text and binary formats.

Notes

The code is not by any means complete and it will change in due time. Also note that some scripts are quite old and have not been tested for a while. If you spot any issues, feel free to create a pull request or contact me by mail.

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.