Skip to content

Instantly share code, notes, and snippets.

View corycorvus's full-sized avatar

Cory Corvus corycorvus

View GitHub Profile
@corycorvus
corycorvus / WindowsNativeDialog.cs
Created October 11, 2017 06:14
Class for displaying native Windows modal dialogs in Unity
using System.Windows.Forms;
// Requires System.Windows.Forms added to a Plugins folder ( C:\Program Files\Unity\Editor\Data\MonoBleedingEdge\lib\mono\2.0)
// Requires .NET 2.0 (setting Player Setting -> Configuration -> Api Compatibility Level set to .NET 2.0)
// Warning! May throw windows errors in editor but works fine in builds
// Example Usage:
// WindowsNativeDialog.SimpleMessage("Hello World!");
// WindowsNativeDialog.Message("Hello World!", "Title");
// WindowsNativeDialog.WarningMessage("Hello World!", "Title");
@corycorvus
corycorvus / UnityMonoBehaviour.cs
Last active October 11, 2017 06:15
Unity MonoBehaviour Example
using UnityEngine;
// Unity MonoBehaviour Example
// MonoBehaviour is the base class from which every Unity script derives.
public class ExampleScript : MonoBehaviour
{
// Awake is called when the script instance is being loaded.
void Awake(){}
// Start is called on the frame when a script is enabled just before any of the Update methods is called the first time.
void Start(){}
@corycorvus
corycorvus / UnitySingleton.cs
Last active October 11, 2017 06:15
Unity Singleton Example
// Unity Singleton Example
// Call with "ClassName.instance.Example();"
public static ClassName instance = null; //Static instance of singleton which allows it to be accessed by any other script.
//Awake is always called before any Start functions
void Awake()
{
//Check if instance already exists
if (instance == null)
//if not, set instance to this