Code Monkey home page Code Monkey logo

unity-winforms's Introduction

Important notice: project is no longer supported. I moved this whole thing from Unity to raylib.

Unity Windows Forms

A Windows Forms port (including System.Drawing) to Unity3d, built on top of 'UnityEngine.GUI' class.

Supported Controls

  • Button;
  • CheckBox;
  • ComboBox;
  • DateTimePicker;
  • FontDialog;
  • Form;
  • GroupBox;
  • HScrollBar;
  • Label;
  • LinkLabel;
  • ListBox;
  • MenuStrip;
  • MonthCalendar;
  • NumericUpDown
  • OpenFileDialog;
  • Panel;
  • PictureBox;
  • ProgressBar;
  • RadioButton;
  • SaveFileDialog;
  • SplitContainer;
  • TabControl;
  • TextBox;
  • Timer;
  • ToolStrip;
  • ToolTip;
  • TrackBar;
  • TreeView;
  • VScrollBar;

Additional custom controls:

  • BitmapLabel;
  • ColorPicker (replacement for ColorDialog);
  • Highchart (replacement for Chart);
  • RepeatButton;
  • TableView (replacement for DataGridView);

Usage

  1. Attach UnityWinForms script to GameObject;
  2. Add Arial font to resources;
  3. Add other fonts and images;
  4. Create Form control in your MonoBehaviour script;
using UnityEngine;

using System.Windows.Forms;

public class GameGuiController : MonoBehaviour
{
	void Start()
	{
		var form = new Form();
		form.Show();
		
		// Or show a message.
		//// MessageBox.Show("Hello World.");
	}
}

Screenshots

scr1 scr1

From other projects using Unity-WinForms

scr1 scr1

unity-winforms's People

Contributors

meragon 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  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  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  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  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  avatar

unity-winforms's Issues

Not an issue

Your wrapper and your help enabled me to finish my application. I just wanted to say thank you a lot for that. Here's the repository for my application Cube 3D. You're free to add it to your "Other projects who use my wraper" if you wish of course. Thanks a lot!

Multiselect for OpenFileDialog or ListBox

Hi, I can't seem to get any multiselect functionality with any of the form elements. You can't use the multiselect parameter with the open file dialogs, and with a ListBox there seems to be no way to set it so you can select multiple items. I'm kind of at a loss. I need a way to select multiple things, whether it's more than one file in an OpenFileDialog or just being able to pick more than one thing in a ListBox, either would be great.

Maybe I'm missing something? Are checkboxes the only way to have more than one selection in the same group of things?

Creating Custom Events

I am using the PanelMenuStrip from your Example, but I would like to have some more Events for the ToolStripMenuItems (like MouseEnter/ MouseLeave). Can you give me some tips on implementing this?

Can't disable resizing

I can't figure out how to disable resizing of a form.

I have tried to change the ControlResizeTypes type by calling SetResize(ControlResizeTypes.None).

The only solution I have figured out now is to set the min/max size to the same values, but this still allows the user to hover an edge to get the resize cursor.

License?

Hi there,

This project looks incredibly useful for use in larger projects - unfortunately the GPL means it's basically impossible to use in a commercial context. Could you consider a re-license to Apache2/MIT/BSD or LGPL?

Thanks!

How to use my own imported .ttf font file?

I added the .ttf font file format to the Asset folder. The name of .ttf font file is "times new roman.ttf". And then, I added font to the script UnityWinForms.
23e8db1f7e62c1a5568f39d9b6df930

I used the font that I imported in a new script.
Form form = new Form();
form.Font = new System.Drawing.Font("times new roman", 11);

But there was a error about "Font not found".
2a157de0388acaf85ad4d8cb81263bf

I wondered if there was something wrong with the format of my imported font file, or something else.

thanks!

Just 2 small questions

First of all, great Asset, love the look!

Altough ive got two small questions. First, the color of my TextBox is black when I focus it and regardless what im doing i cant change it.. just want it to be the normal white color. Second I couldnt manage to change the FontStyle to Bold.

Would appreciate every help, thank you

Textbox focus color and text color are the same

I'm having quite a time trying to make it so that the text color and focus background color for a text box are different. When you click on a text box to enter some text, the background changes to the same color as the text, very dark gray. There appears to be no way to change just the focus color.

When you change the ForeColor for your Textbox and then click on the text box, the focus color is different, but the text is now also that color, so there is no way to see what you are typing. The same thing actually happens with NumericUpDowns too. It happens in the Examples as well. I'll attach an image showing it with the NumericUpDown in the examples. Can anything be done about this?

numericupdownexample

suggest release dll or visual studio project?

hi,i want to release a dll ,and create visual studio project,but is need some time ,
so if you can release a dll,or create visual studio projecto?
that will very nice for user
image

Graphics not drawing crucial parts of forms making them unusable

As far as i see this problem occurs on comboboxes (like when rendering OpenFileDialog), thus making the forms unusable (half of stuff just disappears).

