Skip to content

Instantly share code, notes, and snippets.

@ByronMayne
Created June 13, 2017 03:41
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ByronMayne/1c481cc004b0a57f39dc3bdf09f775db to your computer and use it in GitHub Desktop.
Save ByronMayne/1c481cc004b0a57f39dc3bdf09f775db to your computer and use it in GitHub Desktop.
The code from your Unity tip from 6/13/2017
using UnityEngine;
using System.Collections;
using UnityEditor;
[CustomEditor(typeof(DefaultAsset), editorForChildClasses: true, isFallback = false)]
public class FolderInspector : Editor
{
private int m_ContentCount;
private GUIStyle m_TitleStyle;
private GUIStyle m_ListStyle;
public void OnEnable()
{
// Get our path
string assetPath = AssetDatabase.GetAssetPath(target);
// Find the assets inside
string[] assetGUIDs = AssetDatabase.FindAssets("", new[] { assetPath });
// Save our count
m_ContentCount = assetGUIDs.Length;
}
public override void OnInspectorGUI()
{
if(m_TitleStyle == null)
{
m_TitleStyle = new GUIStyle(EditorStyles.boldLabel);
m_TitleStyle.fontSize = 20;
m_ListStyle = new GUIStyle(GUI.skin.label);
m_ListStyle.fontSize = 20;
}
GUI.enabled = true;
GUILayout.Label("Super Folder ( ͡° ͜ʖ ͡°)", m_TitleStyle);
if (targets.Length > 1)
{
GUILayout.Label("Content Count: Does not Support Multi Selecting");
}
else
{
GUILayout.Label("Folder Facts", m_ListStyle);
GUILayout.Label(" 1) Content Count: " + m_ContentCount.ToString(), m_ListStyle);
GUILayout.Label(" 2) Is a Folder: true", m_ListStyle);
GUILayout.Label(" 3) Is having a good day: true", m_ListStyle);
GUILayout.Label(" 4) Is impressed by #UnityTips: true", m_ListStyle);
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment