Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
The source code behind my Unity tip.
using UnityEngine;
using System.Collections;
// This is not need but I just wanted to make the point clear.
public class AnimatedComponent : MonoBehaviour
using UnityEngine;
using UnityEditor;
using UnityEditor.AnimatedValues;
public class AnimatedEditor : Editor
private class Styles
public readonly GUIStyle lennyFaceStyle;
public readonly GUIStyle lennyTextStyle;
public readonly GUIStyle messageStyle;
public Styles()
lennyFaceStyle = new GUIStyle(EditorStyles.boldLabel);
lennyFaceStyle.fontSize = 40;
lennyFaceStyle.stretchWidth = false;
messageStyle = new GUIStyle(EditorStyles.boldLabel);
messageStyle.alignment = TextAnchor.MiddleLeft;
messageStyle.fontSize = 14;
private AnimBool m_FoldoutOpen;
private GUIContent m_LennyFace;
private GUIContent m_LennyText;
private Styles m_Styles;
public void OnEnable()
m_FoldoutOpen = new AnimBool(); = false; // Default to not open
m_LennyFace = new GUIContent("( ͡° ͜ʖ ͡°)");
m_LennyText = new GUIContent("oh hai");
public void OnDisable()
public override void OnInspectorGUI()
if (m_Styles == null)
m_Styles = new Styles();
// Target is where it's going to = EditorGUILayout.Toggle("Open",;
// Do our fade group
if (EditorGUILayout.BeginFadeGroup(m_FoldoutOpen.faded))
GUILayout.Label(m_LennyFace, m_Styles.lennyFaceStyle);
GUILayout.Label(m_LennyText, m_Styles.messageStyle);

This comment has been minimized.

Copy link
Owner Author

ByronMayne commented May 29, 2017


Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.