• Stars
    star
    123
  • Rank 288,526 (Top 6 %)
  • Language
    C#
  • Created almost 5 years ago
  • Updated over 1 year ago

Reviews

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

Repository Details

Simple, quick and good looking GUI windows for Unity, intended for prototyping and debugging

ProtoGUI

Simple, quick and good looking GUI windows for Unity, intended for prototyping and debugging. The package includes Inconsolata open source font by Raph Levien.

Warning: It is basically a wrapper for Unity's IMGUI, so it is not very performant and GC friendly! The goal of it however is ease of use and is not recommended for production (although I am using it in TBICCT)

If you want something like this but more performant, you'll have to wait until Unity's UIElements become available for runtime.

Installation

Use it as a Unity package, so don't put it in your assets folder, instead either put it in the Packages folder, or some other common folder (to which you can reference from different projects). Then and add it using the Package Manager "+" icon > "Add package from disk..".

How To Use

All you need to do is just inherit from WindowGUI, and then implement the required methods (ctrl + . in VS or Rider). Set the window title, and you can simply start using your window with GUILayout:

using Nothke.ProtoGUI;

public class MyWindow : WindowGUI
{
    public override string WindowLabel => "My cute window!";

    protected override void Window()
    {
        GUILayout.Label("Hello World!");
        GUILayout.Button("Click me!");
    }
}

Put the script on any object in the scene and you should see this:

image

..It's also draggable ;)

A few more useful methods

There are a few more useful methods that you can use to make things easy:

using Nothke.ProtoGUI;

public class WindowExample : WindowGUI
{
    public override string WindowLabel => "My Window";

    bool toggleOn;
    float floatInput = 0;
    string stringInput = "";
    float slider1Value;
    int slider2Value;
    float slider3Value;
    bool showFoldout;

    private void Start()
    {
        // Optional values you can override
        windowRect.width = 400; // Sets initial window width
        labelWidth = 90; // Sets label width of a Slider()
        sliderNumberWidth = 50; // Sets width of the number in a Slider()
        draggable = true;
    }

    protected override void Window()
    {
        Label("Here are some things:");
        Button("Simple button!");

        ToggleButton("Toggle", ref toggleOn);

        Foldout("Foldout", ref showFoldout);

        if (showFoldout)
        {
            Label("Some things in the foldout:");

            // Inputs
            floatInput = FloatField("Input fl", floatInput);
            LabelField("Input str", ref stringInput);
        }

        // Float and int sliders:
        slider1Value = Slider("Float", slider1Value, 0.0f, 1.0f, "F2");
        slider2Value = Slider("Int", slider2Value, 0, 100);

        // A "notched" float slider that will step by stepSize
        slider3Value = Slider("Notched", slider3Value, 0, 2, 0.2f);
    }
}

The result:

image

The Toolbar

Additionally, you can use a toolbar, which can automatically detect all active windows and display them in a toggleable strip. Just add the ToolbarGUI script to any object and it will be rendered on top edge of the screen.

image

Detecting if mouse over the UI

You can use GameWindow.IsMouseOverUI() to detect if the mouse is currently over any of the windows. This is useful for preventing the mouse "clicking through" the UI or disabling keyboard input, for example.

Toggle all GUI with a key

