I am trying to use this code for NET.reflector using Reflexil. I am trying to replace code with this:
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; } }
}
But it gives me an error when I try to compile:
Line: 1 Column: 1 Error Number: CS0116 Error Message: "A namespace does not directly contain members such as fields or methods"
This is Unity code I think. I am not that experienced. Could anyone fix this for me? Or tell me what to do? Thanks!
A namespace cannot directly contain members such as fields or methods.
The namespace keyword is used to declare a scope that contains a set of related objects. You can use a namespace to organize code elements and to create globally unique types. C# Copy.
The snippet you're showing doesn't seem to be directly responsible for the error.
This is how you can CAUSE the error:
namespace MyNameSpace { int i; <-- THIS NEEDS TO BE INSIDE THE CLASS class MyClass { ... } }
If you don't immediately see what is "outside" the class, this may be due to misplaced or extra closing bracket(s) }
.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With