Code Control is a framework written in C#, specially designed to create an easy to understand workflow for creating games in Unity using the MVC design pattern.
Buy now
Code Monitoring
Coming with three insightful ways to monitor what’s happening in code while running the game. Including message visualization and a basic UML of data structures, all clickable to open associated code files, making it much easier for new programmers to hop in on your project and understand the code.
Smart Serialization
Data models can be saved effortless while having references to each other. The big problem with normal serialization is referencing. In normal serialization, having multiple references to the same model creates a separate serialized model for each reference. At deserialization this results in a new model for each reference, while at serialization it was only one. Code Control solves this problem using its ModelRef class.
Global Messaging
Controllers do not have a reference to each other to make sure they are not tightly coupled. Code Control’s global messaging system avoids direct dependencies and keeps the code easy to change. The big issue with global messaging though, is losing sight of what classes are messaging each other. But luckily, that’s where Code Control’s Message Flow monitor comes in!
Code Monitors Demo Video
Released!
Code Control is now for sale on the Asset Store! Get your hands on this framework’s full source code today, and gain access to all of its features!
Additional Links
Product Website: http://unitycodecontrol.com/
Tutorials: http://unitycodecontrol.com/tutorials/
Documentation: http://unitycodecontrol.com/documentation/
Demo: http://unitycodecontrol.com/demo/
Reddit Support Thread: Reddit - Dive into anything
3 Likes
Code Control has been accepted by the admins of the asset store!! Wohoo! Make sure you check it out!
Hi Joris,
First of all, thank you for the framework, looks very promising.
I have two questions about saving/loading models on a remote server. In the tutorial http://unitycodecontrol.com/saving-and-loading-models/ at the ModelBlobs section you mention the dataString which is generated by the ModelBlobs object. How would such a string look like?
And, what is a best practice saving these data strings to a database? Using HTTP POST methods? And/Or using an ORM on the backend? So, how would you save the data coming from your system to a database?
Can you provide an example of this?
Thanks,
Cetin
Hi Cetin! Thanks for your comment 
Answer to question #1: The string coming from the ModelBlobs actually contains multiple xml files, separated using a special char or a custom string. The default separator char is the ~, so a very simple example of a ModelBlobs.ToString() output would be:
“0~1”
Here the xml’s are separated/joined using the default ~ char. Using this data string in the ModelBlobs.FromString(str) method will result back into ModelBlobs with that data. Do note that if you store string data inside your models that may include the ~ char, we advice you to use a custom separator. For example: ModelBlobs.ToString(“CustomSeparator”) and ModelBlobs.FromString(str, “CustomSeparator”).
Answer to question #2: Saving these strings to your database is entirely up to you… they’re nothing more than strings after all. I suggest to indeed use the HTTP POST methods, and to save them in a (sql) database so they can be easily loaded. Of course, when dealing with large tables, it might be more optimized to store the strings in a separate txt file on your web server instead of directly in the database.
I hope this answers your questions! Let me know!
Hi!
Thanks for your extensive and clear answer. .
Are you planning to also do an export to JSON (ModelBlobs or loose models to JSON)? We have a back-end that accepts JSON which is ready to use for my game. So this would be very convenient.
Thanks again 
Hey again ^^ Code Control will not be supporting JSON serialization in the near future as it is not supported in native C# in the way XML is, but you could still use JSON for the backend responses! Just use XML for the game’s model data strings 
Code Control 1.2 has just released! As of now, we are completely Unity 5 compatible!
For the next 24 hours the Code Control framework will be 50% off in the Asset Store’s 24 hour sale http://u3d.as/bRG ! Really curious to your opinions!
Hey, this is awesome. Keeping a maintainable code base in Unity has always been a problem for me. I purchased and looked at the demo code base and the framework and I like what I see. I’ll give it a go in my next game jam game or prototype.
Any thoughts on a unit testing example or, integration with an IoC container?
Hey Musicm122! Thanks for buying Code Control 
About your feedback, I really try the keep the framework as lightweight and simple as possible. I think unit testing could easily be a separate (existing) asset, which could contain tests including functionality of Code Control. In my experience, Inversion of Control requires a big change in architecture and way of programming which a lot of programmers are not willing to make.
Thanks again for your feedback and purchase of Code Control!
Hey,
I’m tempted to purchase Code Control during the current sale. I have worked through the Tutorial and an “issue” has arrived for me. Namely that messages are handled via strings. I want to suggest that you use an enum instead. This offers the following advantages:
- intellisense offers you all messages available.
- no missspelling of messages, compiler ensures that they all exist. with strings you have to remember/copy each message.
- enumeration / switch of all possible messages fe for initialization, list them etc.
- all defined in a single place for easy addition, removal, renaming etc.
- utilize refactoring tools when renaming a message fe. having to look up strings all over the place is error prone.
- enums should be faster than strings and include no allocation (value type). be sure to use a default comparer though.
So basically by using enums instead of string for the message definition you gain support from your IDE/compiler and you avoid some potential bugs/errors what is very hard using strings.
I’m interested to hear your thoughts about that. Most messaging systems I have seen use strings and I think this is “bad” design when you rely on them. I have adapted a basic messaging system from the wiki using enums and I’m very happy with it. I think this is exactly what enums are intended for.
Hi Exiguous, thank you for taking the time to write your post!
I’ve considered using enums, but I got stuck on the part of extending the enum outside of the framework. I want the framework’s code to be fully separated from implementation so I can update classes freely without users loosing their code. Giving the Message.Send a dependency on an enum would require that enum to be declared within the framework, and being that enums cannot be “sub-enumed” or declared as partial this would not get us very far.
The only real solution I found was to add a Send, AddListener and RemoveListener variant which requires you to define the used enum type. That would initially create an ambiguous call error as it would have the same structure as the Send(T message) method, so one of those would evidently need to get a different method name. The Send methods could look like the following:
Message.Send(string messageName);
Message.Send(MyEnum.MessageOne);
Message.SendTyped(new MyMessage());
Is this something that you would likely use in your code?
Thanks again for your feedback!
Hi,
Does the system require any extra coding in scripts to function or works with any script. Also does it work if scripts are in DLLs ?
Thanks
Hi Nasos, thanks for replying on this thread!
The package does not need any extra coding to make it run… but you’ll need to use Code Control’s Messaging system to make the Code Monitors do their thing of course.
I’ve made dll’s of the source code and those run just fine!
Let me know if you got any more questions!
Hi. I am very interested in Code Control. I just watched the demo video and I am wondering how well the Code Monitor works with complicated projects and with opening files in MonoDevelop instead of VisualStudio?
Also I am posting this in the reddit thread but in the future would you rather have support questions posted here or in the reddit tread?
On the enum issue – there’s no reason you cannot have intellisense with a string:
public static class MyMessageTypes
{
public static const Bark = “Bark”;
public static const Growl = “Growl;”
}
Then:
Messages.Send(MyMessageTypes.Bark);
The advantage to a string here is mods – if you use an enum, you have to define all the possible values up front. If you use a string, you don’t. Using the constants should be very nearly as fast (you’d have to test it) as using int or enum. Strings in C# are immutable – using the constant means it should be a simple pointer compare.
That gets you intellisense without losing the flexibility of adding new messages in mods or DLC. If you modify the enum in DLC, you might have to repatch your entire game to add the new message types. That’s architectural, and can be managed, but it’s potentially a good reason to use strings.
I can just say that using your string method is a nogo for me ;). So probably I would have to adapt it to my method manually what makes updating difficult.
I don’t see a problem here. You define an empty enum for the messages and put it in a file named differently (MessageEnum_rename.cs) so it is not overwritten. When the user first installs your package he shall remove “_rename” from the filename and fill in his enum values. When the user updates your package he shall simply delete your empty file or exclude it from import right away. This way usercontent is not overwritten during update and you even get compiler warnings when the type exists twice. Its a bit unusual but I don’t consider this inconvenient.
Why that? You can add enum values as you see fit. You could theoretically even change the order or rename the values (globally). I don’t see any issues here. If you forget it in a switch fe you even get a warning.
Your method adresses most of my listed points but not enumeration. In my messager for example I enumerate all enum values and create a delegate for each at startup. So I don’t have to check at runtime if it is there already. And since enum can be cast to int it can be used to index a list/array instead of a dictionary.
Anyway, thanks for the discussion. Its very interesting for me. The “issue” of updating is one I usually don’t have to care about in my own projects. But I’m eager to learn ;).
Thanks for the feedback guys!
I’ve implemented a mini-map in the Code Monitors that can be used when projects get more complicated. Of course, if you have a lot of events and/or model types it would help to have a second (actual) monitor to put the Code Monitors on full screen.
I’ve not explicitly tested the file opening on MonoDevelop, but I’m not using methods that specifically reference Visual Studio. It should work with any selected API from Unity’s preferences.
I think it’s more convenient to have all the posts in this thread… but I’ll keep the reddit thread alive just in case someone wants to post something there!
I do feel that this requires a bit too much of manual labor, and I hope to keep Code Control as user friendly and out of the box as possible. I think the Send method will evidently require you to define the used enum to keep things simple. Would that be something that you would be willing to use?
Thanks again guys! Really excited to see these discussions going on 