问题遇到的现象和发生背景
Assets\Scripts\DisplayLog.cs(7,12): error CS0246: The type or namespace name 'LogText' could not be found (are you missing a using directive or an assembly reference?)
问题相关代码,请勿粘贴截图
还原错误环境的demo,unity项目文件:
链接:https://pan.baidu.com/s/1M3CQSnWymv0d7tcnoyqIMQ
提取码:yrzf
public class LogText
{
public string log = "一个日志内容";
}
using UnityEngine;
public class DisplayLog : MonoBehaviour
{
public LogText LogText;
// Start is called before the first frame update
void Start()
{
LogText = new LogText();
Debug.Log(LogText.log);
}
}
运行结果及报错内容
Assets\Scripts\DisplayLog.cs(5,12): error CS0246: The type or namespace name 'LogText' could not be found (are you missing a using directive or an assembly reference?)
我的解答思路和尝试过的方法
我想要达到的结果
在不删除Scripts.asmdef,不能给LogText.cs 增加 .asmdef 程序集的情况下,让Scripts类可以引用到LogText 的内容,期望得到大家的帮助。
还原错误环境的demo,unity项目文件:
链接:https://pan.baidu.com/s/1M3CQSnWymv0d7tcnoyqIMQ
提取码:yrzf
请以该demo为错误场景帮忙解决问题,并贴出解决问题后的代码。
万分感谢