Assuming I have declare a Unity asset “HMD”, which contains 2 directories, “Scripts” and “Tests”.
(This project has been uploaded to https://github.com/hpvdt/HMD-Air/blob/d74eb803f933b6a13de33f89468bc70def1126c9/Assets/HMD/Tests/PickleSuite.cs, to demonstrate the error)
Under “Scripts” I have a class called “Pickle”:
namespace HMD.Scripts.Pickle
{
using YamlDotNet.Serialization;
using YamlDotNet.Serialization.NamingConventions;
public class Yaml
{
Under “Tests” I have a testing class called “PickeSuite”:
using NUnit.Framework;
namespace HMD.Tests
{
using Scripts.Pickle;
using Scripts.Streaming.VCap;
public class PickeSuite
{
// A Test behaves as an ordinary method
[Test]
public void PickeSuiteSimplePasses()
{
...
Upon compilation, it is reported that all namespaces under Scripts cannot be found:
1>PickleSuite.cs(5,11): Error CS0246 : The type or namespace name 'Scripts' could not be found (are you missing a using directive or an assembly reference?)
1>PickleSuite.cs(6,11): Error CS0246 : The type or namespace name 'Scripts' could not be found (are you missing a using directive or an assembly reference?)
what’s the cause of this? How to make the namespace visible?
UPDATE 1: I later opened an open-sourced example to fully understand the design of Unity testing framework:
https://github.com/nowsprinting/UnityTestExamples
When the project is fully loaded in the IDE I can immediately see the difference in namespace organisation: namely, C# compiler automatically recognise the following 4 directories under an asset as source root:
- Scripts/Editor
- Scripts/Runtime
- Tests/Editor
- Tests/Runtime
In this case, all namespaces under Scripts can work properly. How to reproduce it in any project with the exact same editor & IDE?
(I can’t find any option to do the same in my IDE)