0

私はC#クラスを持っています:

class VisualElement { 
   private GameObject mesh {get; set;};
   public VisualElement(){
      mesh = Gameobject.find("Models/VE");
   }  
   public void showMesh(GameObject player){
      //TODO show mesh
   }
}

要素をシーンに表示するにはどうすればよいですか?

メッシュ オブジェクトを配置したい位置をプレイヤーから取得できます。

4

1 に答える 1

1

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.

于 2013-06-24T06:48:14.093 に答える