When do I use Singleton and when should I use a static class when working with unityEditor?
How easy is it to serialize data with each one?
Thank you
When do I use Singleton and when should I use a static class when working with unityEditor?
How easy is it to serialize data with each one?
Thank you
At My Editor Scripts i use Static Class … all public fields get serialized automatically and for private fields just use [SerializeField]
the question about Singleton Vs Static … at my point of view, static i just use to hold string data … and Singleton when my class need the functions …
if is just for a bunch of String fields … i say go for static, but if you need to pass data structure for List or Dictionary , you do at the initialization of the Singleton …
using UnityEngine;
public class SomePerson : MonoBehaviour {
//This field gets serialized because it is public.
public string name = "John";
//This field does not get serialized because it is private.
private int age = 40;
//This field gets serialized even though it is private
//because it has the SerializeField attribute applied.
[SerializeField]
private bool hasHealthPotion = true;
void Update () {
}
}