programing

Net.Reflector의 "네임 스페이스는 필드 또는 메서드와 같은 멤버를 직접 포함 할 수 없습니다."

randomtip 2021. 1. 14. 08:12
반응형

Net.Reflector의 "네임 스페이스는 필드 또는 메서드와 같은 멤버를 직접 포함 할 수 없습니다."


NET.reflector에이 코드를 사용하려고합니다. Reflexil을 사용하여 코드를 이것으로 바꾸려고합니다.

if(Input.GetKeyDown(KeyCode.Keypad5)) { 
int i = 0; 
Character localPlayer = PlayerClient.GetLocalPlayer().controllable.GetComponent<Character>(); 
foreach (UnityEngine.Object obj2 in UnityEngine.Object.FindObjectsOfType(typeof(LootableObject))) 
{ 
    if (obj2 != null) 
    { 
        i++; 
        LootableObject loot = (LootableObject) obj2; 
        Debug.Log("Loot "+i+": "+loot.transform.position.ToString()); 
        CCMotor ccmotor = localPlayer.ccmotor; 
        if(ccmotor != null && tpPos1 != Vector3.zero) { 
            ccmotor.Teleport(loot.transform.position); 
            Notice.Popup("", "Teleported to "+loot.name, 1.5f); 
        } 
        break; 
    } 
} 

}

그러나 컴파일하려고 할 때 오류가 발생합니다.

Line: 1 Column: 1 Error Number: CS0116  Error Message: "A namespace does not directly contain members such as fields or methods"

이것은 내가 생각하는 Unity 코드입니다. 나는 그렇게 경험이 없습니다. 누구든지 나를 위해 이것을 고칠 수 있습니까? 아니면 어떻게해야하는지 알려주세요? 감사.


보여 주신 스 니펫이 오류의 직접적인 원인이 아닌 것 같습니다.

다음은 오류를 일으키는 방법입니다.

namespace MyNameSpace
{
   int i; <-- THIS NEEDS TO BE INSIDE THE CLASS

   class MyClass
   {
      ...
   }
}

클래스 "외부"가 무엇인지 즉시 확인하지 못한다면 잘못 배치되었거나 추가 닫는 괄호 때문일 수 있습니다 }.

참조 URL : https://stackoverflow.com/questions/21175781/a-namespace-cannot-directly-contain-members-such-as-fields-or-methods-in-net-r

반응형