我通过将销钉对象附加到球体对象上的脚本创建了该销钉对象。
using UnityEngine;
public class InstantiateMarkerPin : MonoBehaviour
{
public float Xpos;
public float Ypos;
public float Zpos;
public GameObject gameObjectPinInstantiate;
// Start is called before the first frame update
private void Start()
{
Xpos = 0.09f;
Ypos = 0.50f;
Zpos = 1.1f;
//The original object,where to instantiate,and the orientation of the new object
GameObject marker = (GameObject)Resources.Load("gameObjectPin");
Vector3 location = new Vector3(Xpos,Ypos,Zpos);
Quaternion rotation = Quaternion.Euler(0,0);
//The object the script is attached to
GameObject world = this.gameObject;
//Instantiate the prefab
gameObjectPinInstantiate = Instantiate(marker,location,rotation,world.transform);
Debug.Log("InstantiateMarkerPin class : Marker Location 2 :X,Y,Z : " + gameObjectPinInstantiate.transform.position);
}
// Update is called once per frame
private void Update()
{
}
}
此脚本附加到球体对象。我的球体对象具有地球图像(globe)的着色器材质。 球面上的此实例化预制件(gameObjectPin)出现在场景中,而不是出现在游戏屏幕上,当我在摄像机预览中选择摄像机对象时,该对象也不会出现。
场景视图
选择摄像机时的场景视图
我是Unity新手,应该检查或纠正将我创建的对象显示在球体上的内容 基本上,我正在尝试将销钉添加到相应的国家/地区并标记它。类似于此http://kitsdmcc.com/news
在球体对象上单击“播放”时,将创建游戏对象
在播放模式下选择“固定对象”时