What I want to do is forbidding SomeRandom class accessing Protected class
public class CertainClass {
public void CerFunc(){
ProtectedClass.ProtectedFunction();
}
}
public class ProtectedClass {
public static void ProtectedFunction(){
Debug.Log("Protected");
}
}
public class SomeRandomClass {
public void RandFunc(){
ProtectedClass.ProtectedFunction(); // innaccessible due to protection level
}
}
what do I have to change in order to make that work?
Preferably Static, because I need and want it only 1.
Make it private nested class of CertainClass:
UPDATE
If you want another
CertainClass2
to access yourProtectedClass
members -Either make
CertainClass2
as public nested class ofCertainClass
.OR
I would suggest to move
ProtectedClass
and other classes which want to access it into another assembly and makeProtectedClass
asinternal
so that all classes in that assembly can have access to this class and it is invisible to other classes outside this assembly.