Skip to content

Instantly share code, notes, and snippets.

View sim2kid's full-sized avatar

Owen Ravelo sim2kid

View GitHub Profile
@sim2kid
sim2kid / Photon Fusion 2 FieldAccessException.md
Created July 25, 2024 21:10
FieldAccessException in Photon Fusion 2

Issue

When running in Photon Fusion 2, you may run into an error similar to below:

FieldAccessException: Field `Fusion.NetworkBehaviour:Ptr` is inaccessible from method `METHOD_NAME`

This seemingly seems to be that Fusion is not allowing Networked Objects from accessing their own networked properties.

Solution

This error occurs if the "Allow 'unsafe' Code" option is unchecked in PlayerSettings. When enabled, the error will stop occuring.

@sim2kid
sim2kid / DeleteLocalBranchesPowershellGit.ps1
Created May 20, 2024 17:48
Deletes all local branches for a given git repo. This must be executed in the repo's root folder to work. Very useful for cleaning your local branches.
git branch | %{ $_.Trim() } | ?{ $_ -ne 'master' } | ?{ $_ -ne 'main'} | ?{ $_ -ne 'develop'} | %{ git branch -D $_ }
@sim2kid
sim2kid / HorizontalToVertical.bat
Last active October 6, 2022 22:06
Converts videos from "Original" folder into vertical variants and puts them in "Edited". Works only for 16:9 ratio. Requires FFMPEG.
FOR %%a IN (Original/*.mp4) DO ffmpeg -i ".\Original\%%a" -vf "split[original][copy];[copy]scale=-1:ih*(16/9)*(16/9),crop=w=ih*9/16,gblur=sigma=20[blurred];[blurred][original]overlay=(main_w-overlay_w)/2:(main_h-overlay_h)/2" ".\Edited\%%~na.mp4"
pause
@sim2kid
sim2kid / TrackTrigger.cs
Last active April 5, 2022 07:29
A tool used to make sure TriggerExit is reliably called for a MonoBehavior. This will ensure when a collider is disabled, your exit events still happens outside of it.
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using System.Linq;
/// <summary>
/// A tool used to make sure TriggerExit is reliably called for a MonoBehavior. This will ensure when a collider is disabled, your exit events still happens outside of it.
/// Just hook in the AddTrigger, FixedUpdate, and RemoveTrigger to your OnTriggerEnter, FixedUpdate, and OnTriggerExit to get started.
/// </summary>
public class TrackTrigger
@sim2kid
sim2kid / Unity Stadia Controller Input.md
Last active October 21, 2024 19:48
Google Stadia Controller Support in Unity's New Input System (1.2+) With full button mapping. Haptics not supported. You should be able to drag and drop this in your project for Stadia controller support

Unity Stadia Controller Input

This gist has been moved to a repo for better maintainability. Please visit sim2kid/UnityStadiaController for package details and installation.

About

This package adds definition for the Google Stadia Controller to Unity's Input System allowing for the use of a Stadia Controller natively with Unity.

@sim2kid
sim2kid / SetVersion.cs
Last active November 20, 2021 13:42
Set Unity Version to GitHub Tag + Number of Commits. Keep this in an editor only folder. Shit+b to enduce in editor. Should run often enough to keep your build up-to-date
using UnityEngine;
using UnityEditor;
using UnityEditor.Build;
using UnityEditor.Build.Reporting;
using System.Diagnostics;
using System.Text;
using System.IO;
// Will run the script whenever the editor loads
[InitializeOnLoad]
public class SetVersion: IPreprocessBuildWithReport
@sim2kid
sim2kid / ConvertWavToMp3.bat
Last active November 18, 2021 02:00
Converts all wav files in a directory (and sub directory) to MP3 files. This is a destructive process. (Requires FFMPEG)
@echo off
call :treeProcess
goto :eof
:treeProcess
for %%F in (*.wav) DO (
ffmpeg -i "%%F" "%%~nF.mp3"
DEL %%F
@sim2kid
sim2kid / TwoSidedCutOut.shader
Created November 12, 2021 19:08
Two Sided Cutout Shader Unity
Shader "Transparent/TwoSidedCutOut"
{
Properties
{
_Color("Main Color", Color) = (1,1,1,1)
_MainTex("Base (RGB) Trans (A)", 2D) = "white" {}
_Cutoff("Alpha cutoff", Range(0,1)) = 0.5
}
SubShader