[英]Unity3D: How to show mesh in scene?
I've c# class: 我有C#课:
class VisualElement {
private GameObject mesh {get; set;};
public VisualElement(){
mesh = Gameobject.find("Models/VE");
}
public void showMesh(GameObject player){
//TODO show mesh
}
}
What I need to do to have my element displayed on the scene? 我需要做些什么才能在场景中显示我的元素?
I can get from the player the position where I want to place the mesh object. 我可以从播放器中获取要放置网格物体的位置。
It's in the manual . 在手册中 。 Also, GameObject.Find is for finding GameObjects that are already in the scene.
此外, GameObject.Find用于查找场景中已经存在的GameObject。 If you want to load an asset from file, use Resources.Load .
如果要从文件加载资产,请使用Resources.Load 。
On the other hand, I'm 90% sure you do not need this class at all. 另一方面,我90%肯定您根本不需要此课程。 Each time you would create a
VisualElement
, just instantiate a GameObject and Unity will do all the work for you. 每次创建
VisualElement
,只需实例化一个GameObject ,Unity就会为您完成所有工作。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.