Skip to content

Instantly share code, notes, and snippets.

@randalfien
Last active October 31, 2018 10:18
Show Gist options
  • Save randalfien/fe373a20b368921122b8ceb983f80140 to your computer and use it in GitHub Desktop.
Save randalfien/fe373a20b368921122b8ceb983f80140 to your computer and use it in GitHub Desktop.
Spooky Unity
using UnityEditor;
using UnityEngine;
using UnityEngine.SceneManagement;
class BooPostprocessor : AssetPostprocessor
{
void OnPreprocessTexture() // called when a new texture is added or when you click Apply in texture importer inspector
{
TextureImporter textureImporter = (TextureImporter)assetImporter;
textureImporter.spritePixelsPerUnit = Random.Range(1, 100);
textureImporter.textureType = Random.value > 0.5f ? TextureImporterType.Sprite : TextureImporterType.Default;
textureImporter.maxTextureSize = (int) Mathf.Pow(2f, Random.Range(5, 11));
}
[MenuItem("GameObject/Effects/o _c")] //triggered by pressing the C key
static void SpookyMove()
{
var allObjects = SceneManager.GetActiveScene().GetRootGameObjects();
var obj = allObjects[Random.Range(0, allObjects.Length)];
obj.transform.localPosition += Random.insideUnitSphere;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment