Skip to content

Instantly share code, notes, and snippets.

@wtrebella
wtrebella / ApplyMenuTransformItem.cs
Last active August 22, 2022 06:15
This is a Unity menu item script that allows you to easily apply a transform's values to its direct children
/*
Demo video: https://i.imgur.com/bRlAHT9.mp4
This tool allows you to easily apply a transform's values to its direct children.
For example, say we have a parent object called "Starfield" that holds 100 "Star" game objects as direct children.
The Starfield's rotation is set to (x=0, y=0, z=0), and ideally you'd like to keep it that way (for some whatever reason).
But The Stars are arranged in a certain pattern, and it doesn't look right. You don't want to manually adjust
each individual Star. So you rotate the Starfield object to rotate the entire starfield itself.
Shader "Sprites/Default with UV Noise"
{
Properties
{
[PerRendererData] _MainTex ("Sprite Texture", 2D) = "white" {}
_Color ("Tint", Color) = (1,1,1,1)
_NoiseAmt ("Noise Amt", Range(0, 1)) = 0.5
_NoiseScaleX ("Noise Scale X", Float) = 1
_NoiseScaleY ("Noise Scale Y", Float) = 1
_NoiseTex ("Noise Texture", 2D) = "white" {}
using UnityEngine;
using System.Collections;
public delegate void IntDelegate(int value);
public delegate void GenericEventDelegate();
[RequireComponent(typeof(AudioSource))]
public class Metronome : Singleton<Metronome>
{
public IntDelegate SignalPhraseImmediate;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEditor;
public class RingColliderWindow : EditorWindow {
private GameObject _parentObj;
private int _numColliders = 6;
private float _ringRadius = 2.0f;
private float _colliderRadius = 0.5f;
// Rainbow shader with lots of adjustable properties!
Shader "_Shaders/Rainbow" {
Properties {
_Saturation ("Saturation", Range(0.0, 1.0)) = 0.8
_Luminosity ("Luminosity", Range(0.0, 1.0)) = 0.5
_Spread ("Spread", Range(0.5, 10.0)) = 3.8
_Speed ("Speed", Range(-10.0, 10.0)) = 2.4
_TimeOffset ("TimeOffset", Range(0.0, 6.28318531)) = 0.0
}
using System.Collections.Generic;
using System.Linq;
using UnityEngine;
using System.Collections;
using System;
using System.Runtime.Serialization.Formatters.Binary;
using System.IO;
public class PlayerPrefsHelper {
public static void SetList<T>(string key, List<T> list) {
@wtrebella
wtrebella / CameraScreenGrab.cs
Created May 6, 2014 02:13
This will pixelate a camera's output
using UnityEngine;
using System.Collections;
// this script is an altered version of a script found here:
// http://krauspe.eu/r/Unity3D/comments/20arg7/i_made_a_script_to_make_a_unity_camera_render/
[ExecuteInEditMode]
public class CameraScreenGrab : MonoBehaviour {
//how chunky to make the screen
@wtrebella
wtrebella / SpriteAnimator.cs
Created November 20, 2013 05:51
SpriteAnimator by Alec Holowka. Just putting it here so I don't lose it!
using UnityEngine;
using System.Collections;
public class SpriteAnimator : MonoBehaviour
{
[System.Serializable]
public class AnimationTrigger
{
public int frame;
public string name;
@wtrebella
wtrebella / WTUtils.cs
Created September 9, 2013 19:36
Circle/Polygon Intersection from Pivvot's Code
using UnityEngine;
using System.Collections;
// Line segment intersection based on this: http://www.pdas.com/lineint.html
// Intersect circle/polygon algorithm based on this: http://gamedev.stackexchange.com/questions/7735/how-to-find-if-circle-and-concave-polygon-intersect
public static class WTUtils {
public static bool IntersectLineSegments(Vector2 p0, Vector2 p1, Vector2 p2, Vector2 p3) {
Vector2 s1 = p1 - p0;
Vector2 s2 = p3 - p2;
@wtrebella
wtrebella / WTLabel
Created August 3, 2013 08:50
Word wrapping and coloring labels
using UnityEngine;
using System.Collections;
public class WTLabel : FLabel {
protected Color[] quadColors_;
public WTLabel(string fontName, string text) : base(fontName, text) {
}