I’m trying to get a sprite to be clickable and then a UI with options for that sprite (move, shoot, etc) but I’m running into some knowledge/other problems.
I figured the best way to do this is to have a child canvas that can but enabled when click on, but I’m having some problems getting it to come up, centered on the sprite.
here is the small script for the click:
using UnityEngine;
using System.Collections;
using UnityEngine.UI;
public class ShipClick : MonoBehaviour {
public Canvas canvas;
void OnMouseUp() {
canvas.enabled = true;
}
}
The issue is that it doesn’t come up even if I drag the canvas onto the script. The sprite has a Box Collider 2d on it.
Update:
I’ve figured out that I can make the sprite game object have both a button and a canvas component but the only way to be able to see the ship with the canvas component is with a world space render mode. The other 2 render modes seem to make the sprite disappear.