I have almost 2 months of Experience with Unity3D as well as C#.
I can create simple games in Unity with some reference.
Now as I am moving forward to ship one of my game which i have made. i encountered various problems related to management and stuffs like saving game score, loading scene, making a setting page, re factoring my spaghetti code .
Meanwhile i encountered ‘StrangeIoC’ and looks like this is the solution to most of my problems but as soon as i saw the plugin
O_O
I can not make sense of any of these things, even after watching some tutorials i have no idea from where i should start
If you guys could explain step by step what to do, or happen to have a simple example with you then please help me out here.
I dont have Any idea thats why i dont have things which i can show and say that I tried this.
I am lost here
is there any simple way to create a game manager ? ( btw i would prefer StrangeIoC )
But how did you conclude that it’s going to solve your problems if you are unable to understand what it does?
StrangeIoC (or any Inversion of Control library) won’t make bugs go away. It will allow you to structure (or restructure) your code in a way that, hopefully, will be more resilient to changing requirements. Or, in plainer terms, it will allow you to change certain parts of your program without having to also modify other parts that depend on them.
If you can’t make head or tails out of StrangeIoC at this point, then you’re not ready for it yet. Take some time to learn about polymorphism and interfaces (here’s a good Stack Overflow question on the topic). Try to think of where interfaces would benefit your program and implement them. Then IoC might start making more sense.
i want to restructure and re-factor my code because right now its a mess and i cant add new features but to write new script which basically does the same things.
and I keep on changing my logic and whole architecture of game that’s why i need some base where i can put my game code .
I really don’t get those frameworks. So they make your code flexible and more resilient to future changes by adding complexity and solving problems in relatively higher level of sophistication than what the problem actually requires. An overkill. No thanks, I’ll pass.
IMHO most of what we learn in business application programming (even some of the general programming principles) isn’t applicable in game programming, it’s all good in “theory” but when it comes to practice, you’ll end up with a an over-engineered highly complex design that will quickly fall a part as you start adding more features to your game (thus more complexity) - in my experience, what really matters is “simplicity” - go with the simplest solution you can possibly find. Usually, it goes like this: Simple → means more robust → means less bugs. No need to "object"ify everything, do you really need your code to sacredly meet SOLID? are you sure you need the extra flexibility the O gives? maybe you do, if you’re writing a framework. But maybe you don’t, maybe you know exactly what your game needs and don’t need extra flexibility. you’d be surprised how powerful enums combined with switch statements are. I find 85% solutions to be more beneficial to 100%. KISS, all the way. Forget about IoC.Don’t let the rules rule you, you rule them!
If you could give us more info on what exactly you’re trying to solve we could give you better help. Good luck!
If you can’t make sense of it then you are not ready for it. IOC is a relatively complicated technique. If you can’t write good code without it you will make worse code with it.
@vexe This is by far most beautiful response I have ever seen. Thank you so much. You have really helped me with this problem. i am unnecessarily complicating things.
I agree with you BoredMormon.
So I disagree with the notion that StrangeIOC unnecessarily complicates things as I have been using it successfully for 6 months and it’s the backbone of my entire app. It allows me to add or remove functionality with ease and without disturbing other parts of the app. That being said, my app/game is all UI so I can’t speak to how great it is for game loops BUT it’s great for all of your UI needs. The others are right, in that it’s kind of complicated at first, but once you understand what dependency injection is and how to use it wisely, it actually makes your code LESS COMPLICATED then creating an engine/system where classes heavily depend on each other and are wired together. Also I use it with signals so you get compile time errors when you are passing wrong types around as opposed to events that are string based and a pain to debug. I am going to give a talk on it in a Unity User Group in Chicago in the coming months and can post my slides and code samples to this or other places if you are interested.