Created
February 2, 2017 09:40
-
-
Save dykarohora/9accff9be16d7a3f09dedc011f835801 to your computer and use it in GitHub Desktop.
Use event system instead of message system.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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