Say that a project needs to be created from scratch for later use in Unity, for scripts. What is the ideal way to setup this without using a template in Visual Studio?
Can this be created in C# with some simple classes and one or two game loops?
Say that a project needs to be created from scratch for later use in Unity, for scripts. What is the ideal way to setup this without using a template in Visual Studio?
Can this be created in C# with some simple classes and one or two game loops?
TLDR: Kinda but it's a lot of work for something that you will swap out in the future anyway.
I don't know that if you can get access to the unity namespaces and classes without using a template or starting a new project in unity (which essentially generates a template for you).
You could write a dummy class with the same methods that Unity uses. So a class called MonoBehaviour
then simply list the names of the classes that you need (Start, Update, Awake, etc.) so that when you copy the code to unity you don't have to rename and adjust every method you write. Problem is that you won't be able to test this as easily.
When you want to test this you would have to create a basic game loop manually calling all the standard methods in the correct order then repeating update until your done. in a similar way as bellow:
public class FakeGameLoop {
List<MonoBehaviour> scripts = new List<MonoBehaviour>();
public void Main(string[] args)
{
//add all the scripts here one by one
scripts.Add(new Thing());
scripts.Add(new OtherScript());
//etc, more scripts
//initialise the scripts
foreach (MonoBehaviour script in scripts)
{
script.Start();
}
//simulate the update cycle
while (true)
{
foreach (MonoBehaviour script in scripts)
{
script.Update();
}
}
}
}
The problem that you will face is that you need to implement more and more of unity the deeper you get into it and the more you want to use... If you want those scripts to talk to each other you have to make a basic version of the component system that unity has and implement the methods that you want to use.
If you want to just build systems that work around one script without needing any (or very little) unity specific stuff this will work ok as you test the script working on it's own. Once you are then done or ready you can move the code to unity and integrate it fully with other scripts