private void SearchNullRef(Object obj) { if (obj == null) { return; } foreach (FieldInfo f in registry.GetFields(obj.GetType())) { if (f.GetAttribute <NullableFieldAttribute>() == null) { object o = f.GetValue(obj); if (o.UnityEquals(null)) { nullRefs.Add(new NullRefData(obj, f)); break; } } } if (obj is Material) { Material mat = obj as Material; if (mat.mainTexture == null) { nullRefs.Add(new NullRefData(obj, null)); } } }
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(); }
private IEnumerable <FieldInfo> GetObjectFields(Type type) { List <FieldInfo> fields = fieldStore.Get(type); if (fields == null) { fields = new List <FieldInfo>(); fieldStore[type] = fields; foreach (FieldInfo f in registry.GetFields(type)) { if (typeof(UnityEngine.Object).IsAssignableFrom(f.FieldType)) { fields.Add(f); } } } return(fields); }