Can you use plain 'ole C# objects as support code for another script

I'm not sure of the best way to word this question so I hope this comes out correctly. I currently have some logic on an app server (currently in Java) that we are accessing from within Unity via a C# script attached to one of our game objects. However, we would love to get rid of the need to use a servlet/the internet and just put all of the logic inside of Unity. But the Java objects (which we could convert to C#) would not be Unity C# scripts to be hooked onto a game object. Instead we would want to instantiate the C# objects from within an existing Unity C# script. I don't see a place to put plain C# objects nor a way to call them from a Unity C# script. So am I correct in assuming you cannot put that kind of logic code inside of Unity in that way?

Thanks for your help!

It is quite easy to add custom C# classes/structures/enums to Unity projects. Simply create the source as you would in any .NET project or Mono project, then do one of the following:

Option 1: Add your C# code to a folder in the Unity project.

Choose the folder based on this reference. (While it refers to "scripts", it applies to any source files.) The directory you choose effects the compile order, which determines which Unity scripts can use the new functionality.

Option 2: Compile your C# code as a .NET DLL and add the DLL to a folder in the Unity project. If any game code references the DLL, it will be included in the Unity build.

This is my favorite method for C# code that doesn't instantiate Unity objects.

Once you have added your C# files or DLL, you'll be able to reference them from any script.

As an example of the complexity of functionality you can add this way, I ported an entire Java multi-threaded pathfinding library to C# and am able to use it in Unity (both Free and Pro).

You can use regular C# objects. They can't be components, but you can put them as members inside of a component.