C# Find Which Axes Gameobject is on

I have two gameobjects. One functions as a reference for the axes. The other one will have script attached to it that will determine what axis it is lying on. Any idea how I could find that info? I’ve tried if(someGameObject2.transform.position.y == someGameObject.transform.position.y) but that if statement is comparing values and someGameObject’s axes could have the exact same value such as (0,0,0). I have some pseudo code written up. I’m just not sure what I want to compare to see if one gameobject is on the y axis of another gameobject

using UnityEngine;
using System.Collections;

public class AxisChecker : MonoBehaviour {
	public GameObject someGameObject;
	public GameObject someGameObject2;
	// Use this for initialization
	void Start () {
	
	}
	
	// Update is called once per frame
	void Update () {
		/*if(someGameObject2 is lying on someGameObject.transform.x)
          Debug.Log("someGameObject2 is lying on someGameObject's x axis");
          if(someGameObject2 is lying on someGameObject.transform.y)
          Debug.Log("someGameObject2 is lying on someGameObject's y axis");
          if(someGameObject2 is lying on someGameObject.transform.z)
          Debug.Log("someGameObject2 is lying on someGameObject's z axis");
        */
	}
}

The transform has three vectors you can use: transform.up, transform.right and transform.forward. These axes are the world space direction for the forward, right and up side of your game object. To figure out what axis an object as aligned with another object, you can use Vector3.Angle() or Vector3.Dot() for the dot product, if two normalized vectors are aligned, it returns a value of 1.0. If they are exactly opposite, then it returns a value of -1.0. I’m going to make an assumption here based on your wording and that you care about the ‘y’ (up) axis. So you can do:

if (Mathf.Abs(Vector3.Dot(someObject.transform.up someObject2.transform.up) > 0.9f) {
    Debug.Log("Aligned on the 'Y' axis");
}
else if (Mathf.Abs(Vector3.Dot(someObject.transform.forward someObject2.transform.up) > 0.9f) {
    Debug.Log("Aligned on the 'Z' axis");
} else if (Mathf.Abs(Vector3.Dot(someObject.transform.right, someObject2.transform.up) > 0.9f) {
    Debug.Log("Aligned on the 'Z' axis");
}

The .0.9 is an arbitrary threshold, and ‘someObject’ is the reference object. The use of Abs() here means that two objects can be aligned in either direction.