How to import my own C# Classes into another C# Script?

Hello friends

Do you know how to import another class into another class.
Let say for instance I have a class name “Colors.cs” located in “Assets/Scripts/CSharp/Colors.cs”
I would like to import this simple class into another class (ColorTest.cs)
At first I did this

"using Asset.Scripts.CSharp.Colors;"

It gives me this error

But it does not work

Could any one help me please how to import a C# class into another C# class in Unity 3D.
Thank you and God Bless

2 Likes

C# path has nothing to with Unity path. So you don’t to add any “using…” stuff. All classes are accessible as long as you are placing them under unity’s asset folder.

2 Likes

Thanks for clearing things up
But now I have a warning when I do this

The warning is

Hi!
your Colors class should NOT extend Monobehaviour, unless you want to stick the class to a gameobject.

Kind of what the warning says :wink:

3 Likes

@Svenskefan

wowww it works without any warning!!!
Halleluja!!

Thanks Svenskefan.
=D