Code Monkey home page Code Monkey logo

moregizmos's Introduction

MoreGizmos

A example of a square gizmo being drawn

A proof-of-concept-quality library for Unity 2018.4+ that expands the number of debug gizmos that can be drawn.

Here's what you'd have available with Unity's offerings and this library:

  • UnityEngine.Gizmos - usable in OnDrawGizmos, editor-only
    • DrawCube
    • DrawFrustum
    • DrawGUITexture
    • DrawIcon
    • DrawLine
    • DrawMesh
    • DrawRay
    • DrawSphere
    • DrawWireCube
    • DrawWireMesh
    • DrawWireSphere
  • UnityEngine.Debug - usable anywhere, editor-only
    • DrawRay
    • DrawLine
  • MoreGizmos.GizmosEx - usable anywhere, editor-only (for now)
    • DrawSphere
    • DrawCube
    • DrawCircle
    • DrawSquare
    • DrawCustomGizmo - accepts objects of type GizmoDraw

These are intended to be only drawn during editor-time by collecting and delegating the drawing of said debug gizmos to an instance of GizmosEx which in turn renders them in its own OnDrawGizmos message.

Custom gizmos types can be derived from GizmoDraw and implement the required methods that will be called to prepare and render the gizmo.

Installation

MoreGizmos is distributed as a package that can be managed through Unity's Package Manager UI as of 2018.1.

2018.3+

To add this to an existing Unity project, open your project's manifest.json file in your Packages directory and add the following line to your list of dependencies:

  "dependencies": {
    "com.tb.moregizmos": "https://github.com/terrehbyte/MoreGizmos.git",
  }

Note that the trailing comma should be omitted if you add it as the last element in the list, of course. For more information or advanced usage, refer to the Unity Manual for specifying dependencies via Git URLs.

Pre-2018.3

Support for loading Git repositories as a package was only added in 2018.3, so you'll need to resort to local file management if you're running something older.

Screenshot of the "Add package from disk..." entry

Unity allows you to add a package by providing a relative file path to a package.json file. Best practices would advise that you place it somewhere co-located with your Unity project (and versioned, of course).

No Package Manager

Alternatively, you may choose to download this project as a zip (or submodule if you're using Git) whose contents can be placed in the Assets directory of your project. The end-result should be: ProjectRoot/Packages/<repo-contents> as a built-in package.

Quick Usage

Attach an instance of GizmosEx to a GameObject in the scene. After doing so, try adding something to the effect of the following code:

public class ExampleUsage : MonoBehaviour
{
  private void Update()
  {
    // draws a RED CUBE at 0,0,0, with a scale of ONE for each dimension
    GizmosEx.DrawCube(Vector3.zero, Vector3.one, Color.red);
  }
}

License

Copyright (c) 2019-2020 Terry Nguyen - MIT License

The sprites used in the above GIF are CC0-licensed from Buch's dungeon tileset.

More information can be found by reading the LICENSE file in this repository.

moregizmos's People

Contributors

terrehbyte avatar

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.