Attempt #1 - Day: 2.
PART 2: Testing.
As I planed in Part 1, I have done the following:
1-Created the application using Unity.
2-Renamed and Used the Main menu scene since it has everything already.
3-Removed everything from the scene and kept the Server creation UI.
4-Dragged the necessary scripts from other scenes to the Main menu scene.
5-Modified the scripts to create and connect the server right away.
6-Added more UI "Server Status UI".
7-Created a Backup project.
I'll talk about the last two points:
"6-Added more UI "Server Status UI"."
Since I have kept the server creation UI from the game, I had to do a couple of things such as; rearranging, remove buttons and add/merge UIs.
Originally when you click on create, it checks if you're trying to create a Survival mode server, if that's the case it'll ask if you want to load a previous save on that server or if you want to start new. Once you choose which option, the game will enable the Loading UI and change scenes.
That had to be changed. What I have done is added a small window"Server Status UI" that displays the status (Online, server name, number of players, etc...)
So instead of Enabling the Loading UI and changing scenes it'll close the option UI and enable the Server status UI window. It'll also dim and block the server creation menu.
In the Server status UI I have added a button "Quit" it'll simply Reload the same scene and that will reset everything.
"Quit" is abit confusing/misleading and I'll try to change it to something like "Stop server"
As for quitting the application, a quit button is unnecessary to have because the app will always be in-window mode (Not full-screen) which means it'll have the small 'x' button.
As for the second point "7-Created a Backup project.":
I have tested the game and as expected got a lot of errors such as null references and functions that are not being called.
After fixing all the errors and connect everything to each other, I managed to create the server and make everything work normally, however I was faced with two issues:
1-NPC (Merchant) getting errors because it cant find the way-points, since I got the code from the other scene without the game objects, it started to look for them when the server starts.
Since the merchent is looking for fixed locations in the map through game object's transforms, what we can do is create an Array of Vector 3 and have that be the source instead.
Unfortunately since I depend on the merchant to walk using the Unity Nav mesh, which I no longer have in my scene, there is no way for me to know at what time did he reach the targeted location so I can update everyone in the server. So I decided to not have the NPC spawn but have the marketing stand at his house enabled for anyone who wants to trade. Not the best solution but it's not a big deal and I'd rather focus on other things so I might come back to this later.
2-When creating the server using the app, it always considers the app as a player that joined the server even though I don't spawn a player. In other words it always shows 1/10 when the server is empty.
A have thought of a few solutions but all are ugly ones so I decided to come back to it later.
Going back to the point, since I have everything working with no errors I have tested it, thankfully it starts and loads and quits no issues, the app size however is an issue since I haven't optimized it, at this stage its just a game without a camera, not a server app. So I need to start delete everything that I don't use (Animations, sounds, meshes, textures, etc...)
As I mentioned in Part 1, deleting some of these files might cause for an error that results in disconnecting the server. Which means I have to be extremely careful not the remove something that the server needs or even might look for at some point...
I have created a backup to able to re-try if I ruined something (Most likely will do).
SO this is what i'll try to do next:
1-Reduce the size of the project and app as MUCH as possible by deleting and removing unused files.
2-Improve the app performance by modifying the scripts and removing functions that don't really affect the app.