Преглед изворни кода

Unity->Stride comparison for Input

Eideren пре 3 година
родитељ
комит
4997b53352
1 измењених фајлова са 22 додато и 1 уклоњено
  1. 22 1
      en/manual/stride-for-unity-developers/index.md

+ 22 - 1
en/manual/stride-for-unity-developers/index.md

@@ -261,7 +261,7 @@ Stride supports a variety of inputs. The code samples below demonstrate the diff
 
 For more information about Input in Stride, see [Input](../input/index.md).
 
-## Unity
+#### Unity®
 ```cs
 void Update()
 {
@@ -282,6 +282,27 @@ void Update()
     //Do something else.
 }
 ```
+#### Stride
+```cs
+public override void Update()
+{
+    // true for one frame in which the space bar was pressed
+    if(Input.IsKeyDown(Keys.Space))
+    {
+        // Do something.
+    }
+
+    // true while this joystick button is down
+    if (Input.GameControllers[0].IsButtonDown(0))
+    {
+        // Do something.
+    }
+
+    float Horiz = (Input.IsKeyDown(Keys.Left) ? -1f : 0) + (Input.IsKeyDown(Keys.Right) ? 1f : 0);
+    float Vert = (Input.IsKeyDown(Keys.Down) ? -1f : 0) + (Input.IsKeyDown(Keys.Up) ? 1f : 0);
+    //Do something else.
+}
+```
 
 ## Physics