Hey, this is just the sort of thing I'm interested in. I'm an experienced programmer who has no idea what I'm doing with Unity. Unity's tutorials are surprisingly great, but they tend to start with "okay, so a 'variable' is..." and I have to skip forward a bit and just want to know "okay, but say I already know how to program, what's the right way to program with Unity?" I've found very little on that topic, and unfortunately whatever stuff Unity has at that point seems to be behind crazy high pay walls and silly "certifications."
I find the best way to learn is by just building. You quickly run into questions, which can then be resolved one by one. But having said that, here's some tips. There's no single "right" way, but depending on your game idea you'll run into your own challenges and issues.
Learn what GameObject's and Components are and how they work. In Unity you have MonoBehaviour derived classes, but then you might also want some of your own non-Mono classes (for example an Entity-Character-Player/Civilian/Enemy inheritance structure).
For my code framework in Unity I create a GameObject in my scene that I call MainScripts. On this I'm going to attach all my generic Mono classes such as Game, MapList, AudioManager, UnitList etc. I call DontDestroyOnLoad on MainScripts so that it will last through all successive scenes.
Game is the main game class, I use its update to drive as many updates as I can (for performance reasons you want as few Unity Update methods running as possible). So for example inside of game's update I'm also calling my input's update, my own timers etc.
The next big problem is how does code in random class X access another class? For Mono classes you can go through the whole GameObject.Find/GetComponent in your Awake or Start methods and store them; BUT you might not have direct references to all your own code that doesn't inherit from MonoBehaviour.
For that I create a Static class. I'm going to place static references in here for everything global in my game, the previously mentioned MainScripts, Game, etc. As a random example, some Mono class might need to know if the control key is down. Since we're doing all input in our own input class we don't want to test through Unity again if control is down. Our input will already have a flag set, so then we just test something like if (Static.input.isAnyControlDown).
To setup Static we call our custom Static.Create from Mono Game.Start, which Unity will automatically call. Place Game very high (low #) in the Unity Script Execution Order so it will always be created first.
After that you have a code framework to hang everything off of. Hope it makes sense!
I think your first sentence is correct. And that maybe you should have stopped there. Spending ages trying to do things "the right way" instead of just hacking it together and actually learning is what makes it hard to get going. Basically making your own framework on top of Unity (as per your tips) is not the best way to start.
Little HN feature: if you click a comment's timestamp, you'll be able to "favorite" it. You can look at your (or anyone else's) favorites from the profile page.
I'm glad to hear! My series, starting with "Basic Concepts in Unity for Software Engineers" [0] is exactly designed for this and borne out of a frustration in much of the existing content.
Some folks in the replies mention just starting to code and while I totally agree, it was also helpful for me to understand... at least the concepts.
TBH when I started, the main way I did this was my finding a course on Udemy and watching it at 2x speed, still being bored out of my mind for huge chunks of it.
I've messed around with stuff and honestly? Unreal + Blueprints is a much nicer set of tools for experienced programmers I think.
It's visual programming, but it's easy to explore around, there's nice debugging interfaces, and the type inference stuff makes it so that you are presented with a lot of the engine details in a nicely digestible manner.
Unity it's like "OK make a bunch of C# classes and coroutines!" and it gets real messy real quick if you don't know what tools are available to you.
Thanks!