I've got a whole lot of scripts, none of them so far use namespaces. But as I get more and more scripts to deal with I thought it would be a wise idea to start using namespaces. I've never used them before so I'm having a little bit of difficulty. I've declared the namespace in one of my scripts:
using UnityEngine;
using System.Collections;
namespace Train.OnBoardChecker {
public class OnBoardChecker : MonoBehaviour {
[SerializeField]private bool isOnBoard;
public void OnTriggerEnter (Collider col) {
if(col.gameObject.tag == "Character"){
isOnBoard = true;
}
}
public void OnTriggerExit (Collider col) {
if(col.gameObject.tag == "Character"){
isOnBoard = false;
}
}
}
}
And in my main train script, I've tried to access the 'isOnBoard' bool from the OnBoardChecker script. I was told there were a few ways of doing this, this is what I did:
using UnityEngine;
using System.Collections;
using Train.OnBoardChecker;
namespace Train {
public class TrainSystems : MonoBehaviour {
void Start () {
}
void Update () {
}
}
}
I'm not sure if I'm misunderstanding the whole namespace thing, but I can't access my variables from that script. I've making the variable public, and private (with serialzefield). I've tried these, with the public and private variables, and I even tried making the voids public and not public:
(namespace onboard checker) > OnBoardChecker.OnBoardChecker.insertvariablenamehere
OnBoardChecker.varname
What am I doing wrong, how do I access my variables from the OnBoardChecker script in the TrainSystems script with the namespaces without having to make it public, kind of like the standard assets does.