Communication between elements

I have public integers assigned to different elements. I want to choose 2 by clicking mouse and compare it in function.

void Compare(int A, int B)
{
     if(A >B)
     DoSomething;
     else
     DoNothing;
}
`
Should I use void OnMouseUp()?
`

I have no idea what you're talking about, sorry. By "assigned", do you mean you defined a public integer variable in the class of the element? Next what are those "elements"? gameobjects? do they have a collidet? What's the exact flow of control here? Should they be compared as soon as you have selected the second element? Oh and what's about your title? where's the communication you asked about?

1 Answer

1

Aassigned = defined a public integer variable in class of the element.
The Elments are game object with collider.
They should be compared as siin as you selected the second game object.

I failed with the title choosing, what I meant is rather picking GameObjects.
This is what I have, but I want if function to work when mouse cursor is on the GameObject. Can you help me with that?

void Update () {
	
		if(Input.GetMouseButtonDown(0))
		{
				Debug.Log ("Click 1");
		}
		if (Input.GetMouseButtonUp (0)) 
		{

			NextA = otherGameObject.GetComponent<SecondScript>();
			a = a- NextA.a;
			Debug.Log ("Click2"+a);
		}
	}