Skip to content

Instantly share code, notes, and snippets.

@dbechrd
Created May 25, 2020 23:16
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 dbechrd/021aef68b1e4fc3279ed7b651b0c5754 to your computer and use it in GitHub Desktop.
Save dbechrd/021aef68b1e4fc3279ed7b651b0c5754 to your computer and use it in GitHub Desktop.
// Copyright 2020 - Dan Bechard
// https://github.com/dbechrd
// License: Public Domain
using System;
using System.Collections.Generic;
using System.Linq;
using UnityEngine;
// Lists all classes that inherit from Component in Unity's debug log
// Note: This uses C#'s run-time type introspection (i.e. "reflection"),
// and should not be called in any performance-sensitive context.
public class UnityComponentLister : MonoBehaviour
{
void Start()
{
// Queries fully qualified name of every class that inherits from UnityEngine.Component class
List<string> componentNames = AppDomain.CurrentDomain.GetAssemblies()
.SelectMany(t => t.GetTypes())
.Where(t => t.IsSubclassOf(typeof(Component)))
.Select(t => t.FullName)
.ToList();
// Alphabetize
componentNames.Sort();
// Write list to debug log
Debug.Log(String.Join("\n", componentNames));
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment