Skip to content

Instantly share code, notes, and snippets.

View spence-r's full-sized avatar
🦊
foxy

Spencer Rose spence-r

🦊
foxy
View GitHub Profile
@spence-r
spence-r / PropertyChangeTestActor.cpp
Created October 28, 2023 16:06
UE5 - (re)instantiating a child component in response to Blueprint property changes
#include "PropertyChangeTestActor.h"
APropertyChangeTestActor::APropertyChangeTestActor() {
PrimaryActorTick.bCanEverTick = false;
RootComp = CreateDefaultSubobject<USceneComponent>(TEXT("RootComponent"));
RootComp->SetMobility(EComponentMobility::Static);
SetRootComponent(RootComp);
// first-time init
@spence-r
spence-r / LocalCollectionReport.py
Last active January 16, 2024 10:08
Local collection report for Cities:Skylines assets
import json
import os
import re
import requests
import datetime
import sys
import webbrowser
from time import sleep
from random import uniform
from os.path import exists
@spence-r
spence-r / PickPlayersBot.py
Created July 26, 2022 19:09
Discord bot to select random players in the voice chat for playtesting
import os
import disnake
import random
from disnake.ext import commands
from dotenv import load_dotenv
# load bot token from environment variable file
load_dotenv()
TOKEN = os.getenv('DISCORD_TOKEN')
@spence-r
spence-r / animcontainsnotifyname.cpp
Created May 3, 2022 05:11
UE4 - check UAnimSequenceBase for the desired notify track name
bool AnimContainsNotifyName(FName Name, const UAnimSequenceBase* Anim)
{
// evaluate each track in the montage
for (FAnimNotifyTrack trk : Anim->AnimNotifyTracks)
{
// evaluate each notify within each track
for (FAnimNotifyEvent* evt : trk.Notifies)
{
// does this notify name match the in Name?
if (evt->NotifyName == Name)
@spence-r
spence-r / emptychannel.cpp
Last active May 3, 2022 05:14
UE4 - Check texture for empty channel
/**
* R/G/B/A channels of an image represented as enumeration.
*/
UENUM(BlueprintType)
enum class ETextureChannel : uint8
{
R UMETA(DisplayName = "Red"),
G UMETA(DisplayName = "Green"),
B UMETA(DisplayName = "Blue"),
A UMETA(DisplayName = "Alpha"),
@spence-r
spence-r / export_d.jsx
Last active January 5, 2022 03:22
Export a copy of the active Photoshop document as .png, with a suffix, into a subfolder with the document's name
// **************************************************************************************************
// saves a copy of the active document as png, with a given suffix, into a subfolder with the document's name
// example: file1.psd saved as copy to => /file1/file1_d.png
//
// to export other file types (eg, _a): copy the script and save as "export_a.jsx" or something similar
// then change the suffix on line 10 to equal the desired suffix (eg '_a' instead of '_d')
// **************************************************************************************************
// the suffix which gets appended to the file
var suffix = '_d';
@spence-r
spence-r / export_d.jsx
Created January 5, 2022 00:26
exports copy of the active Photoshop document with _d suffix
var suffix = '_d';
var filename = activeDocument.name.match(/(.*)\.[^\.]+$/)[1];
activeDocument.saveAs(File(activeDocument.fullName.parent + '/' + filename + suffix), new PNGSaveOptions(), true);
@spence-r
spence-r / replace_thumbs.ps1
Created July 26, 2020 00:31
Replaces Cities:Skylines tooltip and snapshot images
# copy the 'asset tooltip' (AssetStagingArea)
Set-Location "C:\users\spence\appdata\local\colossal order\cities_skylines\assetstagingarea\"
$destTTPath = Get-ChildItem -Recurse -Include asset_tooltip.png -Name
Copy-Item -path "G:\Dev\Skylines\! scripts\asset_tooltip.png" -Destination $destTTPath
# copy the 'snapshot' (overwrites most recent snap)
Set-Location "C:\Users\Spence\AppData\Local\Colossal Order\Cities_Skylines\Snapshots"
$destSnapPath = Get-ChildItem -Recurse -Include snapshot.png | sort LastWriteTime | select -last 1
Copy-Item -path "G:\Dev\Skylines\! scripts\snapshot.png" -Destination $destSnapPath
@spence-r
spence-r / RandomQuoteDisplay.cs
Created July 17, 2020 22:30
Displays random quote in Unity UI text component
using System.Collections.Generic;
using UnityEngine;
// Displays a random quote inside a UI text component.
[RequireComponent(typeof(UnityEngine.UI.Text))]
public class RandomQuoteDisplay : MonoBehaviour
{
[Multiline]
// the List of potential quotes to display
public List<string> Quotes = new List<string>()
@spence-r
spence-r / UnitySnippets.snippet
Created January 17, 2020 01:26
Unity Snippets
<?xml version="1.0" encoding="utf-8"?>
<CodeSnippets
xmlns="http://schemas.microsoft.com/VisualStudio/2005/CodeSnippet">
<CodeSnippet Format="1.0.0">
<Header>
<Title>FormerlySerializedAs</Title>
<Shortcut>fsa</Shortcut>
<SnippetTypes>
<SnippetType>Expansion</SnippetType>
</SnippetTypes>