【发布时间】:2018-11-28 19:09:36
【问题描述】:
C# 和 Unity 的全新用户。请不要客气,我整晚都在这。我穷过的每个教程都说将对象从不可见更改为可见就像将游戏对象设置为打开一样简单。然而,当我在这个脚本中声明一个游戏对象时,Unity 给了我一个错误。目标是,当输入触发器时,几个名为“spawn”的游戏对象将变得可见。
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class collider : MonoBehaviour
{
public gameObject Spawn; // I get error On this line that type is expected,
//not property. It wants a Transform>
private Rigidbody rb;
void Start ()
{
rb = GetComponent<Rigidbody>();
}
void OnTriggerEnter(BoxCollider other)
{
if (other.gameObject.CompareTag("Player"))
{
Spawn.SetActive(true);
}
}
}
【问题讨论】:
-
请edit您的问题并附上它给您的错误文本。
标签: c# unity3d gameobject