- Home /
Unity 5.6.0p3 does not recognize class inside namespace
This works:
using Zenject;
public class UiSignalInstaller : MonoInstaller
{
public override void InstallBindings()
{
Container.DeclareSignal<RoomSelectionChangedSignal>();
Container.Bind<RoomSelectionHandler>().AsSingle().NonLazy();
}
}
public class RoomSelectionChangedSignal : Signal { }
This does not:
namespace Zenject.Installers.UI
{
public class UiSignalInstaller : MonoInstaller<UiSignalInstaller>
{
public override void InstallBindings()
{
Container.DeclareSignal<RoomSelectionChangedSignal>();
Container.Bind<RoomSelectionHandler>().AsSingle().NonLazy();
}
}
public class RoomSelectionChangedSignal : Signal<int, RoomSelectionChangedSignal> { }
}
The library Zenject is placed under Plugins if this matters. I don't get a specific error warning, just "fix compiler issues" which is very unspecific. The only reason I found the solution is by trial-and-error.
I just realized there are tons of cases where the compiler is warning wrongly. Even if a variable is passed as parameter to a method. I am pretty sure this should not be the case.
Just a hunch, is it possible the scope of your namespace is just more restricted than before?
In your first example you have access to the whole Zenject namespace. In your second example it's restricted to Zenject.Installers.UI.. maybe you still need to keep the "using Zenject;" ?
Not near a computer to test at the moment, but you seem to have changed several things between the two code snippets - not just containing in a namespace:
The second example implements a generic interface -
$$anonymous$$onoInstaller<UiSignalInstaller>
rather than simply$$anonymous$$onoInstaller
.Also, you've changed the definition of
RoomSelectionChangedSignal : Signal { }
toRoomSelectionChangedSignal : Signal<int, RoomSelectionChangedSignal> { }
Not sure that these will explain the compilation errors, but it bothers my scientific tendencies to try to draw conclusions from a controlled experiment when you've varied more than one factor!
Arg... No. It is actually the same. The changed generics were swallowed by the unity editor before I had formatted the text as code correctly or during the copy-paste. I am going to load up the project and fix the two code examples above. Anyway: Good call!
Answer by eskivor · Jul 22, 2017 at 01:17 AM
try using Zenject.Installers.UI;
instead of just using Zenject;
Your answer
![](https://koobas.hobune.stream/wayback/20220612130814im_/https://answers.unity.com/themes/thub/images/avi.jpg)
Follow this Question
Related Questions
How do c# scripts get accessed by the Unity Engine 2 Answers
What we can achieve by putting MonoBehaviour inside namespaces? 1 Answer
UnityEngine found but MonoBehaviour or Vector3 not found in MonoDevelop 1 Answer
using UnityEditor outside of Editor folder when compiling build? 4 Answers
namespaces and script names 0 Answers