Pergunta

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.

Foi útil?

Solução

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.

Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top