- I want to stick my interface in a separate scene. This is contraindicated by EngiGames for small games, but for my RPG, I think it makes sense to have it be its own thing that sits over the top of everything else going on.
if (SceneManager.GetSceneByName("UI").IsLoaded == false) SceneManager.LoadSceneAsync("UI", LoadSceneMode.Additive);
- Consider, instead, having the menu call
Don'tDestroyOnLoad()and then swapping immediately to a gameplay scene, rather than monkeying around with additive scenes, though.
- If I don’t want to hook up events to buttons using the Unity Button delegates, I can create scripts that handle the button directly. E.g.
// In Start(), using UnityEngine.UI...
button = GetComponent<Button>();
- Obviously, I’ll want to be able to grab an instance of some access point to my menu from any other scene. I should be aware that just putting a reference in a public static field in
Awake()is considered a Very Bad Plan. This is because it is a sloppy singleton that doesn’t do the first part of a singleton’s job — ensure that one, and only one instance of the class exists. This video details a singleton generic that will allow you to turn a Monobehavior into a proper singleton merely by inheriting from it.
The contentions of this video are twofold:
- Choosing a theme is superior to making a resolution. This is because when presented with a fork in the road, it is easier to choose the branch in keeping with your theme than it is to force yourself to take the branch you resolved to take, whether it is there or not.
- Consider instead of choosing a theme for a year (or a resolution for a year) choosing a theme for a season. E.g. instead of “I will do 30 pushups a day”, prefer, “this will be the Winter of pushups!” or better yet “the winter of Health!”
I take a definite interest in self-improvement as I fall short on a number of fronts. Fortunate man I, Christ has suffered and died for my many evils. But I still want to better myself for a number of reasons. First of them is: it is good to be good. But more importantly, the better a man I am, the better it is for those I claim to love.
My habit has been making monthly goals, not yearly resolutions nor seasonal themes. And the system has been fruitful, but not as fruitful as I think is possible. I don’t know whether “seasonal themes” is the answer. Right now, I have taken ill and am preparing for sleep, and lack the mental firepower to usefully analyze it. But I have a notion it is more in tune with my natural rhythms, simply because my one-month projects always manage to expand to 3 months. And I wanted to note it down so I can look into it tomorrow, or whenever I am awake and my mind is clear.
So you want a field in you Inspector that has sub fields. Its sole purpose is to just be a bucket of data, but you have no real need to share it between classes in Unity or have it be universal in any way.
Sounds like a good use for the C# struct, right?
Nah. Unity doesn’t roll that way. You want a plain old class. No inheriting from
ScriptableObject. Just decorate that bad boy with
Wait, Unity’s default code files don’t
include System? I suppose I can see why, as I haven’t noticed ’til now, but years of working with XNA/Monogame led me to not see that coming…
Do consider, however, whether a
ScriptableObject might not be right for you.
One of the reasons I hate, hate, hate Unity is that all the best documentation is Youtube videos, and I want a book.
Here’s the Brackey’s Scriptable Object tutorial, followed by my transforming the bits I care about into text, for future reference.
Righteo, let’s go:Continue reading “Scriptable Objects”
I hate video as a format. I like text because I can read much faster than people can talk (and even speeding up a video, as I often do, I read much faster than I can listen). I like text because I can skip forward and back with ease. And so on and so forth.
Here’s a video I find inspiring and useful.
And now I’m going to textify it for my convenience, then follow it up with some thoughts.Textify me, cap’n!
When using Unity to make 2D Platformers.
- A Box Collider2D can get the rounding advantages of a capsule collider via the edge radius attribute.
- A Tilemap Collider2D will treat each tile as an individual collider unless you check “Used by Composite”, which has performance pitfalls and can get you caught on corners. Adding the requisite composite collider automatically adds a rigidbody, so be sure to set that to static.
- Be sure to set static components (such as large swaths of your map) to static, to enable various optimizations.
- Be sure to set your player character’s collision to Continuous and interpolation to Interpolate so you don’t have to deal with the Bullet problem.
- If you want to use Physics2D.Raycast for sensors, and your plan is to start the raycast inside the character’s collider, be sure to deselect “Queries start in colliders” in the Project Settings.
- Unity doesn’t play nicely with C# events. If you want a public event that multiple entities can subscribe to, look up Unity Events. If you just want one component to broadcast an event to fellow components, it’s easier to just wire them up by hand.