chenxin
2020-12-08 ff228d1c9534d6e66b241563fd31eb81af8a38d2
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
using UnityEngine;
 
namespace Core.Input
{
    /// <summary>
    /// Base class for any input scheme that knows how and when to activate itself
    /// </summary>
    public abstract class InputScheme : MonoBehaviour
    {
        /// <summary>
        /// Gets whether the scheme should be activated or not
        /// </summary>
        public abstract bool shouldActivate { get; }
 
        /// <summary>
        /// Gets whether this scheme should be default
        /// </summary>
        public abstract bool isDefault { get; }
 
        /// <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>
        /// 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;
            }
        }
    }
}