• Stars
    star
    533
  • Rank 83,238 (Top 2 %)
  • Language
    C#
  • License
    MIT License
  • Created about 9 years ago
  • Updated almost 3 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

In-game powerful REPL environment for Unity3D.

uREPL

uREPL is an in-game powerful REPL environment for Unity3D that supports following functions:

  • Any Unity-supported C# code evaluation at run time.
  • Emacs-like keyboard shortcuts.
  • Multi-Line input.
  • Customizable completions.
  • Command definition just by adding an attribute.
  • GameObject and Component inspector.
  • Output logs.
  • History.

Demo

uREPL - In-game powerful REPL environment for Unity3D - YouTube

Environment

  • Mac / Windows
  • Unity 2017.x .NET 4.6 (from v0.5.0)
    • Unity 5.x .NET 3.5 (until v0.4.0)

Install

  • Unity Package
  • Git URL (UPM)
    • Add https://github.com/hecomi/uREPL.git#upm to Package Manager.
  • Scoped Registry (UPM)
    • Add a scoped registry to your project.
      • URL: https://registry.npmjs.com
      • Scope: com.hecomi
    • Install uREPL in Package Manager.

Usage

  1. Select menu from Assets > Create > uREPL to instantiate a uREPL prefab.
  2. If you have no EventSystem, add it from Hierarchy > Create > UI > EventSystem.
  3. Input the code into the input filed, then press the Enter key to submit and evaluate it.

Keybinds

Input

Key Description
ctrl + a move to head.
ctrl + e move to end.
ctrl + f, right arrow move forward.
ctrl + b, left arrow move back.
ctrl + h, backspace remove character before cursor position.
ctrl + d remove character after cursor position.
ctrl + k remove all characters after cursor position.
ctrl + l clear all outputs.
ctrl + m toggle single-line / multi-line mode.
ctrl + n, up arrow show next history.
ctrl + p, down arrow show previous history.
ctrl + tab show completions.
enter run input command.
F1 toggle window display on/off.

Completion

Key Description
ctrl + n, up arrow select lower item.
ctrl + p, down arrow select upper item.
tab, enter insert selected completion.
esc hide completions.

Commands

Attribute

You can add commands by adding a [uREPL.Command] attribute to static methods.

public class CommandTest
{
	// Given from somewhere.
	static public GameObject gameObject;

	// This method can be called without class name.
	// $ ShowCurrentSelectedObject() ⏎
	[uREPL.Command]
	static public string ShowCurrentSelectedObject()
	{
		return gameObject.name;
	}

	// This method can be called by the given name.
	// $ selected ⏎
	[uREPL.Command(name = "selected")]
	static public string ShowCurrentSelectedObject2()
	{
		return gameObject.name;
	}

	// Completion view show the given description.
	[uREPL.Command(name = "selected2", description = "show the selected gameobject name.")]
	static public string ShowCurrentSelectedObject3()
	{
		return gameObject.name;
	}
}

Command with arguments

uREPL automatically convert the command format into the actual code.

public class CommandTest
{
	// '$ print "\"hoge hoge\"" ⏎' will be replaced with:
	// CommandTest.Print("\"hoge hoge\"");
	[uREPL.Command(name = "print")]
	static public void Print(object obj)
	{
		Debug.Log(obj);
	}

	// Supports an overloaded command.
	[uREPL.Command(name = "print")]
	static public void Print(string value1, int value2, float value3)
	{
		Debug.LogFormat("string: {0}, int: {1}, float: {2}", value1, value2, value3);
	}
}

Runtime

From v0.4.0, you can register and unregister commands in runtime.

using UnityEngine;

