I’ am Writing a script for a button click to instantiate a game object into my play field.
My play field is a grid of buttons so when you select a button from the play field it will give you another selection of buttons with different objects to instantiate, I 'am trying to reference the button that was clicked in the play field in the other buttons script when it is clicked, so using “EventSystem.current.currentSelectedGameObject” wouldnt work right?
so could i use “EventSystem.current.lastSelectedGameObject”?
the other thing is that when i try just referencing the selected game object and using Debug.Log. to print its name its not returning with anything , see Below
using UnityEngine;
using System.Collections;
using UnityEngine.EventSystems;
public class TurretScript : MonoBehaviour
{
public Sprite Turret;
private GameObject selButton;
void Awake()
{
selButton = GameObject.Find(EventSystem.current.currentSelectedGameObject.name);
}
void start()
{
if (GameObject.Find(EventSystem.current.currentSelectedGameObject.name) != null)
{
Debug.Log((selButton.name));
}
}
}