我有一个学校项目,我的同学正在制作有关邮局的VR游戏,您可以在其中简单地打包包裹并将其发送给公众。在我们的菜单中,我们印有与不同难度相对应的印章,当您在某个盒子上印章时,这些印章将设置等级。我已经编码,因此无论何时使用图章,它都会以相应的难度实例化文本。下面的代码:
public class Stampspawner : MonoBehaviour
{
public GameObject stampDifficultyPrefab;
public float timer;
private string stampDifficulty;
void Update()
{
timer -= Time.deltaTime;
}
void OnTriggerEnter(Collider other)
{
if (timer <= 0)
{
if (gameObject.name == "StampLower_StampLower")
{
stampDifficulty = "LÄTT";
}
else if (gameObject.name == "stamplower1_stamplower1")
{
stampDifficulty = "LAGOM";
}
else if (gameObject.name == "Teeth_Teeth")
{
stampDifficulty = "SVÅR";
}
stampDifficultyPrefab.GetComponent<TextMesh>().text =
stampDifficulty;
GameObject go = Instantiate(stampDifficultyPrefab,
transform.position,
Quaternion.identity, other.transform);
if (gameObject.name == "Teeth_Teeth")
{
go.transform.rotation = gameObject.transform.rotation *
Quaternion.Euler(90, 180, 270);
}
else if (gameObject.name == "StampLower_StampLower")
{
go.transform.rotation = gameObject.transform.rotation *
Quaternion.Euler(90, 270, 270);
}
else
{
go.transform.rotation = gameObject.transform.rotation *
Quaternion.Euler(90, 90, 270);
}
timer = 2f;
}
}
}
在这张照片上,我使用印章在桌子的边缘上盖章,从而使文本在桌子的一半内侧和一半外侧产生。