private void OnEnable() { Collectors.Add(this); SaveLoad.Instance().onLoad += CleanSaveablesList; saveables.AddRange(GetComponentsInChildren <ISaveable>(true)); foreach (ISaveable saveable in saveables) { saveable.Register(); } List <Transform> simpleObjects = GetAllTransforms(transform); foreach (Transform tr in simpleObjects) { Saveable saveable = tr.gameObject.AddComponent <Saveable>(); saveable.Register(); } }
public void AddToCollector(Transform go) { ISaveable[] goSaveables = go.GetComponentsInChildren <ISaveable>(); foreach (ISaveable saveable in goSaveables) { saveable.Register(); } saveables.AddRange(goSaveables); List <Transform> trs = new List <Transform>() { go }; trs.AddRange(GetAllTransforms(go)); foreach (Transform tr in trs) { Saveable saveable = tr.gameObject.AddComponent <Saveable>(); saveable.Register(); } }