Комментарии:
Please, fix this microphone
ОтветитьThere is a workaround for singletons, but if you are working on a team you must communicate how the system works. What you do is make your singleton base class abstract, add a protected abstract function called Initialize or OnAwake or whatever. Now also in the base Singleton class in the Awake function, after all the base class related code just call the Initialize function. So now all the child classes of the Singleton class require you to implement the Initialize function which is automatically called on the Awake function from your base class. Just make sure to never use the Awake function in your child classes. One step further would be to have a static function in your base class with the RuntimeInitializeOnLoadMethodAttribute attribute to automatically create an instance of your class when the scene loads.
ОтветитьSingletons are mid and Scriptable Objects are based
ОтветитьI really want to watch this video, but the changing volume makes it hard for me to listen and understand. I don't know, maybe it's easier for native English speakers. 🤔
Ответитьthank you
ОтветитьIf singletons are not great for global state management, what pattern would you recommend?
ОтветитьNeed a re-recording of this one day. The audio triggers my condition and I can't seem to make it sit right no matter what I do 😭
ОтветитьI use a static class called Conventions to hold all of the useful functions that I tend to use throughout my different objects.
ОтветитьHere is a problem I came across when using singleton pattern on my prefab.
I have 3 box (same prefab). each of them has one same script called changeColor (because it is prefab) ; I use singleton in this class like
if(isntance == null) { instance = this;} else{ destroy(gameObject)} . When game stars all of other boxes ( 2 boxes of 3 ) are disapppearing. I found the problem is when Instance in not null it destroys other boxes and keep only one box.
What should I do here.?
You should retract this video, it's poor software engineering and you don't "new a property".
ОтветитьSo the main two points i got from it:
1. Singleton makes stuff easier than:
GameObject.FindObjectOfType() on every manager my game has, instead i have just static instance of one object, and i can event prevent duplicates :D
2.
static field values on MonoBehaviour are the same for ALL monobehaviours of same type, you dont have to cycle through every one to set one specific global value. hmm TIL :D
TYVM for you hard work Jason! :D
English is not my first language. Your voice is unclear and loudness is not constant so I really had a hard time understanding your content!
ОтветитьA video on object oriented vs process oriented programming? A GDC talk by the dude that built Thumper argued for it but I cant get my head around the differences. I don't think I've ever built anything purely on functions without classes or objects
Ответитьmost of my scripts are singletons :S
Ответитьwhat's the VS code extension you used that gives the function arguments a label next to it? Like for example in the beginning of the video, you have Vector3.Distance(a: t.transform.position, b: point)
ОтветитьInteresting video, I recently started getting into Unity and your channel very helpful for me, thanks!
But I got a question, I created abstract class similar to AutoCleanupSingleton with virtual awake with cleanup and I still can add something to Awake if I need to. Is there still any downsides of using it compared to establishing singleton separately in each class i want to use as singleton?
pls set up yiut mic properly. my ears are hurting
ОтветитьAll I wanted to know was how to use Singletons to create a class which contains global variables. I thought this would address this. Alas, this was such a confusing tutorial and introduced so much stuff which has nothing to do specifically with singletons. While I have enjoyed and learned a lot from your tutorials Jason, this one floors me! :(
ОтветитьLine 11, never forget.
Ответить