Coder Social home page Coder Social logo

clzsv / unityingamedebugconsole Goto Github PK

View Code? Open in Web Editor NEW

This project forked from leinlin/unityingamedebugconsole

0.0 1.0 0.0 8.47 MB

A uGUI based console to see debug messages and execute commands during gameplay in Unity

License: MIT License

C# 99.30% C++ 0.39% Java 0.30%

unityingamedebugconsole's Introduction

Unity 3D 游戏内部控制台

呼出

按住屏幕,逆时针画圈圈即可呼出界面

控制台界面

popup

本插件UI使用的是UGUI,不必担心版本更新的问题,手机平台上也正常运行。原作者编写的循环列表效率很好,B格也贼高。于是在基础上改了改ui,以及加入了xlua脚本调用。

原github地址:https://github.com/yasirkula/UnityIngameDebugConsole.git

运行指令

你可以输入指令"help"来获取所有的注册的指令,同时装载了xlua的功能,你可以以"lua:"后面跟上xlua的脚本可以操作C#这边几乎所有的函数

你也可以通过 ConsoleMethodAttribute这个Attribute来注册一些指令,建议使用静态函数进行标记。

函数支持一些参数:

Primitive types, string, Vector2, Vector3, Vector4, GameObject

例子代码:

using UnityEngine;
using IngameDebugConsole;

public class TestScript : MonoBehaviour
{
	[ConsoleMethod( "cube", "Creates a cube at specified position" )]
	public static void CreateCubeAt( Vector3 position )
	{
		GameObject.CreatePrimitive( PrimitiveType.Cube ).transform.position = position;
	}
}

然后在控制台输入cube [0 2.5 0]即可在position (0,2.5,0)的位置上创建一个Cube.

控制台指令参数输入注意事项:

  • float类型的数字不要以f结尾
  • string类型的参数要用("")装载起来
  • vector2~4的变量使用 ( [] ) 或者 ( () )装载

参数的一些默认选项:

  • 你可以使用 [] 来代表Vector.zero
  • 你可以使用1代表true,0代表false

游戏内部要注销指令可以使用代码

DebugLogConsole.RemoveCommand( string command )

xlua的使用详见:https://github.com/Tencent/xLua

lua控制台例子:

lua:
CS.UnityEngine.Debug.Log("13224")

lua代码使用注意事项:

每一次运行lua都会新建一个虚拟机,执行完毕后就销毁,所以不要注册啥全局函数

var env = new XLua.LuaEnv();
env.DoString(command.Substring(4));
env.Dispose();

如果要使用虚拟机调用游戏内部的lua函数请使用函数将规则加到控制台中:

DebugLogConsole.AddCommondRuleAction(your rule)

操作指引

打开example中的consle.unity场景
使用回车键可以扩大输入框
Ctrl+回车键 或者点击发送按钮执行指令
手机上从电脑上发送信息上来,然后粘贴进去吧

运行lua代码

popup

popup

运行指令代码

popup

unityingamedebugconsole's People

Contributors

yasirkula avatar

Watchers

 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.