문제

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