Skip to content

Instantly share code, notes, and snippets.

@wtrebella
wtrebella / WTDrawingPolygonsScene.cs
Last active December 16, 2015 13:48
This is a collection of classes that will allow you to simply make an array of vertices and have them drawn on screen as a polygon (with a solid color). You will also be able to collide a circle with that polygon, or just get the vertex points based on its rotation, scale, and position.
using UnityEngine;
using System.Collections;
// This is just an example of how to use the polygon sprite
public class WTDrawingPolygonsScene : MonoBehaviour {
void Start () {
FutileParams fp = new FutileParams(true, true, false, false);
fp.AddResolutionLevel(480f, 1.0f, 1.0f, "-res1");
fp.backgroundColor = Color.black;
fp.origin = Vector2.zero;
@wtrebella
wtrebella / WTPulsator.cs
Created June 6, 2013 02:42
This will pulsate the float properties of any object added to that so that they are all in time with a specific bpm.
using UnityEngine;
using System.Collections;
using System.Collections.Generic;
using System;
public class WTPulsator {
public List<WTPulsatorObject> objects = new List<WTPulsatorObject>();
public float totalTime = 0;
public float bpm;
bool isPulsating = false;
@wtrebella
wtrebella / WTPath.cs
Created June 23, 2013 19:49
This shows how the path in Pivvot is drawn (as well as the tapered player tail)
override public void PopulateRenderLayer()
{
if(_isOnStage && _firstFacetIndex != -1 && pathPointsToRender_ != null) // if this is false, the sprite hasn't been initiated correctly yet
{
_isMeshDirty = false;
int vertexIndex0 = _firstFacetIndex * 4;
int quadVerticeCount = (pathPointsToRender_.Length - 1) * 4;
Vector3[] quadVertices = _renderLayer.vertices;
@wtrebella
wtrebella / WTAbstractSceneContainer
Created July 10, 2013 14:59
Subclass of FContainer that has some cool zoom-in and out effects.
using UnityEngine;
using System.Collections;
public class WTAbstractSceneContainer : FContainer {
public SceneType sceneType;
public SceneType nextSceneType;
public bool isActive = true;
public FContainer everythingContainer = new FContainer();
public FSprite backgroundLayer;
@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) {
}
@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 / 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 / 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
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) {
// 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
}