//---------------------------------------------------------------------------------------------------------------------- private static DummyScriptableObject CreateDictionaryElement(DummySerializedDictionaryComponent comp, int key) { DummyScriptableObject newObject = ScriptableObject.CreateInstance <DummyScriptableObject>(); comp.AddElement(newObject, Mathf.RoundToInt(key)); return(newObject); }
public void SetExposedReferenceOfScriptableObject() { SimpleExposedPropertyTable propTable = CreatePropertyTableGameObject(); DummyScriptableObject obj = ScriptableObject.CreateInstance <DummyScriptableObject>(); GameObject fooGameObject = new GameObject("Foo"); ExposedReferenceUtility.SetReferenceValueInEditor(ref obj.exposedGameObject, propTable, fooGameObject); GameObject resolvedGameObject = obj.exposedGameObject.Resolve(propTable); Assert.AreEqual(fooGameObject, resolvedGameObject); Object.DestroyImmediate(obj); }
public void TestDuplicatedExposedReferenceAreNotLinked() { SimpleExposedPropertyTable propTable = CreatePropertyTableGameObject(); DummyScriptableObject obj0 = ScriptableObject.CreateInstance <DummyScriptableObject>(); GameObject fooGameObject = new GameObject("Foo"); ExposedReferenceUtility.SetReferenceValueInEditor(ref obj0.exposedGameObject, propTable, fooGameObject); //Duplicate DummyScriptableObject obj1 = Object.Instantiate(obj0); GameObject barGameObject = new GameObject("Bar"); ExposedReferenceUtility.RecreateReferenceInEditor(ref obj1.exposedGameObject, propTable); Assert.AreEqual(obj0.exposedGameObject.Resolve(propTable), obj1.exposedGameObject.Resolve(propTable)); //Change value ExposedReferenceUtility.SetReferenceValueInEditor(ref obj1.exposedGameObject, propTable, barGameObject); Assert.AreNotEqual(obj0.exposedGameObject.Resolve(propTable), obj1.exposedGameObject.Resolve(propTable)); Object.DestroyImmediate(obj1); Object.DestroyImmediate(obj0); }