Tag: C#

Few design patterns you should know about

Singleton – duh. Object pooling https://youtu.be/9-zDOJllPZ8 Service Locator https://msdn.microsoft.com/en-us/library/ff648968.aspx Publish–subscribe pattern https://www.romanluks.eu/nezarazene/great-explanation-of-events-and-delegates-in-c/ more patterns here http://gameprogrammingpatterns.com/ Do you have favorite patterns? Let me know in the comments 🙂

Tagged with: , ,

Add headings in Inspector to make debugging in Unity easier

Following code turns in Unity into… Btw see how you can use empty string “” for header to create empty space between values.

Tagged with: ,

Renaming multipe gameobjects in Unity

Or so called batch renaming I have found this script . It works. However objects are taken from Selection which does not guarantee same order as in hierarchy. I have tweaked it a bit, added sorting by sibling index and it

Tagged with: ,

How to implement simple Publisher/Subscriber pattern in Unity C#

Here is publisher using System; … public event EventHandler RailsEnabled; void EnableRails() { if (RailsEnabled != null) RailsEnabled(this, EventArgs.Empty); } Here is subscriber void Start () { Launcher.RailsEnabled += OnRailsEnabled; } private void OnRailsEnabled(object sender, EventArgs e) { RailsEnabled =

Tagged with: , ,

Method chaining is cool!

var jack = new Person().SetName(“Jack”)                                            .SetAge(30)                          

Tagged with: ,

AR Flashcards (ANKI in AR) prototype in ARToolkit

Project in ARToolkit for my Augmented Reality Interfaces course

Tagged with: , , , , ,

Great explanation of Events and Delegates in C#

Tagged with: , ,

How to autolaunch KeePass

I made a simple C# console app which launches KeePass on startup and automatically opens specified database. Location of DB file and password must be specified in config file. The config file is encrypted on first launch. Tested with: KeePass

Tagged with: , , , ,

Random enum in C#

Array values = Enum.GetValues(typeof(AttackType)); Random random = new Random(); AttackType randomAttackType = (AttackType)values.GetValue(random.Next(values.Length));  

Tagged with: