• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Elringus/UnityConsole: Development console for Unity game engine

原作者: [db:作者] 来自: 网络 收藏 邀请

开源软件名称:

Elringus/UnityConsole

开源软件地址:

https://github.com/Elringus/UnityConsole

开源编程语言:

C# 99.3%

开源软件介绍:

Installation

Use UPM to install the package via the following Git URL: https://github.com/Elringus/UnityConsole.git#package.

Minimum supported Unity version: 2019.1

Description

Allows executing static C# methods via an on-demand console IMGUI.

How to Use

Register commands by adding ConsoleCommand attribute to static C# methods. The attribute has an optional string argument, allowing to assign an alias (shortcut).

[UnityConsole.ConsoleCommand("hello")]
public static void PrintHelloWorld () => Debug.Log("Hello World!");

[UnityConsole.ConsoleCommand]
public static void Add (int arg1, int arg2) => Debug.Log(arg1 + arg2);

Enable the console at runtime with:

UnityConsole.ConsoleGUI.Initialize()

Toggle console GUI with ~ key. The key can be overridden via ConsoleGUI.ToggleKey public static property. It's also possible to toggle console with a multi-(3 or more) touch on touch screen devices.

In the console, type either method name or alias of a registered command and press Enter key to invoke the method. Method arguments are separated with a single whitespace.

Use Up and Down to navigate over previously executed commands.

To disable the console at runtime:

UnityConsole.ConsoleGUI.Destroy()

Preprocessors

It's possible to inject delegates to modify the console input before it's send for execution, eg:

using UnityConsole;
using UnityEngine;

public class TestPreprocessor : MonoBehaviour
{
    private void OnEnable ()
    {
        InputPreprocessor.AddPreprocessor(PreprocessInput);
    }

    private void OnDisable ()
    {
        InputPreprocessor.RemovePreprocessor(PreprocessInput);
    }

    private string PreprocessInput (string input)
    {
        if (input != null && input.StartsWith("@"))
        {
            Debug.Log(input);
            return null;
        }
        return input;
    }
}

— will intercept commands starting with @ and instead log the input. Notice, that when a preprocessor delegate returns null it will stop the default console behaviour.




鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap