0
다른 Unity 구성 요소에서 사용자 지정 속성에 액세스하려면 어떻게합니까? 내 아바타 구성 요소에서Unity의 다른 구성 요소에서 사용자 지정 속성에 액세스하는 방법
나는 이런 식으로 변수를 선언 한 :
public var isInEndzone : boolean;
가 다른 구성 요소의 속성을 호출 :
//actor variable is the GameObject that has the Avatar component.
public var avatar : GameObject;
....
var avatarComponent : Avatar = avatar.GetComponent(Avatar);
if (avatarComponent.IsInEndzone){
//do something...
}
오류 :
GetComponent requires that the requested component 'Avatar' derives from MonoBehaviour or Component or is an interface.
UnityEngine.GameObject:GetComponent(Type)
BCE0019: 'IsInEndzone' is not a member of 'UnityEngine.Avatar'.
또는 이것을 진술에 추가하십시오. var avatarComponent : Avatar = avatar.gameObject.GetComponent (Avatar); – verbanicm
var로 변경했습니다. avatarComponent : Avatar = avatar.gameObject.GetComponent ("Avatar"); BCE0022 : 'UnityEngine.Component'를 'UnityEngine.Avatar'로 변환 할 수 없습니다. – joe
아바타 클래스를 게시 할 수 있습니까? 아바타 변수는 무엇입니까? – verbanicm