void OnDestroy()
        {
            List <InputSourceBase> inputSources = InputShellMap.Instance.inputSwitchLogic.TargetingSourceBases;

            for (int i = 0; i < inputSources.Count; i++)
            {
                ITargetingInputSource targetSource = inputSources as ITargetingInputSource;
                if (targetSource != null)
                {
                    targetSource.OnSelectChanged -= DoTargetSourceSelectChanged;
                    targetSource.OnMenuChanged   -= OnTargetSourceMenuChanged;
                }
            }
        }
 /// <summary>
 /// Checks all enabled input sources and activates a new source if requested
 /// </summary>
 public void Update()
 {
     for (int i = 0; i < TargetingSources.Count; ++i)
     {
         ITargetingInputSource targetSource = TargetingSources[i];
         if (TargetingSourceBases[i].IsEnabled)
         {
             if (targetSource != CurrentTargetingSource && targetSource.ShouldActivate())
             {
                 ActivateTargetingSource(targetSource);
                 break;
             }
         }
     }
 }
 /// <summary>
 /// Returns true if any enabled input source has menu pressed
 /// </summary>
 public bool GetAnyMenuPressed()
 {
     foreach (InputSourceBase source in inputSources.sources)
     {
         if (source.IsEnabled)
         {
             ITargetingInputSource targetSource = source as ITargetingInputSource;
             if (targetSource != null && targetSource.IsMenuPressed())
             {
                 return(true);
             }
         }
     }
     return(false);
 }
    /// <summary>
    /// Deactivates the current source and activateds the new source
    /// </summary>
    public void ActivateTargetingSource(ITargetingInputSource targetSource)
    {
        if (CurrentTargetingSource != null && CurrentTargetingSource != targetSource)
        {
            CurrentTargetingSource.OnActivate(false);
        }

        CurrentTargetingSource = targetSource;

        if (CurrentTargetingSource != null)
        {
            if (debugPrint)
            {
                Debug.Log("Activating source " + CurrentTargetingSource);
            }

            CurrentTargetingSource.OnActivate(true);
        }
    }
        /// <summary>
        /// Initialization.  Creates the world cursor, gets the beam controller, and other things associated
        /// with input.
        /// </summary>
        void Start()
        {
            // Create world cursor instance
            if (WorldCursorPrefab != null)
            {
                worldCursor = Instantiate <WorldCursor>(WorldCursorPrefab);
            }

            List <InputSourceBase> inputSources = InputShellMap.Instance.inputSwitchLogic.TargetingSourceBases;

            for (int i = 0; i < inputSources.Count; i++)
            {
                ITargetingInputSource targetSource = inputSources[i] as ITargetingInputSource;
                if (targetSource != null)
                {
                    targetSource.OnSelectChanged += DoTargetSourceSelectChanged;
                    targetSource.OnMenuChanged   += OnTargetSourceMenuChanged;
                }
            }
        }
    /// <summary>
    /// Initialization.  Stores all input sources from InputSources which implement ITargetingInputSource
    /// </summary>
    /// <param name="_inputSources"></param>
    public void Init(InputSources _inputSources)
    {
        inputSources = _inputSources;

        foreach (InputSourceBase source in inputSources.sources)
        {
            //if( source.GetType().IsAssignableFrom(typeof(ITargetingInputSource)))
            if (source is ITargetingInputSource)
            {
                TargetingSources.Add(source as ITargetingInputSource);
                TargetingSourceBases.Add(source);
            }
        }

        if (debugPrint)
        {
            Debug.Log("TargetingSources: " + TargetingSources.Count);
        }

        CurrentTargetingSource = inputSources.hands;
    }