This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#if UNITY_EDITOR | |
// only got it to work in the Editor | |
using UnityEngine; | |
using System; | |
using System.Collections; | |
using System.IO; | |
public class ScreenshotSequencer : MonoBehaviour |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#if UNITY_EDITOR | |
using UnityEngine; | |
using UnityEditor.Callbacks; | |
using UnityEditor; | |
using System.IO; | |
public static class PostBuildHook | |
{ | |
private static int filecount; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using UnityEngine; | |
using UnityEditor; | |
using JSONPersistency; | |
using UnityEditor.Callbacks; | |
public class SaveSceneHook : AssetModificationProcessor | |
{ | |
static string[] OnWillSaveAssets (string[] paths) | |
{ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using UnityEngine; | |
using UnityEditor; | |
using System.Collections; | |
using JSONPersistency; | |
[CustomEditor(typeof(DragNDrop))] | |
public class DragNDropInspector : Editor | |
{ | |
Color picked = Color.green; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using UnityEngine; | |
using UnityEditor; | |
// replace "SpawnZone" with the class of your Script on a GameObject | |
[CustomEditor(typeof(SpawnZone))] | |
public class SpawnZoneInspector : Editor | |
{ | |
// replace "SpawnZone" with the class of your Script on a GameObject | |
private SpawnZone myZone; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
private ReorderableList list; | |
list = new ReorderableList(property.serializedObject, property.FindPropertyRelative("tagList"), true, true, true, true); | |
list.drawHeaderCallback += rect => GUI.Label(rect, label); | |
list.drawElementCallback += (rect, index, active, focused) => | |
{ | |
rect.height = 16; | |
rect.y += 2; | |
EditorGUI.PropertyField(rect, | |
list.serializedProperty.GetArrayElementAtIndex(index), |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// http://www.third-helix.com/2013/04/12/doing-thumbstick-dead-zones-right.html | |
float deadzone = 0.25f; | |
Vector2 stickInput = new Vector2(Input.GetAxis(“Horizontal”), Input.GetAxis(“Vertical”)); | |
if(stickInput.magnitude < deadzone) | |
stickInput = Vector2.zero; | |
else | |
stickInput = stickInput.normalized * ((stickInput.magnitude - deadzone) / (1 - deadzone)); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Vector3 clickPos = new Vector3 (Input.mousePosition.x, Input.mousePosition.y, 0); | |
Ray camRay = Camera.main.ScreenPointToRay (clickPos); | |
RaycastHit hit; | |
if (Physics.Raycast (camRay.origin, camRay.direction, | |
out hit, rayLength, fieldMask)) { | |
// do awesome stuff here | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
private Color getAverageRGB (Texture2D tex) | |
{ | |
Color[] allPixels = tex.GetPixels (0, 0, tex.width, tex.height); | |
float r = 0; | |
float g = 0; | |
float b = 0; | |
int interationSteps = 1; | |
for (int i = 0; i < allPixels.Length; i += interationSteps) { |