コード例 #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);
        }
コード例 #2
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));
        }
コード例 #3
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));
        }