Coder Social home page Coder Social logo

cronyxllc / developerconsole Goto Github PK

View Code? Open in Web Editor NEW
28.0 2.0 3.0 5.15 MB

A lightweight, in-game developer console for Unity

License: MIT License

C# 73.49% Python 3.27% ShaderLab 19.78% HLSL 3.45%
debugging developer-tools developer-console utilities unity3d unity logging

developerconsole's Introduction

DeveloperConsole

Release openupm Release

A lightweight, in-game developer console for Unity

Features

  • Easy to use and extendable in-game developer console!
  • Quickly add new commands by marking a method with [Command]:

    [Command("cube")]
    public static void CreateCube (Vector3 pos, float scale)
    {
      var cube = GameObject.CreatePrimitive(PrimitiveType.Cube);
      cube.transform.position = pos;
      cube.transform.localScale = Vector3.one * scale;
    }
     
    // $ cube (1 2 3) 2
    // Creates a cube at (1, 2, 3) with scale 2.0f
  • Parsing support for all basic C# types, IEnumerable<T>, List<T>, Dictionary<TKey, TValue>, and many more.

  • Fully customizable GetOpt command syntax and automatic help text generation:

    [Command("showcase", Description = "Showcases the flexibility of the command parser.")]
    public static void CustomCommand(
      [Positional(Description = "The first positional", Meta = "FOO")] Vector3 posOne,
      [Positional(Description = "The second positional", Max = 4, Meta = "BAR", Optional = true)] IEnumerable<string> posTwo,
      [Switch('a', LongName = "flag", Description = "A flag")] bool flag,
      [Switch('b', LongName = "switch", Description = "A switch", Meta = "STR")] string @switch)
    {
      // Command implementation
    }
    
    // Automatically generated help text:
    // $ help showcase
    // showcase: Showcases the flexibility of the command parser
    // 
    // usage: showcase FOO [BAR] [-a] [-b STR]
    // Format:
    //     FOO            Vector3                (x y z)
    //     BAR            IEnumerable    [foo bar ...]
    //     STR            string                 
    // 
    // Mandatory Parameters:
    //     FOO            The first positional
    // 
    // Optional Parameters:
    //     BAR            The second positional
    //                    Can have at most 4 elements
    //     -a, --flag     A flag
    //     -b, --switch   A switch
  • Seamless parsing support for nested generic types, such as List<List<T>>.

  • Define parsers for custom types by extending the ParameterParser.

  • Add custom widgets, images, and media by extending the ConsoleEntry class.

  • Implement custom command line parsing through the IConsoleCommand interface.

    [Command("cmd")]
    public class MyCommand : IConsoleCommand
    {
      public void Invoke(string data)
      {
        // Parse command line input passed to this command
      }
    }
  • Access filesystem through built-in commands like ls and pwd.
  • A detailed documentation of all of these features and more over at the wiki!

Installation

Prerequisites

  1. Unity 2020.2 or greater
  2. TextMeshPro package 3.0.1 or greater installed in your project. Comes built-in with Unity 2020.2 or greater.

Installation Guides

Via PackageInstaller (drag-and-drop)
  1. Download the installer .unitypackage to your machine.
  2. Import the .unitypackage by dragging and dropping it onto the Unity window or by going to Assets > Import Package > Custom Package... and selecting the package.
  3. Import everything by clicking Import.
  4. Give the installer a moment to add the appropriate OpenUPM registries to your project.
  5. You're all set!

See more information here!

Via OpenUPM

Run:

~/MyProject $ openupm add com.cronyx.console

from within your project directory.

See more information here!

Via UPM (Tarball)
  1. Navigate to Releases and choose a release.
  2. Download the DeveloperConsole_v*.tar.gz file for that release.
  3. Open the Package Manager window (Window > Package Manager), click the ➕, and then click Add package from tarball...
  4. Select the tarball file you just downloaded, and then click Open.
  5. You're all set!

See more information here!

Via UPM (Git)
  1. Open the Package Manager window (Window > Package Manager), click the ➕, and then click Add package from git...
  2. Enter https://github.com/cronyxllc/DeveloperConsole.git#upm for the URL when prompted.
  3. Click Add and wait a moment.
  4. You're all set!

See more information here!

Getting started

Using the console

By default, you can open the in-game console by pressing the backquote key (`) (or tilde, ~, on QWERTY keyboards). This will open the console UI and allow you to start entering commands. For your first command, try printing the working directory:

~ $ pwd
C:\Users\MyUser\AppData\LocalLow\DefaultCompany\DeveloperConsole
~ $ █

Just like in a Bash console, past inputs can be cycled through using the up and down arrow keys. For a list of all commands that can be called, enter $ help.

Customizing the console

To customize the console's settings, go to Window > DeveloperConsole > Settings. This will create a ConsoleSettings asset in your projects directory. Hover over any of the settings to get a description of what that feature does. For a more detailed description of the console's settings, see the settings documentation.

Adding commands to the console

The DeveloperConsole package was created with the intention that you would extend its functionality by creating console commands specific to your own project. Creating a console command can be as simple as tagging a static method with a CommandAttribute:

[Command("cmd")]
public static void MyCommand (Vector3 v)
{
    // Your command's code
}

and calling it like so:

~ $ cmd (1 2 3)
~ $ █

or as complicated as creating a custom class that manually parses command-line arguments. See the documentation on console commands for more information on creating your own commands.

Contributing

Please feel free to contribute to this project! If you'd like to contribute, please do any of the following:

  • ‼️ Let others know about this project! We'd like to get the word out!
  • 🐛 Open an issue with a bug report or feature request.
  • ➕ Open a pull request with a change or new feature. Please let us know before you start working to prevent development conflicts.

developerconsole's People

Contributors

cronyxllc avatar jacobrobertsbaca avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

developerconsole's Issues

New Input System Support

Is your feature request related to a problem? Please describe.
I use new Input System in the project and DeveloperConsole throw exception with You are trying to read Input using the UnityEngine.Input class, but you have switched active Input handling to Input System package in Player Settings. message.

Describe the feature you'd like
Check INPUT_SYSTEM define on Update() and retrieve console key on input actions assets (which set on settings page)

Are there any alternatives you've considered?
None.

Additional context
Version: 1.2.0
Script: DeveloperConsole.cs
Line: 350 (Update method)

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.