Created
February 5, 2020 05:34
-
-
Save Lachee/7b85ad53ed97b230e7f203c4d7392b46 to your computer and use it in GitHub Desktop.
Joke Script to include in a shared Unity Project that will slowly make everyone's editor "Play Mode" tint turn to black. Note that a black tint completely obfuscates the editor and makes it impossible to see the play button.
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
```cs | |
using System.Collections; | |
using System.Collections.Generic; | |
using UnityEditor; | |
using UnityEngine; | |
public class EditorColorLUT : MonoBehaviour | |
{ | |
private static float decrementation_chance = 0.1f; | |
private static float decrementation_amount = 0.01f; | |
[UnityEditor.Callbacks.DidReloadScripts] | |
private static void OnScriptsReloaded() | |
{ | |
//This logic makes it darker randomly | |
if (Random.value <= decrementation_chance) | |
{ | |
Color color = GetColor(); | |
color = Color.Lerp(color, Color.black, decrementation_amount); | |
SetColor(color); | |
} | |
} | |
[MenuItem("Edit/Playmode Color/Log Current")] | |
static void FetchCurrent() | |
{ | |
Debug.Log(GetColor()); | |
} | |
[MenuItem("Edit/Playmode Color/Restore Default")] | |
static void MakeDefault() | |
{ | |
SetColor(new Color(0.8f, 0.8f, 0.8f, 1f)); | |
} | |
[MenuItem("Edit/Playmode Color/Make Black UI")] | |
static void MakeBlack() | |
{ | |
SetColor(new Color(0.0001f, 0.0001f, 0.0001f, 1f)); | |
} | |
[MenuItem("Edit/Playmode Color/Make Invisible UI")] | |
static void MakeGray() | |
{ | |
SetColor(new Color(1f, 1f, 1f, 0f)); | |
} | |
public static void SetColor(Color color) | |
{ | |
EditorPrefs.SetString("Playmode tint", EncodeColor(color)); | |
} | |
public static Color GetColor() | |
{ | |
return DecodeColor(EditorPrefs.GetString("Playmode tint", "Playmode tint;0.8;0.8;0.8;1")); | |
} | |
private static Color DecodeColor(string lines) | |
{ | |
string[] parts = lines.Split(';'); | |
float r = float.Parse(parts[1]); | |
float g = float.Parse(parts[2]); | |
float b = float.Parse(parts[3]); | |
float a = float.Parse(parts[4]); | |
return new Color(r, g, b, a); | |
} | |
private static string EncodeColor(Color c) | |
{ | |
string lines = string.Format("Playmode tint;{0};{1};{2};{3}", c.r, c.g, c.b, c.a); | |
return lines; | |
} | |
} | |
``` |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment