How can you find the index or a variable associated to said index, from a script run from that instance of the game object?
This has me stumped!
1. I populate my level scene with instances of a button prefab that are generated from a level manager script attached to my GameManager.
2. The Button instances get the onClick event passed from the level manager script.
I have a function to Set World and Level.
3. When I click the instance of the button during runtime and try to reference the game object it returns the GameManager (the object that the LevelManager is on) and not the button instance.
4. How can I get the function to reference or return the specific array ID and or variables associated to the instance of the button I am clicking in the scene?
See Inspector
I've tried a bunch of stuff but nothing has worked. This is the current state of the script. I feel like it should be something so simple. What am I missing?
public void SetWorldAndLevel()
{
int refID = gameObject.GetComponent<LevelButton>().btnGlobalLvl; //GetInstanceID(); //LevelList.IndexOf(1); //transform.parent.gameObject;
Debug.Log("Im attached to " + refID);
//pState.currentWorld = this.gameObject.GetComponent<LevelManager>().LevelList[refID].m_WorldIndx;
//pState.currentLvl = this.gameObject.GetComponent<LevelButton>().btnGlobalLvl;
SaveAll();
}