This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<div id="output" style="background:green;min-height:40px"> | |
</div> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { useEffect, useState } from "react" | |
// Modified the useKeyPress from useHooks: https://usehooks.com/useKeyPress/ | |
// Takes a `pressMethod` that will run continuously "every frame" (1/60 second - not locked tho) | |
// And also accepts a `downMethod` and `upMethod` for a single call | |
// And still returns a simple true/false for the keypress for convenience/use in React | |
// Ideally all the methods should be an properties of 1 object so user doesn't have to set noop functions to get deeper params | |
export default function useKeyPress(targetKey: string, pressMethod?: () => void, downMethod?: () => void, upMethod?: () => void): boolean { | |
// State for keeping track of whether key is pressed | |
const [keyPressed, setKeyPressed] = useState(false) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var OSName = "Unknown"; | |
if (window.navigator.userAgent.indexOf("Windows NT 10.0")!= -1) OSName="Windows 10"; | |
if (window.navigator.userAgent.indexOf("Windows NT 6.3") != -1) OSName="Windows 8.1"; | |
if (window.navigator.userAgent.indexOf("Windows NT 6.2") != -1) OSName="Windows 8"; | |
if (window.navigator.userAgent.indexOf("Windows NT 6.1") != -1) OSName="Windows 7"; | |
if (window.navigator.userAgent.indexOf("Windows NT 6.0") != -1) OSName="Windows Vista"; | |
if (window.navigator.userAgent.indexOf("Windows NT 5.1") != -1) OSName="Windows XP"; | |
if (window.navigator.userAgent.indexOf("Windows NT 5.0") != -1) OSName="Windows 2000"; | |
if (window.navigator.userAgent.indexOf("Mac") != -1) OSName="Mac/iOS"; | |
if (window.navigator.userAgent.indexOf("X11") != -1) OSName="UNIX"; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html> | |
<html lang="en"> | |
<head> | |
<title>Dialog Example</title> | |
</head> | |
<body> | |
<h1>Dialog Example</h1> | |
<button id="execute-dialog">Click to show dialog</button> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(async () => { | |
const rawResponse = await fetch('https://httpbin.org/post', { | |
method: 'POST', | |
headers: { | |
'Accept': 'application/json', | |
'Content-Type': 'application/json' | |
}, | |
body: JSON.stringify({a: 1, b: 'Textual content'}) | |
}); | |
const content = await rawResponse.json(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
1) Open known_hosts file and look for the invalid host | |
nano ~/.ssh/known_hosts | |
2) Remove the line that has the invalid host. Should be the same host in your .git/config of your repo | |
ssh-keygen -R [dev.blahblah.com]:1234 | |
3) Pull from repo | |
git pull | |
4) You should see something similar to this. Answer 'yes' when asked. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System.Collections; | |
using System.Collections.Generic; | |
using UnityEngine; | |
public class MouseLook : MonoBehaviour | |
{ | |
private bool mouseLock = true; | |
public float mouseSensitivity = 100f; | |
public Transform playerBody; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using UnityEngine; | |
using UnityEngine.EventSystems; // 1 | |
public class PointerExample : MonoBehaviour | |
, IPointerClickHandler // 2 | |
, IDragHandler | |
, IPointerEnterHandler | |
, IPointerExitHandler | |
// ... And many more available! | |
{ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System.Collections.Generic; | |
using UnityEngine; | |
using UnityEngine.UI; | |
using UnityEngine.EventSystems; | |
public class CheckClicks : MonoBehaviour | |
{ | |
// Normal raycasts do not work on UI elements, they require a special kind | |
GraphicRaycaster raycaster; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System.Collections; | |
using System.Collections.Generic; | |
using UnityEngine; | |
using UnityEngine.AI; | |
// Handles actual movement of character + triggering things like animation | |
// This game has a "shooting mode" which is activated by Left Shift | |
// So you'll see shooting logic as well | |
public class PlayerLocomotionController : MonoBehaviour |