Skip to content

Instantly share code, notes, and snippets.

@dykarohora
Created February 2, 2017 09:40
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dykarohora/9accff9be16d7a3f09dedc011f835801 to your computer and use it in GitHub Desktop.
Save dykarohora/9accff9be16d7a3f09dedc011f835801 to your computer and use it in GitHub Desktop.
Use event system instead of message system.
using UnityEngine;
using UnityEngine.EventSystems;
public class SphereCommandsForEvent : MonoBehaviour, ISelectable {
public void OnSelect() {
if(!this.GetComponent<Rigidbody>()) {
var rigidbody = this.gameObject.AddComponent<Rigidbody>();
rigidbody.collisionDetectionMode = CollisionDetectionMode.Continuous;
}
}
}
// Add to
public interface ISelectable : IEventSystemHandler {
void OnSelect();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment