Working in Javascript, I’m trying to detect when the dropdown is open or close (i.e. when the option list is presented). I suspect that the OnPointerClick event has something to do with this but am having trouble coming up with a reliable solution.
I realize that working with C# is preferred but this is legacy code I’m modifying so a Javascript solution is preferable.
Adding to Gearme’s Answer. I used the childCount thinking it would be Better than FindGameObject since I had to use this inside an Update Function to prevent finger sliding from moving the camera.
public Transform DropDownShips;
if (DropDownShips.childCount != 3)
{
return;
}
I’m guessing this is way too late for you - but for posterity’s sake: Lets call the GameObject holding the Dropdown-Component “DropdownObject”. Whenever the dropdown menu is opened, Unity creates a new GameObject called “Dropdown List” as a child of DropdownObject’s transform. One could therefore query the state of the dropdown by trying to find it, i.e. by using the FindChild(string name) function of DropdownObject’s transform. The function will return the GameObject if the Dropdown is open and null if it is not.