public class RuntimeCommandTest : MonoBehaviour
{
    void OnEnable()
    {
        uREPL.RuntimeCommands.Register("func1", () => Debug.Log("hoge"), "output hoge");
        uREPL.RuntimeCommands.Register("func2", x => Debug.Log(x), "outout given argument");
        uREPL.RuntimeCommands.Register("func3", (x, y) => Debug.Log((int)x * (int)y), "multiply arg0 by arg1");
        uREPL.RuntimeCommands.Register("func4", (x, y, z) => Debug.Log(x + " " + y + " " + z), "output all arguments");
        uREPL.RuntimeCommands.Register("func5", (int x) => Debug.Log(x), "output int value");
        uREPL.RuntimeCommands.Register("func6", (string x, float y) => Debug.Log(x + " is " + y), "output arg0 is arg1");
        uREPL.RuntimeCommands.Register("func7", (Vector3 pos, Quaternion rot, Vector3 scale) => Debug.Log(pos + " " + rot + " " + scale), "output unity-type values.");
    }

    void OnDisable()
    {
        uREPL.RuntimeCommands.Unregister("func1");
        uREPL.RuntimeCommands.Unregister("func2");
        uREPL.RuntimeCommands.Unregister("func3");
        uREPL.RuntimeCommands.Unregister("func4");
        uREPL.RuntimeCommands.Unregister("func5");
        uREPL.RuntimeCommands.Unregister("func6");
        uREPL.RuntimeCommands.Unregister("func7");
    }
}
  • If types are omitted, they become System.Object.
  • If types are given, arguments are automatically converted into them, and output an error if it failed.
  • You cannot use overload.
  • At most 3 arguments now.

Built-in Commands

  • help
    • show keybinds.
  • commands
    • show all commands.
  • close
    • close uREPL window.
  • exit
    • exit game.

Completion

uREPL supports three completion methods by default:

  • Context
  • Command
  • GameObject name / path

You can add completion plugins by adding a class that inherits from uREPL.CompletionPlugin and overrides GetCompletions(). This class is derived from MonoBehaviour, so you can collect information using its callbacks. The following code is a sample for GameObject name completion.

using UnityEngine;
using System.Linq;
using uREPL;

public class SampleCompletion : CompletionPlugin
{
	string[] gameObjectNames_;

	public void Update()
	{
		gameObjectNames_ = GameObject.FindObjectsOfType<GameObject>()
			.Select(go => go.name)
			.ToArray();
	}

	// This method is called from a non-main thread.
	// If you want to use such as GameObject-related data, please get it in the main thread.
	public override CompletionInfo[] GetCompletions(string input)
	{
		var partialName = input.Substring(input.LastIndexOf("\"") + 1);
		return gameObjectNames_
			.Where(name => name.IndexOf(partialName) != -1)
			.Select(name => new CompletionInfo(partialName, name, "G", Color.red))
			.ToArray();
	}
}

Logs

You can output 3 level logs by uREPL.Log.Output(string), uREPL.Log.Warn(string), and uREPL.Log.Error(string).

static public class LogTest
{
	static public void ShowLogs()
	{
		uREPL.Log.Output("this is normal log.");
		uREPL.Log.Warn("this is warning log.");
		uREPL.Log.Error("this is error log.");
	}
}

log examples

Inspector

You can inspect GameObject by calling GameObject.Inspect(). This shows position, rotation, scale, and components added to it.

gameobject inspector

You can also inspect Component by clicking the inspect icon or calling Component.Inspect().

component inspector

See the following videos for more details:

Multi-Line

Toggle single-line and multi-line modes by Ctrl-m or clicking the right-top icon in the input area.

multiline mode

Others

  • World Space GUI
    • Set the Render Mode of the Canvas component as World Space.
  • Multiple GUI
    • You can locate multiple GUIs in a scene.
  • Builds
    • Almost all functions are available even in the built binary.

More Repositories

1

uRaymarching

Raymarching Shader Generator in Unity
HLSL
1,189
star
2

UnityFurURP

Fur shader implementation for URP
HLSL
659
star
3

uLipSync

MFCC-based LipSync plug-in for Unity using Job System and Burst Compiler
C#
556
star
4

uDesktopDuplication

Desktop Duplication API implementation for Unity (only for Windows 8/10)
C++
509
star
5

uWindowCapture

