Skip to content

Instantly share code, notes, and snippets.

View wowbroforce's full-sized avatar

Prokhor Kharchenko wowbroforce

View GitHub Profile
using UnityEngine;
using System.Linq;
using System.Collections.Generic;
public static class LinqExtensions {
public static T Random<T>(this IEnumerable<T> list) {
if (list != null && list.Any ())
return list.ElementAt(UnityEngine.Random.Range(0, list.Count()));
return default(T);
}
@wowbroforce
wowbroforce / CreateEditorWindowSubclassMenuItem.cs
Last active August 29, 2015 14:19
Unity editor menu item for creating EditorWindow subclass. Place this file into 'Editor' folder.
using UnityEditor;
using System.CodeDom;
using System.IO;
using System.CodeDom.Compiler;
public class CreateEditorWindowSubclassMenuItem {
[MenuItem("Assets/Create/File/EditorWindow Subclass...", false, 12)]
private static void CreateEditorWindowClass() {
var filePath = EditorUtility.SaveFilePanelInProject("Save file", "EditorWindowSubclass", "cs", "Enter class name");
if (!string.IsNullOrEmpty(filePath)) {
@wowbroforce
wowbroforce / CreateMonoBehaviourSubclassMenuItem.cs
Last active August 29, 2015 14:19
Unity editor menu item for creating MonoBehaviour subclass. Place this file into 'Editor' folder.
using UnityEditor;
using System.CodeDom;
using System.IO;
using System.CodeDom.Compiler;
public class CreateMonoBehaviourSubclassMenuItem {
[MenuItem("Assets/Create/File/MonoBehaviour Subclass...", false, 11)]
private static void CreateMonoBehaviourClass() {
var filePath = EditorUtility.SaveFilePanelInProject("Save file", "MonoBehaviourSubclass", "cs", "Enter class name");
if (!string.IsNullOrEmpty(filePath)) {
@wowbroforce
wowbroforce / CreateInterfaceMenuItem.cs
Last active August 29, 2015 14:19
Unity editor menu item for creating interface. Place this file into 'Editor' folder.
using UnityEditor;
using System.CodeDom;
using System.IO;
using System.CodeDom.Compiler;
public class CreateInterfaceMenuItem {
[MenuItem("Assets/Create/File/Interface...", false, 10)]
private static void CreateInterface() {
var filePath = EditorUtility.SaveFilePanelInProject("Save file", "Interface", "cs", "Enter interface name");
if (!string.IsNullOrEmpty(filePath)) {
@wowbroforce
wowbroforce / CreateClassMenuItem.cs
Last active August 29, 2015 14:19
Unity editor menu item for creating simple class. Place this file into 'Editor' folder.
using UnityEditor;
using System.CodeDom;
using System.IO;
using System.CodeDom.Compiler;
public class CreateClassMenuItem {
[MenuItem("Assets/Create/File/Class...", false, 13)]
private static void CreateClass() {
var filePath = EditorUtility.SaveFilePanelInProject("Save file", "Class", "cs", "Enter class name");
if (!string.IsNullOrEmpty(filePath)) {