I want to make a Select
and Deselect
method on 3D object. I’m using Event Trigger
with ISelectHandler
and IDeselectHandler
.
I’m add as component to 2 object: UI button and 3D object cube… and the result, on UI its works but on 3D object its nothing happen…
here my script, please help thanks
using UnityEngine;
using UnityEngine.EventSystems;
using System.Collections;
namespace DebugScripts
{
public class SelectedObjectv2 : MonoBehaviour, ISelectHandler, IDeselectHandler
{
public void OnSelect (BaseEventData eventData) { print ("Object Selected"); }
public void OnDeselect (BaseEventData eventData) { print ("Object Deseleted"); }
}
}
You need at least colliders on your 3D objects to interact with them trough events. If adding colliders does not trigger the UI events then you need to use [OnMouseDown][1] function instead. [1]: http://docs.unity3d.com/ScriptReference/MonoBehaviour.OnMouseDown.html
– CommunizeI already tried adding colliders but still not working.. I want to avoid using OnMouseDown because my object is many, but thanks for respons
– Vagabond