Skip to content

Instantly share code, notes, and snippets.

View wowbroforce's full-sized avatar

Prokhor Kharchenko wowbroforce

View GitHub Profile
@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)) {
@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 / 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 / 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)) {
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);
}
using UnityEngine;
using System.Collections;
public static class GameObjectExtensions {
public static GameObject Instantiate(this Object prefab) {
return GameObject.Instantiate (prefab) as GameObject;
}
}
@wowbroforce
wowbroforce / CoroutineExtensions.cs
Last active August 29, 2015 14:22
Simple actions, based on coroutines and callbacks. Delays, loops etc...
using UnityEngine;
using System.Collections;
using System;
public static class CoroutineExtensions {
public static void StartWaitForSeconds(this MonoBehaviour target, float seconds, Action completion) {
target.StartCoroutine (WaitForSeconds (seconds, completion));
}
@wowbroforce
wowbroforce / insert_build_phases.rb
Created January 7, 2017 21:19
Example of adding 'Shell Script Build Phase' to Xcode project using Fastlane action and Xcodeptoj tool
module Fastlane
module Actions
module SharedValues
INSERT_BUILD_PHASES_CUSTOM_VALUE = :INSERT_BUILD_PHASES_CUSTOM_VALUE
end
class InsertBuildPhasesAction < Action
def self.run(params)
require 'xcodeproj'
@wowbroforce
wowbroforce / GLSL-Noise.md
Created February 14, 2018 08:28 — forked from patriciogonzalezvivo/GLSL-Noise.md
GLSL Noise Algorithms

Generic 1,2,3 Noise

float rand(float n){return fract(sin(n) * 43758.5453123);}

float noise(float p){
	float fl = floor(p);
  float fc = fract(p);
	return mix(rand(fl), rand(fl + 1.0), fc);
}
using UnityEngine;
[CreateAssetMenu(fileName = "FloatVariable", menuName = "~/Assets/Scripts/FloatVariable")]
public class FloatVariable : Variable<float> { }