c# - Unity Class Instantiate C#
问题描述
Working on an assignment and this is one of the examples of code that I'm trying to work with in my code.
GameObject prefabRocks;
GameObject rocks = Instantiate(prefabRocks) as GameObject;
I get an error every time this code runs in Unity.
Error Is: UnassignedReferenceException: The variable prefabRocks of Class1 has not been assigned. You probably need to assign the prefabRocks variable of the Class1 script in the inspector.
Can someone help me understand what exactly this code does?
It would help if you can also point me to some reading I can do to understand this weird way of instantiating classes and methods.
解决方案
推荐阅读
- python - UnboundLocalError:分配前引用的局部变量“d”
- amazon-web-services - 如何订阅 cloudwatch 指标数据?
- javascript - 如何根据屏幕大小更改图像组件?
- c# - 数据源gridview c#
- google-apps-script - 在另一列的循环中查找与条件匹配的日期?
- javascript - 节点 child_process 等待结果
- android - 如何从回收站视图中滑动项目而不将其从屏幕上移除
- ruby-on-rails - Mongoid / Rails 每个请求的查询计数
- python - IPython 滚动问题与魔法('clear') | 蜘蛛侠
- ios - SwiftUI 并非所有字符串都已本地化