0
我Stone.cs定義的枚舉類型如何使用ENUM在
using UnityEngine;
using System.Collections;
public enum ColliderType { ColliderTypeSlowDown,ColliderTypeLoseControl };
public class Stone : MonoBehaviour {
public ColliderType colliderType;
void Start() {
}
void Update() {
}
}
,然後我想在PlayerControl.cs
void OnTriggerEnter(Collider obstacle)
{
if (obstacle.CompareTag("Stone"))
{
Stone stone = obstacle.gameObject.GetComponent();
if (stone.colliderType == ColloderTypeSlowDown) {
// code
}
else {
// code
}
}
}
使用它的另一個C#文件和它會引發一個錯誤:名稱'ColliderTypeSlowDown'在當前上下文中不存在。
我是一個客觀的C編碼器。我嘗試了很多次,但無法修復它。我應該如何解決這個問題?
包括命名空間:'用石;' –