简体   繁体   中英

Unity3D: How to show mesh in scene?

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM