public void ANullReferenceWillNotBeFixed() { GameObject go = new GameObject(); ReferencingComponent cmp = new ReferencingComponent(); go.AddComponent(cmp); Dictionary <int, UnityObject> dict = new Dictionary <int, UnityObject>(); cmp.FixReferences(dict); Assert.That(cmp.reference, Is.Null); }
public void WeWillAlsoFixUpNonPublicReferencesThatHaveTheContentSerializeAttribute() { GameObject go = new GameObject(); TestComponent testCmp = new TestComponent(true); TestComponent newCmp = new TestComponent(); ReferencingComponent cmp = new ReferencingComponent(testCmp); go.AddComponent(cmp); Dictionary <int, UnityObject> dict = new Dictionary <int, UnityObject>(); dict.Add(testCmp.GetInstanceID(), newCmp); go.FixReferences(dict); Assert.That(cmp.GetSerializedProperty(), Is.SameAs(newCmp)); }
public void WeCanFixReferencesInArrayProperties() { GameObject go = new GameObject(); TestComponent testCmp = new TestComponent(true); TestComponent newCmp = new TestComponent(); ReferencingComponent cmp = new ReferencingComponent() { componentArray = new Component[] { testCmp } }; go.AddComponent(cmp); Dictionary <int, UnityObject> dict = new Dictionary <int, UnityObject>(); dict.Add(testCmp.GetInstanceID(), newCmp); cmp.FixReferences(dict); Assert.That(cmp.componentArray[0], Is.SameAs(newCmp)); }
public void WeWillFixReferencesInTheHierarchy() { TestHierarchy h = new TestHierarchy(); TestComponent testCmp = new TestComponent(true); TestComponent newCmp = new TestComponent(); ReferencingComponent cmp = new ReferencingComponent() { reference = testCmp }; h.childOfChild.AddComponent(cmp); Dictionary <int, UnityObject> dict = new Dictionary <int, UnityObject>(); dict.Add(testCmp.GetInstanceID(), newCmp); h.root.FixReferences(dict); Assert.That(cmp.reference, Is.SameAs(newCmp)); }
public void WeFixUpTheComponentsOfAGameObject() { GameObject go = new GameObject(); TestComponent testCmp = new TestComponent(true); TestComponent newCmp = new TestComponent(); ReferencingComponent cmp = new ReferencingComponent() { reference = testCmp }; go.AddComponent(cmp); Dictionary <int, UnityObject> dict = new Dictionary <int, UnityObject>(); dict.Add(testCmp.GetInstanceID(), newCmp); go.FixReferences(dict); Assert.That(cmp.reference, Is.SameAs(newCmp)); }
public void WeWillReplaceADummyPrefabReferenceWithAReferenceFromTheIdMap() { GameObject go = new GameObject(); TestComponent testCmp = new TestComponent(true); TestComponent newCmp = new TestComponent(); ReferencingComponent cmp = new ReferencingComponent() { reference = testCmp }; go.AddComponent(cmp); Dictionary <int, UnityObject> dict = new Dictionary <int, UnityObject>(); dict.Add(testCmp.GetInstanceID(), newCmp); cmp.FixReferences(dict); Assert.That(cmp.reference, Is.SameAs(newCmp)); }