Beispiel #1
0
 /// <summary>
 /// Deactivate if not already deactivated
 /// </summary>
 /// <param name="nextScheme">
 /// The next scheme that will be activated.
 /// Will be null on start up.
 /// </param>
 public virtual void Deactivate(InputScheme nextScheme)
 {
     if (enabled)
     {
         enabled = false;
     }
 }
Beispiel #2
0
 /// <summary>
 /// Activate if not already activated
 /// </summary>
 /// <param name="previousScheme">
 /// The scheme that was previously enabled.
 /// Will be null on start up.
 /// </param>
 public virtual void Activate(InputScheme previousScheme)
 {
     if (!enabled)
     {
         enabled = true;
     }
 }
 /// <summary>
 /// Checks the different schemes and activates them if needed
 /// </summary>
 protected virtual void Update()
 {
     foreach (InputScheme scheme in m_InputSchemes)
     {
         if (scheme.enabled || !scheme.shouldActivate)
         {
             continue;
         }
         if (m_CurrentScheme != null)
         {
             m_CurrentScheme.Deactivate(scheme);
         }
         scheme.Activate(m_CurrentScheme);
         m_CurrentScheme = scheme;
         break;
     }
 }
 /// <summary>
 /// Cache the schemes and activate the default
 /// </summary>
 protected virtual void Awake()
 {
     m_InputSchemes = GetComponents <InputScheme>();
     foreach (InputScheme scheme in m_InputSchemes)
     {
         scheme.Deactivate(null);
         if (m_CurrentScheme == null && scheme.isDefault)
         {
             m_DefaultScheme = scheme;
         }
     }
     if (m_DefaultScheme == null)
     {
         Debug.LogError("[InputSchemeSwitcher] Default scheme not set.");
         return;
     }
     m_DefaultScheme.Activate(null);
     m_CurrentScheme = m_DefaultScheme;
 }