how dp o cange buttons in code

139561-scrips.png

I want to make a collectable tape menu but im stuck trying to figure out how to change the numbers of the buttons in the code I attached a pick of the thing im trying to change

Are you talking about the text on the buttons? If so, you should make a method that takes a string as a parameter and sets the text as a string and not an int.

Not the buttons the void

Your question is very unclear…

Are you trying to change the parameter of the tapeMenu.tunronTape when the button is clicked ? (currently, parameter is 0 and you would like to change to 1 for instance?)

If so, you will have to remove the tapeMenu.tunronTape callback you have added through the inspector and add it by code.

// Drag & drop the gameObject with the TapeMenu component in the inspector
public TapeMenu Tapes;

// Drag & drop the gameObject with the Button component in the inspector
public Button Button;

private UnityEngine.Events.UnityAction onClickAction;

private void Start()
{
    ChangeTapeIndex( 0 );
}

// Call this function somewhere to change the argument given to the `tunronTape` function
public void ChangeTapeIndex( int tapeIndex )
{
    if( onClickAction != null )
        Button.onClick.RemoveListener( onClickAction );
    onClickAction = () => TapeMenu.tunronTape( tapeIndex );
    Button.onClick.AddListener( onClickAction );
}