Align a object's rotation to another object

So i have a objectA with child MountPoint1, and objectB with child MountPoint2. Both Y axis of Mountpoints are point outwards, away from the object.

I want to mount ObjectA on ObjectB so that those two mountpoints would be pointing at each other.

The current method in my mind is to find the angular difference between those two mountpoints, and add it to the rotation of the ObjectA.

Would this be the most elegant way to do it? And if so, how do I actually apply it. (I’m pretty bad with rotations and stuff)

Any suggestions would be appreciated.

Your question is not perfectly clear but here is a script I made to help you. Attach it to your objectA and objectB :

using UnityEngine;
using System.Collections;

public class Rotate : MonoBehaviour
{
        // Drag and drop the MountPoint transform of the object holding the script
	public Transform child ;

        // Drag and drop the MountPoint transform of the other object
	public Transform target ;	
	
	private void Start()
	{
		Align();
	}
	
	private void Align()
	{
		Vector3 direction = target.position - child.position ;
                // Change child.forward to child.up if you want the up vectors to "look at" the other child object
		Quaternion rotation = Quaternion.FromToRotation(child.forward, direction);
		transform.rotation = rotation * transform.rotation;		
	}
}