Created
May 25, 2020 23:16
-
-
Save dbechrd/021aef68b1e4fc3279ed7b651b0c5754 to your computer and use it in GitHub Desktop.
This file contains 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
// 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