/// <summary> /// Register new mocked object to this root /// </summary> /// <param name="newObject">New mocked object to be registered</param> public void RegisterObject(MockedObject newObject) { if (registeredObjects.Contains(newObject)) { return; } MessagesManager.RegisterObject(newObject); registeredObjects.Add(newObject); NewMockedObjectRegistered?.Invoke(newObject); }
/// <summary> /// Unregister mocked object from this root /// </summary> /// <param name="objectToUnregister">Mocked object to be unregistered</param> public void UnregisterObject(MockedObject objectToUnregister) { if (!registeredObjects.Contains(objectToUnregister)) { return; } MessagesManager.UnregisterObject(objectToUnregister); registeredObjects.Remove(objectToUnregister); MockedObjectUnregistered?.Invoke(objectToUnregister); }
/// <summary> /// Locate mocked object in the hierarchy parent objects /// </summary> private MockedObject LocateParentObject() { var node = transform; while (node != null && parentObject == null) { parentObject = node.GetComponent <MockedObject>(); node = node.parent; } return(parentObject); }