Another utility is the GUIToggler, with which you can toggle the entire GUI (default is `). Just add the GUIToggler script to any GameObject.

More Repositories

1

unity-utils

A set of single script utils used throughout my projects
C#
216
star
2

UnityShaderCheatsheet

Collection of Unity shader copypastas and gotchas
ShaderLab
123
star
3

dx-highlighter

A Deus Ex/System Shock inspired pulsing bounds item highlighter for Unity
C#
90
star
4

UnityDOTSGotchas

Various DOTS Gotchas collected by me
69
star
5

normans-sky

Normans Sky made for lowrezjam '16
C#
66
star
6

csDelaunayUnity

GC free (non alloc) voronoi diagram for Unity
C#
56
star
7

NDraw

Runtime line drawing utility for Unity
C#
36
star
8

blender_unity_rotation_fix

Rotation fix for exporting from Blender to Unity
Python
33
star
9

StarMap

Rendering of stars in the night sky using the HYG database
C#
30
star
10

gridventory

Functions for making a simple grid inventory in Unity
C#
30
star
11

pikoralli

A small rally game made in pico8
Lua
15
star
12

b3d-attribute-converter

Converts geometry node attributes to built-in attributes
Python
13
star
13

Unity-Raymarching

GLSL
13
star
14

shakedown-docs

Documentation for Shakedown Rally
12
star
15

atmospheric-scattering

Atmospheric Scattering Unity package
C#
11
star
16

MeshX

Mesh extensions for Unity
C#
10
star
17

SimpleVanAllenBelts

SDF based Van Allen belt sampler, implemented in C# (Unity)
C#
10
star
18

SpinningMeshMotionBlur

Motion blur for fast spinning objects by rendering multiple meshes - example
C#
9
star
19

NativeMeshTests

Testing new Mesh support for NativeArray in Unity 2019.3
C#
9
star
20

serialization-experiments

Unity serialization experiments
C#
9
star
21

JobifiedTextureModifyTests

C#
8
star
22

PicoSpaceProgram

2D space program for Demake Jam 2018
Lua
7
star
23

AStar

A Unity package for basic AStar pathfinding
C#
7
star
24

IndentedDialogueParser

C#
7
star
25

LiteRally

A GeneRally clone
C#
6
star
26

NEngine

Learning how to make a small opengl game engine
C++
6
star
27

ThreadableCurve

Unity AnimationCurve that is thread safe
C#
6
star
28

Unity-VS-Code-Snippets

Vim Snippet
5
star
29

FPSCounter

Simple FPS Counter for Unity
C#
4
star
30

NAudio

Shortcuts/extensions for a single line audio clip playing and audio source creation
C#
4
star
31

blender_ac_exporter

One-click Assetto Corsa fbx export utility for Blender
Python
3
star
32

ecs-ribbon

C#
3
star
33

DoublePhysics

Double precision rigidbody physics for Unity
C#
3
star
34

FlyCam

A simple package for flying the camera around
C#
3
star
35

CableMaker

C#
2
star
36

nothke.github.io

JavaScript
2
star
37

mat2id_baker

Material to id map baker for blender that DOESN'T use Cycles
Python
2
star
38

ProcPort

Airport simulation for a PROCJAM project
C#
2
star
39

rts-proto

C#
2
star
40

GGJ18

The TV game
C#
2
star
41

PlaneParkingPackingProblem

3D tetris with planes and physics
C#
2
star
42

TODO-syntax-highlighter

A simple syntax highlighter for Sublime for TODO lists
2
star
43

CreaseOutline

Object highlight for Unity
C#
1
star
44

perfect-wave

A GGJ 17 game
C#
1
star
45

ECSJam

C#
1
star
46

quality-control

GMTK '24 game
C#
1
star
47

TCIBTTCT-code-ref

Code reference for TCIBTTCT towers
1
star
48

depplier

Script for easier C++ dependancies assignment
Python
1
star
49

cpp-project-template

Personal C++ premake project template
Python
1
star
50

moonsharp-unity-upm

A copy of Moonsharp for Unity that works with Unity package manager
C#
1
star
51

bezier-curves

Improved Bezier curves for Unity
C#
1
star
52

paths

General purpose simple networked paths for Unity
C#
1
star
53

mesh-as-asset

Test project for saving procedural meshes outside of scene files
C#
1
star
54

ProcPuddler

Filling a heightmap with standing water
C#
1
star
55

NAudio-Project

Shortcuts/extensions for a single line audio clip playing and audio source creation
C#
1
star
56

hanoi-track-ac

Vietnam GP Hanoi track for Assetto Corsa, source files
1
star
57

vehdyn-interfaces

Package for interfacing between various vehicle dynamics implementations
C#
1
star