using System.Collections;
using System.Collections.Generic;
using UnityEditor;
using UnityEngine;
public class GetPrefabs : Editor
{
public GameObject[] prefabs;
// Start is called before the first frame update
void Start()
{
prefabs = (GameObject[])Resources.LoadAll("Assets/Test/Animations/");
}
// Update is called once per frame
void Update()
{
prefabs = (GameObject[])Resources.LoadAll("Assets/Test/Animations/");
}
}
首先,我尝试将脚本放入Assets / Test / Editor中,但没有用,然后我将脚本移至Assets / Editor,但它不起作用,或者永远无法到达我在脚本中的断点。更新或在开始中。
答案 0 :(得分:1)
GetPrefabs源自编辑器。 Start()和Update()是MonoBehaviour方法(即,如果您从MonoBehaviour派生,则Unity将寻找它们)。您应查看Editor类的Unity文档,并从其列表中选择适当的方法-https://docs.unity3d.com/ScriptReference/Editor.html