This allows you to use Windows Graphics Capture / PrintWindow / BitBlt in Windows to capture multiple windows individually and easily use them as Texture2D in Unity.
C++
469
star
6

UnityScreenSpaceBoolean

Screen Space Boolean Implementation for Unity.
ShaderLab
244
star
7

UnityWaterSurface

Water Surface Simulation using CutomRenderTexture in Unity 2017.1
ShaderLab
236
star
8

UnityVolumeRendering

A simple example of Volume Rendering for Unity.
GLSL
159
star
9

uRaymarchingExamples

Examples using uRaymarching (https://github.com/hecomi/uRaymarching)
C#
141
star
10

MMD4Mecanim-LipSync-Plugin

LipSync and TTS Plugin for MMD4Mecanim
C#
140
star
11

uShaderTemplate

This is an Unity editor extension for generating shader code from template files.
C#
133
star
12

UnityPseudoInstancedGPUParticles

GPU Particles w/ Screen Space Collision Example.
GLSL
109
star
13

UnityECSBoidsSimulation

Simple Boids simulation example using Unity ECS.
C#
108
star
14

uWintab

Wintab API plugin for Unity
C++
99
star
15

node-mecab-async

Asynchronous japanese morphological analyser using MeCab.
JavaScript
94
star
16

uChromaKey

Chroma key shader asset for Unity
ShaderLab
91
star
17

uDllExporter

Tool to build DLLs in Unity.
C#
80
star
18

VrGrabber

VR Grabber components for Unity
C#
79
star
19

node-julius

Node.js module for voice recognition using Julius
C
72
star
20

UnityRemoteDesktopDuplication

An Unity example to send a desktop image to a remote PC using Desktop Duplication API and NVENC/NVDEC.
C#
64
star
21

uHomography

Homography Transformation Image Effect for Unity.
C#
64
star
22

HLSLToolsForVisualStudioConfigGenerator

Create shadertoolsconfig.json for Unity project
C#
60
star
23

uCurvedScreen

Curved-sreen shader aseet for Unity.
ShaderLab
57
star
24

UnityRaymarchingCollision

Raymarching x Rigidbody interaction example.
GLSL
54
star
25

NodejsUnity

Run Node.js automatically when Unity application starts, and they communicate with each other.
C#
51
star
26

UWO

Unity WebGL x WebSocket MMO demo
C#
49
star
27

node-openjtalk

Node.js TTS module using OpenJTalk
C++
49
star
28

Unity-WebGL-3D-Chat

Unity5 WebGL x Socket.IO = Online 3D Chat on the web browser!
JavaScript
44
star
29

UnityScreenSpaceReflection

Simple Screen Space Reflection Implementation.
GLSL
43
star
30

UnityDICOMVolumeRendering

This is a simple project for volume rendering of DICOM data in Unity.
C#
43
star
31

UnityRaymarchingSample

Unity3D Raymarching Simple Implementation.
GLSL
41
star
32

uNvEncoder

A simple wrapper of NVENC (NVIDIA's HW-accelerated encoder) for Unity.
C
41
star
33

uTouchInjection

Windows Multitouch Injection Plugin for Unity.
C#
38
star
34

UnityNativeTextureLoader

This is an example to load textures from StreaminAssets directory or web in a native plugin.
C++
36
star
35

tsubakumi2

Home Automation System for @hecomi room
JavaScript
36
star
36

HoloLensPlayground

My playground for HoloLens.
C#
31
star
37

uNvPipe

A simple NvPipe wrapper for Unity
C
25
star
38

UnityTimelineExample

A simple example of creating custom Track and Clip
C#
22
star
39

StereoAR-for-Unity

Oculus Rift にて 2 つの Playstation Eye を通じて現実世界を立体視し、更にそこへ AR を重畳するプロジェクトです。
C#
20
star
40

LITTAI

Interaction recognizer for LITTAI project.
C++
20
star
41

LITTAI-game

Unity project for the table-top projection game, LITTAI.
C#
20
star
42

unity-android-aruco-sample

Unity x Android x OpenCV x ArUco sample project.
C++
20
star
43

UnityCustomTextureUpdate

An example to load texture using CustomTextureUpdate().
C
19
star
44

node-wemo

Belkin 社の WeMo を操作する Node モジュールです
JavaScript
19
star
45

UnityRaymarchingForward

Example of raymarching in forward rendering for Unity
HLSL
17
star
46

UnityKinectV2DeferredRendering

Unity sample project to draw KinectV2 depth sensor values into G-Buffer directly.
C#
17
star
47

QwertyVR

An Unity sample project for my Mixed Reality-based concept, Visual IO.
C#
17
star
48

uNetVoice

Tiny voice chat implementation for Unity.
C#
16
star
49

CyalumeLive

Unity でシェーダを使って 20,000 人がサイリウムを音楽に合わせて振るデモです。
C
14
star
50

UnityWebGLAudioStream

A simple sample that uses the Web Audio API to play float[] sent from Unity in a WebGL build
C#
10
star
51

node-oll

Node.js module for oll (Online-Learning Library)
Shell
10
star
52

create-upm-branch-action

A Github Actions to create release branches for Unity Package Manager
Shell
10
star
53

UnityCustomFunctionNodeExample

Custom Function Node Example in Unity Shader Graph
HLSL
9
star
54

T265_Playground

Simple implementation of positional tracking for Oculus Go
C#
8
star
55

HmdInputModule

Unity VR cursor module
C#
7
star
56

dotfiles

...
Vim Script
7
star
57

node-iRemocon

iRemocon module for Node.js
JavaScript
7
star
58

node-execSync

node.js で shell コマンドを同期的に実行するアドオンです
C++
7
star
59

UnityCustomTextureUpdateForDXT1

CustomTextureUpdate for DXT1
C
7
star
60

Julius2iRemocon

Home electronics operation by speech recognition is enabled using Julius and iRemocon.
C++
6
star
61

MyoUnity-with-RawData

Emg raw data and RSSI are available
C#
5
star
62

uPacketDivision

A native plugin for Unity that provides simple packet division and restoration.
C++
5
star
63

qml-osc

QML custom element that can handle OSC.
C++
5
star
64

NativePluginExample

Unity Advent Calendar 2017 - 21 日目の記事のサンプルプロジェクトです
C#
4
star
65

node-kaden

node.js-based home electronics control system.
C
3
star
66

Outlinus

VR Effect Tool for Oculus Rift x Ovrvision
C++
3
star
67

node-openjtalk-waf

C
3
star
68

node-kana2voca

Katakana to Julius voca format converter
C++
3
star
69

TangoPlayground

my Google Tango application playground (Unity).
C#
3
star
70

node-tw2email

Twitter の特定のリストの TL をメールで送信してくれるヤツです
JavaScript
3
star
71

HAS-Project

Home Automation System (HAS) Project that makes our life lazier.
C++
2
star
72

Xml2dfa

[Julius] コマンドを記述した XML ファイルから dfa ファイルと dict ファイルを生成する
C++
2
star
73

node-voca

ICU を利用してカタカナをローマ字や Julius の voca 形式に変換する Node.js アドオンです。
C++
2
star
74

unite-fhc

Unite.vim source for Future Home Controller
Vim Script
1
star
75

JuliuslibTest

C
1
star
76

LegoAnalyzer

Maker Faire Tokyo に出展予定の LEGO の凹凸を検出する Qt ベースのアプリです
C++
1
star
77

Hellospc

HelloSPCafe
C
1
star
78

node-mecab

node.js から MeCab を利用したり文字列をカタカナに変換するアドオンです
C++
1
star
79

tsubakumi

音声認識家電コントロールシステム@hecomi 家
JavaScript
1
star
80

Blender

Blender 作品のアーカイブです。
1
star
81

tsubakumi-android-wear

凹家のホームオートメーションの Android Wear 連携用プロジェクト
Java
1
star
82

uMicrophoneWebGL

Enable microphone input buffer access in Unity WebGL builds
C#
1
star