Is something wrong with this code ? It’s currently not working and I can’t figure out why
The point is simply when you click on a button, it spawns a tree.
using UnityEngine;
using System.Collections;
using UnityEngine.UI;
using UnityEngine.EventSystems;
public class NewTree : MonoBehaviour {
public GameObject myTree;
public Toggle treeToggle;
public void OnPointerClick(PointerEventData eventData) {
Instantiate (myTree, new Vector3 (0, 0, 0), Quaternion.identity);
}
}
Thanks for your help