Version: 2021.3

MonoImporter.GetAllRuntimeMonoScripts

切换到手册
public static MonoScript[] GetAllRuntimeMonoScripts ();

返回

MonoScript[] Returns an array of scripts.

描述

Gets an array of scripts that will be available at runtime.

using UnityEngine;
using UnityEditor;

class Example { [MenuItem("Examples/Get Scripts Available at Runtime")] public static void GetScriptsAvailableAtRuntime() { foreach (var monoScript in MonoImporter.GetAllRuntimeMonoScripts()) { Debug.Log($"Class: {monoScript.GetClass()}, Name: {monoScript.name}"); } } }