c# - 为什么在编辑器类型脚本中它永远不会到达断点?
问题描述
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 但它不起作用,要么它永远不会到达我在 Update 或 in 中放置的断点开始。
解决方案
GetPrefabs 派生自编辑器。Start() 和 Update() 是 MonoBehaviour 方法(即,如果您从 MonoBehaviour 派生,Unity 会查找它们)。您应该查看编辑器类的 Unity 文档并从其列表中选择适当的方法 - https://docs.unity3d.com/ScriptReference/Editor.html
推荐阅读
- mongodb - 有没有办法使用 in Array 函数从 mongodb Collection 中获取数据。如果数组 id 是字符串
- django - 在详细视图中列出包含外键的模型
- spring-batch - Spring Batch 可以与 Amazon Redshift 一起使用吗?
- python - 在 Python 中从 SQL Server 解码拙劣的转义 unicode?
- mysql - 如何计算foreach循环的值?
- .htaccess - 使用 .htaccess 文件隐藏文件夹内文件的实际名称
- php - 有没有办法在事先不知道值的情况下用 php 更新 mysql 表?
- airflow - Airflow:SubDagOperator 的成功基于什么?
- mysql - MySQL:选择多个子查询的结果时,“子查询返回超过 1 行”
- node.js - 如何让 CucumberJS 在步骤定义中识别我的场景大纲参数?