I know that certain namespaces are necessary to include to specify under what scope certain methods are found, and this also saves typing. Otherwise the error CS0246 is thrown if referencing an unknown type.
The problem is, that I am using a namespace in a script in:
Assets / Scripts
And that namespace is defined in a script in:
Editors / Data / AnotherFile
So I am getting an error CS0246.
How could I solve this without moving that script into the Assets / Scripts
location?
SCRIPT LOCATED IN EDITOR / DATA / ANOTHERFILE:
using System.Collections.Generic;
using UnityEngine;
using UnityEditor;
namespace NodeEditorWindow
{
[CreateAssetMenu]
public class LevelFlowData : BaseNodeEditorData<BaseLevelNode, LevelFlowEditorAttributes>
{
private const string MENU_ITEM_PATH = "Create / ScriptableObjects / LevelFlowData";
private const string NEW_ASSET_PATH = "ScriptableObjects / Level Flow Data";
[SerializeField] private string _name;
/// <summary>Gets and Sets name property.</summary>
public string name
{
get { return _name; }
set { _name = value; }
}
[MenuItem(MENU_ITEM_PATH)]
public static void CreateAsset()
{
LevelFlowData scriptableObject = ScriptableObject.CreateInstance<LevelFlowData>() as LevelFlowData;
AssetDatabase.CreateAsset(scriptableObject, AssetDatabase.GenerateUniqueAssetPath(NEW_ASSET_PATH));
}
}
}
SCRIPT LOCATED ON ASSETS / SCRIPTS / ...:
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
using GameData;
using NodeEditorWindow; //HERE I AM USINGTHE OTHER CLASS'S NAMESPACE
public class LevelController : Singleton<LevelController>
{
[Header("Level Data:")]
[SerializeField] private LevelFlowData levelFlowData;
}
These are the errors I get in console (both CS0246):
Assets/Scripts/Scene Controllers/LevelController.cs(6,7): error CS0246: The type or namespace name `NodeEditorWindow' could not be found. Are you missing an assembly reference?
Assets/Scripts/Scene Controllers/LevelController.cs(11,27): error CS0246: The type or namespace name `LevelFlowData' could not be found. Are you missing an assembly reference?
Sorry if this seems to be a repeated question, but I haven't found any solution to this error due to having scripts on different paths (but using the namespaces). Thanks in advance.