Skip to content

Instantly share code, notes, and snippets.

View mattbenic's full-sized avatar

Matt Benic mattbenic

View GitHub Profile
@mattbenic
mattbenic / BatchDownloader.cs
Created October 6, 2020 10:17
Batch downloader that runs multiple download coroutines in parallel using a provided host MonoBehaviour
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using UnityEngine;
namespace MB.Other
{
public class BatchDownloader
{
@mattbenic
mattbenic / appveyor.yml
Last active April 9, 2022 21:05
AtomicGameEngine appveyor build
version: 1.0.{build}
branches:
only:
- master
image: Visual Studio 2015
configuration: Debug
platform: x64
environment:
appveyor_rdp_password: P@ssw0rd1
init:
@mattbenic
mattbenic / FooBuilder.plugin.ts
Created September 1, 2016 13:20
Atomic Editor Plugin that accesses the scene
/// <reference path="../Scripts/Generated/AtomicWork.d.ts" />
/// <reference path="../Scripts/Generated/Editor.d.ts" />
/// <reference path="../Scripts/Generated/EditorWork.d.ts" />
const FooBuilderServiceUILabel = "Foo Builder";
const FooBuilderServiceTBPath = "EditorData/FooBuilder.tb.txt";
class FooBuilderService implements
Editor.HostExtensions.HostEditorService,
Editor.HostExtensions.ProjectServicesEventListener,
@mattbenic
mattbenic / CompiledInUnity.cs
Created July 18, 2016 07:31
Relative loop performance tests in Unity and VS compiled code
// Included directly in Unity
using System.Collections.Generic;
using System.Diagnostics;
public static class CompiledInUnity
{
private const int ArrayLength = 20;
private const long BatchSize = 10000000;
@mattbenic
mattbenic / SmtpClientExtensions.cs
Last active November 22, 2018 03:25
Extension method to have SmtpClient's SendMailAsync respond to a CancellationToken
using System;
using System.Net.Mail;
using System.Threading;
using System.Threading.Tasks;
public static class SmtpClientExtensions
{
/// <summary>
/// Extension method to have SmtpClient's SendMailAsync respond to a CancellationToken
/// </summary>
@mattbenic
mattbenic / AppSettingsValueBindingWrapper.cs
Created April 11, 2015 08:23
A generic wrapper for AppSettings values to allow them to be used in Windows Forms bindings
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Configuration;
using System.Reflection;
using System.ComponentModel;
/// <summary>
@mattbenic
mattbenic / SpecificInstanceOfGameExample.cs
Last active June 11, 2023 14:40
Example of using Win32 API to get specific window instance in Unity. This is useful for when running multiple instances of the same application, as the window handle can then be used to correctly position and size the different windows for multi screen use.
using UnityEngine;
using System;
using System.Runtime.InteropServices;
using System.Text;
public class SpecificInstanceOfGameExample : MonoBehaviour
{
#region DLL Imports
private const string UnityWindowClassName = "UnityWndClass";
@mattbenic
mattbenic / CoroutineWrapper.cs
Created June 3, 2013 09:10
A Unity3D coroutine wrapper for simple thread jobs. This can be added to any utility class, and then passed a thread function (run on the worker thread, be sure to make any shared variable access threadsafe) and a callback called when the thread is done (run on the main thread, no locking needed).
/// <summary>
/// A coroutine used to run a function on once-off thread
/// Note that the thread function is responsible for ending itself,
/// the coroutine makes no effort to explicitly end the thread.
/// </summary>
/// <typeparam name="T">Type of the parameter passed to the thread function</typeparam>
/// <param name="threadFunc">The thread function</param>
/// <param name="doneFunc">Function called when the thread has completed it's work and is no longer alive.</param>
/// <param name="param">Parameter passed to the thread function</param>
/// <returns>An enumerator</returns>
@mattbenic
mattbenic / MultiDragAndDropExample.cs
Created April 5, 2013 15:15
Accepting drag and drop to multiple layout controlled areas in Unity Editor scripts.
using UnityEngine;
using UnityEditor;
using System.Collections;
using System.Text;
public class MultiDragAndDropExample : EditorWindow
{
[MenuItem("Examples/Multi Drag and Drop")]
public static void ShowWindow()
{
@mattbenic
mattbenic / .gitignore
Last active April 9, 2022 21:08
Common .gitignore file for Unity 3D projects Originally based on Github's default Unity 3D .gitignore
# Unity automatically generated files/folders
[Ll]ibrary/
[Tt]emp/
[Oo]bj/
[Uu]nityGenerated/
# Autogenerated VS/MD solution and project files
*.csproj
*.unityproj
*.sln