Stacktrace:
NullReferenceException: Object reference not set to an instance of an object System.Drawing.Graphics.uwfDrawImage (System.Drawing.Image image, System.Drawing.Color color, System.Single x, System.Single y, System.Single width, System.Single height) (at Assets/Scripts/Outsourced/Unity-WinForms-master/System/Drawing/Graphics.cs:195) System.Windows.Forms.ComboBox.OnPaint (System.Windows.Forms.PaintEventArgs e) (at Assets/Scripts/Outsourced/Unity-WinForms-master/System/Windows/Forms/ComboBox.cs:378) System.Windows.Forms.Control.RaiseOnPaint (System.Windows.Forms.PaintEventArgs e) (at Assets/Scripts/Outsourced/Unity-WinForms-master/System/Windows/Forms/Control.cs:604) System.Windows.Forms.Control.RaiseOnPaint (System.Windows.Forms.PaintEventArgs e) (at Assets/Scripts/Outsourced/Unity-WinForms-master/System/Windows/Forms/Control.cs:623) System.Windows.Forms.Application.Redraw () (at Assets/Scripts/Outsourced/Unity-WinForms-master/System/Windows/Forms/Application.cs:248) Unity.API.UnityWinForms.OnGUI () (at Assets/Scripts/Outsourced/Unity-WinForms-master/Unity/UnityWinForms.cs:330)

Buttons do not respond to events

    MessageBox.Show("zsq","zsq");
    
    Button button1 = new Button();
    button1.Location = new Point(108, 101);
    button1.Name = "button1";
    button1.Size = new Size(75, 23);
    button1.TabIndex = 0;
    button1.Text = "button1";
    button1.Click += (sender, args) =>
    {
        Debug.Log("test2");
       
    };

    Form form = new Form();
    form.Text = "zsq";
    form.MinimumSize = new Size(600, 400);
    form.Controls.Add(button1);
    
    form.Show();

image

I'd like your opinion on the performance

Hi

I regularly visit this repo because WinForm is exactly what I miss the most right now in Unity.
Big kudos for your wrapper !

The only thing that prevents me from using it now is that it seems a bit greedy in performance.

Do you have any suggestions or planning to improve on that?
I wonder if the new features of Unity 2018 could be an « easy way » to address this point.

Anyway, thanks for all !

Guide for usage?

Would it be possible to make a more detailed description of how you would actually use this in a project? It seems like a really good implementation of WinForms in Unity, but it's a bit hard to get started using it.

Is this cross platform?

Hello im very interested in porting AccordNet to unity and use it in mobile devices, but it depends heavily on system.drawing, is Your version cross platform?

any plan to support webbrowser in unity?

I tried to use webbrowser in a c# dll, it works fine when used in winform. but cannot work in unity.
when invoke webbrowser.navigate, error as below:

NullReferenceException: Object reference not set to an instance of an object
System.Windows.Forms.WebBrowser.Navigate (System.Uri url)

but webbrowser is actually not null!

AxHost

First I m soo impressed by the initiative of porting WInform to .NET! crazy work!

So my question: is AxHost also going to be ported?
i would love to do it but that seem way above my abilities

Accessing Unity functionality from WinForms

I'm trying to interact with game objects from the WinForms but can't seem to make it work. How would you go about turning on and off a game object from the WinForms class? What I hope to achieve is to make a WinForm button turn on and off a settings panel, which is a Unity game object. I'm running the script below to generate the tool strip. Since it doesn't derrive from MonoBehaviour I'm not able to directly attach and interact with game objects and was hoping it would be possible to just instanciate a class with the game object already connected.

using UnityEngine;
using System.Drawing;
using System.Windows.Forms;

public class WinFormToolStrip : Form
{
    public WinFormToolStrip()
    {
        // Instances of Unity classes
        PanelOpener panelOpener = new PanelOpener();
        panelOpener.TogglePanel();
        ...
    }

Save table

Hello!
I am pretty new to Unity and C#, so thank you for this very useful project!
I would like to ask if there is an easy way to save a table created with TableView script.
Thank you in advance!

Two little problems about close button of From and cell padding of TableView

First one, I can only adjust the spacing of the cells by CellPadding, but I can't just adjust the spacing between rows and keep the column spacing the same. I didn't find relevant attribute values in the TableView class.
Second one, I want to use my own picture as the close icon in the upper right corner of the form. My picture looks like this:
image

But, after I replaced the close.png in the Resources folder with my own picture, the close icon looks like this in the unity:
c76b31cb45ff9b5b98ddd7053d2d9c8
I wonder why the background color of my picture will be changed.

thanks!

Are the windows stuck inside game window?

Sorry it was unclear from the images provided. are the form windows restricted within the game rendering area or can they go to multiple monitors outside the primary game window and such?

No Example

Thanx for this Great Effort ,But problem is i dont know where to start ?
means there is no Example scene , no guide.

MessageBoxButtons?

I can't seem to get MessageBoxButtons to work. For example to have the MessageBox.Show with Yes, No and Cancel. Is this a functionality that simply hasn't been implemented?

How to use it in Unity

Hi,
I'm sorry to bother you, I'm a student and I have to code an application using Unity and Windows Form but I don't know how to code with that.
Is there an easy way to put what you did in a unity project ? Or should I write it all other again to make it work ?
Thank you very much for your answer.

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.