Last active
October 31, 2018 10:18
-
-
Save randalfien/fe373a20b368921122b8ceb983f80140 to your computer and use it in GitHub Desktop.
Spooky Unity
This file contains hidden or 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 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