Giter Club home page Giter Club logo

genui's Introduction

GenUI

Automatic OSC Control for Unity.

This plugins allows you to simply create a UI for your application, exposing script sliders, inputfield and method. This UI is also fully controllable via OSC.

Demo

Example Unity project can be found at : https://github.com/theoriz/genui-demo

What's inside ?

You can expose bool, int, float, string, List and Vector3 properties. It is possible to define a range for int and float in order to get a slider in the UI by adding the Range metadata, otherwise you would get an inputfield. Method appear as button in UI so you can't give it arguments but this is possible using OSC.

Default Shortcuts

  • H : Toggle the UI.
  • PageUp / PageDown: Scale up/down the UI, only when the UI is visible.
  • Ctrl + Left/Right/Up/Down arrow : Move the UI, only when the UI is visible.
  • R : Reset the UI, only when the UI is visible.

How to use ?

  1. Drop the prefab "GenUI" in your game.
  2. Create a new script inheriting from "Controllable". It will be the interface for the script you want to control.
  3. Add to this script every attributes you want to control with UI/OSC and the metadata "[OSCProperty]. You can use booleans to use or not the UI, presets, etc. Just be sure that your attributs have the same name as the one in the script you want to control.
  4. Add the metadata "[OSCMethod] above methods you want to expose.
  5. Run !
**CONTROLLABLE EXAMPLE**

public class MyScriptControllable : Controllable {

	// Expose variables from MyScript to OSC by creating OSCProperties with the name of those variables
	[OSCProperty]
	public int intParameter;

	[OSCProperty]
	public float floatParameter;
	
	[OSCProperty][Range(0,1)]
	public float floatParameterWithRange;
	
	[OSCProperty(isInteractible = false)]
	public bool readOnlyBoolParameter;

	//Create OSC methods to call methods from myScript
	[OSCMethod]
	public void MyOSCMethod() {
		(TargetScript as MyScript).MyScriptMethod();
	}
}

OSC Control

To access a property or launch a method you have to use its address. For example : "/OCF/id/method" or "/OCF/id/floatProperty/ 1.5" by default the id corresponds to the script type name but this can be changed by setting the public variable ID in your script extending "Controllable".

You can also get your own OSC messages by connecting to MessageAvailable event in OSCMaster. This event will be triggered for every OSC message which doesn't start by /OCF/.

Presets

This plugin comes with a preset system, you can save the state of a "'Controllable" script. It saves each property to a file that can be loaded later so that you can create differents settings for your script. To use it, simply click on "Save preset" then select the wanted preset inside the dropdown menu and press "Load Preset". It is also possible to load a specific file via the OSC method "LoadPresetWithName" giving it as argument :

  • fileName (string) : case sensitive;
  • duration (float) : tween duration in seconds;
  • tweenType (string) : "EaseInOut", "EaseIn", "EaseOut" or "Linear" if you want to tween the current value to preset's one;

Expose a List

To expose a string list you have to create a index string variable which will be used by the dropdown mennu as an index. It will allows you to know which element of the list is selected. Simply specify [OSCProperty(TargetList=yourListName)].

Dev

Unity 2018.1.8f1 OCF : http://github.com/theoriz/OCF

genui's People

Contributors

alexbourgeois avatar barbelot avatar benkuper avatar paulinelvne 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  avatar

Watchers

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

genui's Issues

How to loadpresetwithname

Hi, your code is great and very useful but i dont understand how i can load a specific preset with name, is it possible to load a preset with name from OSC too ? Can you explain me how to do it or add it to the example project. I have some problem too, i have an error on the console when it try to get my local ip adress (i'm working on mac os) and the show button return an error too and does not work. The smalls problem are not big issue because it work but the loading via OSC message will be great. Thank you for your work.

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.