Function Requires Two Button Presses Instead of One?

I’m working on something with the Oculus Rift as a personal project. Everything has been working fine up until this point. The problem is that with my code, a certain function requires two button presses to complete for some reason. However, I know that the functions are being called the first time, because updates to the UI are made.
This portion of code deals with the locking and unlocking of objects in a given position. There are UI Toggles that control the locking of separate objects, and the Y and B buttons lock (and unlock) all objects on the respective hand. The code should read as follows:

If the Y button is pressed, check to see if there are any locked objects in the hand. If so, unlock all objects. Otherwise, if the hand trigger is held to a certain degree while the button is pressed, then lock all objects.

In the unlock function, the objects are sorted through and all are unlocked. Then, a call to a static function in the UI manager is made (and again, this updates the first time the button is pressed). However, both in the inspector and in the game, the objects are shown as still being locked. It requires a second press to unlock the objects. Here’s the code.

public void Update(){
///....
if(GetButtonDown(1)){ //Refers to the top button on Oculus Touch controller
			if(AnyLocked()){
				UnlockObjects();
			} else if(GetHandTrigger() >= 0.95f){
				LockObjects();
			}
		}
///....
UpdateObjects();
}

public bool AnyLocked(){
		for(int i = 0; i < objs.Length; i++){
			if(objs*.locked)*
  •  		return true;*
    
  •  }*
    
  •  return false;*
    
  • }*
    public void LockObjects(){
  •  for(int i = 0; i < objs.Length; i++){*
    

_ objs*.locked = true;_
_
string str = ((leftHand)?“L1”:“R1”) + “C” + (i+1).ToString();_
_
UIHandler.SetToggleByName(str, false);_
_
}_
_
}_
_
public void UnlockObjects(){_
_
for(int i = 0; i < objs.Length; i++){_
_ objs.locked = false;
string str = ((leftHand)?“L1”:“R1”) + “C” + (i+1).ToString();
UIHandler.SetToggleByName(str, true);
}
}*
Is there a logical fallacy I’m missing here? The objects are updated every frame, and putting the UpdateObjects() function at the end of the locking and unlocking functions does nothing.
Any help would be appreciated!_

Ah, I forgot that I added an ‘On Value Changed’ event to the UI toggles, so they’d toggle the objects’ lock again after disabling it. Oops.