Skip to content

Instantly share code, notes, and snippets.

@zonaryFUND
Last active August 29, 2015 14:02
Show Gist options
  • Save zonaryFUND/71b54517056929fa31e0 to your computer and use it in GitHub Desktop.
Save zonaryFUND/71b54517056929fa31e0 to your computer and use it in GitHub Desktop.
Registers Unity's Texture2D as an icon of System.Windows.Fomrs.Notifyicon (requires mono dll)
using UnityEngine;
using System.Windows.Forms;
public class WindowsNotifyIcon {
NotifyIcon notifyIcon;
public void RegisterNotifyIcon(Texture2D iconTexture) {
notifyIcon = new NotifyIcon();
MemoryStream memStream = new MemoryStream(iconTexture.EncodeToPNG());
memStream.Seek(0, SeekOrigin.Begin);
System.Drawing.Bitmap bitmap = new System.Drawing.Bitmap(memStream);
notifyIcon.Icon = System.Drawing.Icon.FromHandle(bitmap.GetHicon());
notifyIcon.Visible = true;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment