private List <GameObjectRefs> SearchRefs() { refDiffs.Clear(); List <GameObjectRefs> result = new List <GameObjectRefs>(); foreach (Transform t in root.GetComponentsInChildren <Transform>(true)) { GameObjectRefs goRefs = new GameObjectRefs(t.GetScenePath()); Component[] comps = t.GetComponents(typeof(Component)); for (int i = 0; i < comps.Length; ++i) { Component c = comps[i]; if (c != null) { CompRefs compRefs = new CompRefs(c.GetType(), i); foreach (FieldInfo f in registry.GetFields(c.GetType())) { Object val = f.GetValue(c) as Object; if (val != null) { compRefs.AddRef(f.Name, val); refDiffs.Add(new RefDiff(c, f, val)); } } goRefs.AddRef(compRefs); } else { goRefs.AddRef(new CompRefs()); } } result.Add(goRefs); } return(result); }
private void Load() { ClearResults(); refDiffs.Clear(); BinarySerializer reader = new BinarySerializer(fileToLoad.FullName, FileAccess.Read); List <GameObjectRefs> backup = reader.Deserialize <List <GameObjectRefs> >(); foreach (GameObjectRefs refs in backup) { Transform t = TransformUtil.Search(refs.path); if (t != null) { Component[] comps = t.GetComponents(typeof(Component)); for (int i = 0; i < comps.Length && i < refs.refs.Count; ++i) { Component c = comps[i]; if (c == null) { continue; } CompRefs compRefs = refs.refs[i]; if (compRefs.compType == c.GetType().FullName) { foreach (FieldInfo f in registry.GetFields(c.GetType())) { Object backupVal = compRefs.GetValue(f.Name); if (backupVal != null) { refDiffs.Add(new RefDiff(c, f, backupVal)); } } } } } } reader.Close(); }
public void AddRef(CompRefs r) { refs.Add(r); }