열차 목업의 내부 확인용 프로젝트
smchoi
2024-06-14 3d45944b4b2abc384e2539fa72cd7925bbcf2543
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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
using System;
using UnityEngine;
using UnityStandardAssets.CrossPlatformInput.PlatformSpecific;
 
namespace UnityStandardAssets.CrossPlatformInput
{
    public static class CrossPlatformInputManager
    {
        public enum ActiveInputMethod
        {
            Hardware,
            Touch
        }
 
 
        private static VirtualInput activeInput;
 
        private static VirtualInput s_TouchInput;
        private static VirtualInput s_HardwareInput;
 
 
        static CrossPlatformInputManager()
        {
            s_TouchInput = new MobileInput();
            s_HardwareInput = new StandaloneInput();
#if MOBILE_INPUT
            activeInput = s_TouchInput;
#else
            activeInput = s_HardwareInput;
#endif
        }
 
        public static void SwitchActiveInputMethod(ActiveInputMethod activeInputMethod)
        {
            switch (activeInputMethod)
            {
                case ActiveInputMethod.Hardware:
                    activeInput = s_HardwareInput;
                    break;
 
                case ActiveInputMethod.Touch:
                    activeInput = s_TouchInput;
                    break;
            }
        }
 
        public static bool AxisExists(string name)
        {
            return activeInput.AxisExists(name);
        }
 
        public static bool ButtonExists(string name)
        {
            return activeInput.ButtonExists(name);
        }
 
        public static void RegisterVirtualAxis(VirtualAxis axis)
        {
            activeInput.RegisterVirtualAxis(axis);
        }
 
 
        public static void RegisterVirtualButton(VirtualButton button)
        {
            activeInput.RegisterVirtualButton(button);
        }
 
 
        public static void UnRegisterVirtualAxis(string name)
        {
            if (name == null)
            {
                throw new ArgumentNullException("name");
            }
            activeInput.UnRegisterVirtualAxis(name);
        }
 
 
        public static void UnRegisterVirtualButton(string name)
        {
            activeInput.UnRegisterVirtualButton(name);
        }
 
 
        // returns a reference to a named virtual axis if it exists otherwise null
        public static VirtualAxis VirtualAxisReference(string name)
        {
            return activeInput.VirtualAxisReference(name);
        }
 
 
        // returns the platform appropriate axis for the given name
        public static float GetAxis(string name)
        {
            return GetAxis(name, false);
        }
 
 
        public static float GetAxisRaw(string name)
        {
            return GetAxis(name, true);
        }
 
 
        // private function handles both types of axis (raw and not raw)
        private static float GetAxis(string name, bool raw)
        {
            return activeInput.GetAxis(name, raw);
        }
 
 
        // -- Button handling --
        public static bool GetButton(string name)
        {
            return activeInput.GetButton(name);
        }
 
 
        public static bool GetButtonDown(string name)
        {
            return activeInput.GetButtonDown(name);
        }
 
 
        public static bool GetButtonUp(string name)
        {
            return activeInput.GetButtonUp(name);
        }
 
 
        public static void SetButtonDown(string name)
        {
            activeInput.SetButtonDown(name);
        }
 
 
        public static void SetButtonUp(string name)
        {
            activeInput.SetButtonUp(name);
        }
 
 
        public static void SetAxisPositive(string name)
        {
            activeInput.SetAxisPositive(name);
        }
 
 
        public static void SetAxisNegative(string name)
        {
            activeInput.SetAxisNegative(name);
        }
 
 
        public static void SetAxisZero(string name)
        {
            activeInput.SetAxisZero(name);
        }
 
 
        public static void SetAxis(string name, float value)
        {
            activeInput.SetAxis(name, value);
        }
 
 
        public static Vector3 mousePosition
        {
            get { return activeInput.MousePosition(); }
        }
 
 
        public static void SetVirtualMousePositionX(float f)
        {
            activeInput.SetVirtualMousePositionX(f);
        }
 
 
        public static void SetVirtualMousePositionY(float f)
        {
            activeInput.SetVirtualMousePositionY(f);
        }
 
 
        public static void SetVirtualMousePositionZ(float f)
        {
            activeInput.SetVirtualMousePositionZ(f);
        }
 
 
        // virtual axis and button classes - applies to mobile input
        // Can be mapped to touch joysticks, tilt, gyro, etc, depending on desired implementation.
        // Could also be implemented by other input devices - kinect, electronic sensors, etc
        public class VirtualAxis
        {
            public string name { get; private set; }
            private float m_Value;
            public bool matchWithInputManager { get; private set; }
 
 
            public VirtualAxis(string name)
                : this(name, true)
            {
            }
 
 
            public VirtualAxis(string name, bool matchToInputSettings)
            {
                this.name = name;
                matchWithInputManager = matchToInputSettings;
            }
 
 
            // removes an axes from the cross platform input system
            public void Remove()
            {
                UnRegisterVirtualAxis(name);
            }
 
 
            // a controller gameobject (eg. a virtual thumbstick) should update this class
            public void Update(float value)
            {
                m_Value = value;
            }
 
 
            public float GetValue
            {
                get { return m_Value; }
            }
 
 
            public float GetValueRaw
            {
                get { return m_Value; }
            }
        }
 
        // a controller gameobject (eg. a virtual GUI button) should call the
        // 'pressed' function of this class. Other objects can then read the
        // Get/Down/Up state of this button.
        public class VirtualButton
        {
            public string name { get; private set; }
            public bool matchWithInputManager { get; private set; }
 
            private int m_LastPressedFrame = -5;
            private int m_ReleasedFrame = -5;
            private bool m_Pressed;
 
 
            public VirtualButton(string name)
                : this(name, true)
            {
            }
 
 
            public VirtualButton(string name, bool matchToInputSettings)
            {
                this.name = name;
                matchWithInputManager = matchToInputSettings;
            }
 
 
            // A controller gameobject should call this function when the button is pressed down
            public void Pressed()
            {
                if (m_Pressed)
                {
                    return;
                }
                m_Pressed = true;
                m_LastPressedFrame = Time.frameCount;
            }
 
 
            // A controller gameobject should call this function when the button is released
            public void Released()
            {
                m_Pressed = false;
                m_ReleasedFrame = Time.frameCount;
            }
 
 
            // the controller gameobject should call Remove when the button is destroyed or disabled
            public void Remove()
            {
                UnRegisterVirtualButton(name);
            }
 
 
            // these are the states of the button which can be read via the cross platform input system
            public bool GetButton
            {
                get { return m_Pressed; }
            }
 
 
            public bool GetButtonDown
            {
                get
                {
                    return m_LastPressedFrame - Time.frameCount == -1;
                }
            }
 
 
            public bool GetButtonUp
            {
                get
                {
                    return (m_ReleasedFrame == Time.frameCount - 1);
                }
            }
        }
    }
}