【发布时间】:2019-11-13 09:06:10
【问题描述】:
我通过将其附加到球体对象的脚本创建了一个 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 对象时
【问题讨论】:
-
你能添加一个选择了图钉的截图吗?
-
@Camile 我添加了,我能知道为什么它没有出现在游戏屏幕上吗?我为此坐了两天。请帮助提前谢谢
-
看起来您的对象只是一个空变换?您在编辑器中看到的图钉的图形图像可能实际上是 Canvas 中的一个对象(尝试扩展它),而不是您选择的游戏对象。