Skip to content

Instantly share code, notes, and snippets.

View sinbad's full-sized avatar

Steve Streeting sinbad

View GitHub Profile
sinbad / StevesEaseMath.cpp
Last active March 31, 2023 11:41
Easing functions from implemented for Unreal Engine
#include "StevesEaseMath.h"
float UStevesEaseMath::EaseAlpha(float InAlpha, EStevesEaseFunction Func)
constexpr float BackC1 = 1.70158f;
constexpr float BackC2 = BackC1 * 1.525f;
constexpr float BackC3 = BackC1 + 1.f;
constexpr float ElasticC4 = UE_TWO_PI / 3.f;
constexpr float ElasticC5 = UE_TWO_PI / 4.5;
sinbad / Steve's Rider For Unreal Code Theme.icls
Last active October 27, 2021 01:05
Rider for Unreal Code Colours
<scheme name="Steve's Custom Monokai Pro" version="142" parent_scheme="Darcula">
<property name="created">2021-06-01T12:01:43</property>
<property name="ide">Rider</property>
<property name="ideVersion">2021.</property>
<property name="modified">2021-06-01T12:02:09</property>
<property name="originalScheme">Steve's Custom Monokai Pro</property>
<option name="ADDED_LINES_COLOR" value="a9dc76" />
sinbad / InputModeDetector.cpp
Last active March 18, 2024 19:02
UE4 detecting which input method was last used by each player
#include "InputModeDetector.h"
#include "Input/Events.h"
// 4 local players should be plenty usually (will expand if necessary)
LastInputModeByPlayer.Init(EInputMode::Mouse, 4);
bool FInputModeDetector::HandleKeyDownEvent(FSlateApplication& SlateApp, const FKeyEvent& InKeyEvent)
sinbad /
Created August 9, 2020 14:58
My Gitea Backup & Restore Scripts
# `gitea dump` doesn't currently back up LFS data as well, only git repos
# It primarily backs up the SQL DB, and also the config / logs
# We'll backup like this:
# * "gitea dump" to backup the DB and config etc
# * tar / bzip all the repos since they will be skipped
# * Not rotated because git data is immutable (normally) so has all data
# * rsync LFS data directly from /volume/docker/gitea/git/lfs
# * No need for rotation since all files are immutable
sinbad /
Last active June 9, 2020 11:41
UE4 RPCs with both C++ and Blueprint implementations

I want a server RPC function which:

  • Is callable by both C++ and Blueprints
  • Is overrideable in Blueprints as well as C++

The basic C++ declared RPC with BlueprintCallable gets me the C++ / Blueprint visibility, but NOT the BP overrideable aspect, because you're not allowed to use BlueprintNativeEvent on Server functions. I.e.

UFUNCTION(BlueprintCallable, Server, Reliable)
void DoSomethingOnServer();
sinbad / TooltipPanel.cs
Last active September 25, 2021 17:25
Simple Unity UI tooltip system (requires DoTween)
using DG.Tweening;
using TMPro;
using UnityEngine;
using UnityEngine.UI;
// Attach this component to a UI object which will be the tooltip visual
// Must include some text somewhere of course, and optionally a CanvasGroup if you want fading
public class TooltipPanel : MonoBehaviour {
[Tooltip("The text object which will display the tooltip string")]
public TextMeshProUGUI tooltipText;
sinbad / SpriteMeshRaycastFilter.cs
Last active May 11, 2023 05:35
SpriteMeshRaycastFilter: easy Unity UI non-rectangular click detector without reading textures
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
// Restrict raycasting to a sprite mesh shape
// Could use Image.alphaHitTestMinimumThreshold to mask but that requires read/write images which can't be packed
public class SpriteMeshRaycastFilter : MonoBehaviour, ICanvasRaycastFilter {
private RectTransform rectTransform;
sinbad / CombinedOverlapCollider.cs
Last active November 29, 2019 15:52
Quick hack to use a single shared array for results from multiple Unity OverlapCollider calls
// I always use the Unity collider calls which place results in a single pre-allocated array to avoid allocations.
// However it's a bit annoying that you can't make a call like `collider2D.OverlapCollider` and tell it to start
// inserting results at a non-zero index in that results array, in order to collect multiple tests in a single
// result array.
// Yes, you can (and should) use CompoundCollider2D if this is a single object you're tracking, but if it's not and
// you just want combined results from different colliders it's a ball-ache to not be able to get all results in a
// single array easily.
// This little snippet shunts results of earlier OverlapCollider calls to the end of the array temporarily,
private Dictionary<int, Action<Localisation.VariableSetter>> localisationVariableFuncs;
private void InitLocalisation() {
Localisation.Instance.DefaultVariableCallback = LocalisationVariableCallback;
localisationVariableFuncs = new Dictionary<int, Action<Localisation.VariableSetter>>{
{LocalisationConsts.Variables.ShotStyleBonusHash, setter => setter.SetValue(shotStyleBonuses)},
{LocalisationConsts.Variables.ShotPegScoreHash, setter => setter.SetValue(shotPegScore)}
// Iterate over all strings and pre-convert action tags to IDs so we only do this once
sinbad / License.txt
Last active May 29, 2024 08:30
Unity 2D Line Segment Intersection
This is free and unencumbered software released into the public domain.
Anyone is free to copy, modify, publish, use, compile, sell, or
distribute this software, either in source code form or as a compiled
binary, for any purpose, commercial or non-commercial, and by any
In jurisdictions that recognize copyright laws, the author or authors
of this software dedicate any and all copyright interest in the
software to the public domain. We make this dedication for the benefit