- Home /
Question by
unity_5H7RTjteZfn5Sg · Jun 27, 2018 at 09:02 PM ·
input2d gametouch
Global input script vs own scripts for all gameObjects
I want to create global input script, like:
public class InputManager : MonoBehaviorExtended
{
TouchPhase _lastTouchPhase = TouchPhase.Ended;
private void Update ()
{
//Touch phase changed.
if (Input.touches.Any() && Input.GetTouch(0).phase != _lastTouchPhase)
{
//here i will raycast and find object that hit
}
}
}
After i find object, that was hit i will call my custom method OnInput(), all my game objects will be implement interface or override method from custom base class, whatever.
The question is: will it be faster or more optiomal (or any advantages), than just subscribe on touch event with attached scripts for each object or using global input with redicrection to specific objects like i said?
Comment