This file contains hidden or 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 UnityEditor; | |
public static class SerializedObjectUtility | |
{ | |
public static object GetTargetValue(this SerializedProperty property) | |
{ | |
var targetObject = property.serializedObject.targetObject; | |
var field = targetObject.GetType().GetField(property.propertyPath); | |
return field?.GetValue(targetObject); |
This file contains hidden or 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
public class SingletonInstance : MonoBehaviour | |
{ | |
public static SingletonInstance Instance { get; private set; } | |
private void Awake() | |
{ | |
if (Instance != null) | |
{ | |
Destroy(gameObject); | |
return; |
This file contains hidden or 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; | |
[ExecuteInEditMode] | |
[RequireComponent(typeof(Camera))] | |
public class CameraEffect : MonoBehaviour | |
{ | |
public Material material; | |
private void OnRenderImage(RenderTexture source, RenderTexture destination) | |
{ |
This file contains hidden or 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; | |
[CreateAssetMenu(fileName = "New Example", menuName = "Example")] | |
public class ExampleScriptableObject : ScriptableObject | |
{ | |
public Sprite Icon => icon; | |
[SerializeField] | |
private Sprite icon = null; | |
} |
This file contains hidden or 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
# "pip install pynput" to install pynput | |
from pynput.keyboard import Key, Controller | |
from time import time, sleep | |
def take_screenshot(): | |
keyboard = Controller() | |
# Windows key + Print screen | |
with keyboard.pressed(Key.cmd_r): | |
keyboard.press(Key.print_screen) |
This file contains hidden or 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
export type EventHandler<T> = (event: T) => void; | |
export interface IEvent<T> | |
{ | |
add(handler: EventHandler<T>): void; | |
remove(handler: EventHandler<T>): void; | |
} | |
export class InvokeableEvent<T> implements IEvent<T> | |
{ |
This file contains hidden or 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
doStuff(); | |
async function doStuff() | |
{ | |
while (true) | |
{ | |
console.log("Hello, world!"); | |
await sleep(500); | |
} | |
} |
This file contains hidden or 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
public static class RotationUtility | |
{ | |
/// <param name="rotation"> | |
/// Value of 0f to 360f. | |
/// Rotation that will be limitted to a certain angle. | |
/// </param> | |
public static float LimitRotation( | |
float rotation, | |
float minRotation, | |
float maxRotation) |
This file contains hidden or 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; | |
public static class CameraUtility | |
{ | |
public static Camera MainCamera | |
{ | |
get | |
{ | |
if (_mainCamera == null) | |
{ |
This file contains hidden or 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; | |
namespace VariableChangedEventPattern | |
{ | |
class Program | |
{ | |
private static void Main() | |
{ | |
Game.Score.Changed += OnScoreChanged; | |
Game.Score.Value += 200; |
NewerOlder