Skip to content

Instantly share code, notes, and snippets.

View benui-dev's full-sized avatar
🌱

benui benui-dev

🌱
View GitHub Profile
@benui-dev
benui-dev / IsOverUIElement.h
Created October 27, 2021 17:19
Hacky way to see if the cursor is over a UI element. Useful for detecting whether to do raycasts into the world or not.
static const FString RootName = "SGameLayerManager";
bool IsOverUIElement()
{
FVector2D CursorPos = FSlateApplication::Get().GetCursorPos();
FWidgetPath WidgetPath = FSlateApplication::Get().LocateWindowUnderMouse( CursorPos, FSlateApplication::Get().GetInteractiveTopLevelWindows() );
if ( WidgetPath.IsValid() )
{
const FArrangedChildren::FArrangedWidgetArray& AllArrangedWidgets = WidgetPath.Widgets.GetInternalArray();
@benui-dev
benui-dev / PackagePlugin.bat
Last active March 29, 2024 04:30
Unreal Engine Package Plugin batch script. Confirm that your plugin packages under each Unreal Engine version.
@echo off
SETLOCAL
rem Set your plugin name, should match the .uplugin filename
set PLUGIN_NAME=BYGYouTrackFiller
rem Always add trailing space please
rem Don't put trailing slashes
set UNREAL_PATHS=E:\UE_4.25 ^
E:\UE_4.26 ^
@benui-dev
benui-dev / Outliner.cs
Created January 24, 2015 19:50
Take a flat 2d poly mesh and return a mesh with MeshTopology.Lines of the outline. Good for text!
using UnityEngine;
using System.Collections;
using System.Collections.Generic;
public class Outliner : BaseBehaviour
{
void Awake()
{
GetComponent<MeshFilter>().mesh
= FindOutlinePairs(GetComponent<MeshFilter>().mesh);
@benui-dev
benui-dev / NormalEditor.cs
Created December 29, 2014 12:33
Show and edit mesh normals in Unity
using UnityEngine;
using System.Collections;
[ExecuteInEditMode]
public class NormalEditor : BaseBehaviour
{
Mesh m_mesh;
public Mesh Mesh { get { return m_mesh; } }
[SerializeField]
@benui-dev
benui-dev / ErrorReporter.cs
Created May 12, 2014 15:18
Hacky error reporter for Unity. Takes a screenshot and uploads it with system information to your server. Almost certainly super insecure.
using UnityEngine;
using System.Collections;
using System.Text;
public class ErrorReporter
{
static string m_postUrl = "http://www.yoursite.com/reports/report.cgi";
static string m_reportUrl = "http://www.yoursite.com/reports/";
// Take screenshot
@benui-dev
benui-dev / CoroutineSyncer.cs
Created March 11, 2014 05:28
Helper singleton for running multiple coroutines simultaneously, and then waiting for all of them to finish.
using UnityEngine;
using System.Collections;
using System.Collections.Generic;
public class CoroutineSyncer : MonoBehaviour
{
static CoroutineSyncer m_instance;
public static CoroutineSyncer Instance
{
get
@benui-dev
benui-dev / gist:6111355
Created July 30, 2013 08:51
Unity C# snippets for Vim Snipmate
snippet find
GameObject.Find("${1}")${2}
snippet gc
GetComponent<${1}>()
snippet ac
AddComponent<${1}>()
snippet sar
SetActiveRecursively(${1:true})
snippet rc
[RequireComponent (typeof(${1:AudioSource}))]
@benui-dev
benui-dev / OrderTester.cs
Created May 17, 2013 06:29
Unity order tester. Comment out lines you don't care about. Update etc. will be especially noisy.
using UnityEngine;
using System.Collections;
public class OrderTester : MonoBehaviour {
void Update() { Debug.Log("Update()"); }
void LateUpdate() { Debug.Log("LateUpdate()"); }
void FixedUpdate() { Debug.Log("FixedUpdate()"); }
void Awake() { Debug.Log("Awake()"); }
void Start() { Debug.Log("Start()"); }
void Reset() { Debug.Log("Reset()"); }
@benui-dev
benui-dev / spritebatch.lua
Created September 12, 2012 00:57
How to use Löve2d's SpriteBatch
function love.load()
-- Load our image we want to draw many times
image = love.graphics.newImage("dirt.png")
-- The number of tiles we want to draw is pretty much the number
-- that will fit on the screen
maxX = math.ceil(love.graphics.getWidth() / image:getWidth()) + 2
maxY = math.ceil(love.graphics.getHeight() / image:getHeight()) + 2
local size = maxX * maxY
print(size)
@benui-dev
benui-dev / init.lua
Created July 8, 2012 00:20
Example of subclassing physics objects from Löve2d's Hardoncollider, using Class-Commons. Requires HardonCollider to work.
-- Add this line to the main hardoncollider/init.lua file around line 136
-- to allow you to add preconstructed shapes.
function HC:addExistingShape(shape)
return new_shape(self, shape)
end