Skip to content

Instantly share code, notes, and snippets.

@kernalphage
Last active August 29, 2015 14:08
Show Gist options
  • Save kernalphage/5a7c32d9f5733e59cb15 to your computer and use it in GitHub Desktop.
Save kernalphage/5a7c32d9f5733e59cb15 to your computer and use it in GitHub Desktop.
using UnityEngine;
using UnityEditor;
using System.Collections;
public class SpoopyEditor : EditorWindow {
static float hauntTime = 0;
static float hauntSpeed = .005f;
static bool haunting = false;
public Texture2D skeletons = (Texture2D) Resources.Load("spook/ghost.jpg", typeof(Texture2D));
public SceneView scene = null;
de
public static void StartTheHaunt()
{
EditorWindow.GetWindow(typeof(SpoopyEditor));
haunting = true;
hauntTime = 0;
}
void OnGUI () {
// The actual window code goes here
Rect wholeBox = new Rect(0,0,skeletons.width, skeletons.height);
EditorGUI.DrawPreviewTexture(wholeBox, skeletons);
}
//Animate at a buttery smooth 100fps
void Update()
{
if(haunting)
{
hauntTime += hauntSpeed;
if(hauntTime > 3.14)
{
hauntTime = 0;
haunting = false;
this.Close();
}
if(skeletons)
{
this.position = new Rect(hauntTime * 800, 200, skeletons.width, skeletons.height);
}
}
}
}
//Actually listens to the save command
public class SpoopyListener : UnityEditor.AssetModificationProcessor {
public static bool isSaving = true;
public static string[] OnWillSaveAssets(string[] paths)
{
SpoopyEditor.StartTheHaunt();
return paths;
}
}
@liam-middlebrook
Copy link

10/10 - Hands down the most useful editor plugin I've come across 👻

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment