我通过将其附加到球体对象的脚本创建了一个 pin 对象。
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, 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()
{
}
}
此脚本附加到球体对象。我的球体对象具有地球图像(地球)的着色器材质。球体表面上的这个实例化预制件(gameObjectPin)出现在场景上但不在游戏屏幕上,当我在相机预览中选择相机对象时,这个对象也不会出现。
场景视图
选择相机时的场景视图
我是 Unity 的新手,我应该检查或更正什么以使我创建的对象出现在球体上基本上我正在尝试将引脚添加到相应的国家并标记它。类似于这个http://kitsdmcc.com/news上的地球
在球体对象上单击 Play 时创建游戏对象
在播放模式下选择 Pin Object 时