I've c# class:

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. If you want to load an asset from file, use Resources.Load.

On the other hand, I'm 90% sure you do not need this class at all. Each time you would create a VisualElement, just instantiate a GameObject and Unity will do all the work for you.

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top