Ejemplo n.º 1
0
        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);
        }
Ejemplo n.º 2
0
        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));
        }
Ejemplo n.º 3
0
        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));
        }
Ejemplo n.º 4
0
        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));
        }
Ejemplo n.º 5
0
        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));
        }
Ejemplo n.º 6
0
        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));
        }