Skip to content

Instantly share code, notes, and snippets.

@jbvrtx
jbvrtx / Extensions.cs
Last active June 12, 2023 14:32
Extensions for Scripting with Unity Editor
public static class Extensions
{
public static void RemoveComponent<T>(this GameObject gameObject) where T : UnityEngine.Component
{
GameObject.Destroy(gameObject.GetComponent<T>());
}
public static void ExecuteNextFrame(this MonoBehaviour monoBehaviour, DelayedFunction delayedFunction)
{
if (delayedFunction != null)
@jbvrtx
jbvrtx / StartupArguments.cs
Last active June 12, 2023 14:33
Read Commandline Arguments and Select Certain Scenes With Them in Unity Editor
public static class StartupArguments
{
// Constants
public const string ArgumentVR = "-vr";
// Properties
public static bool ContainVRMode => Arguments.Contains(ArgumentVR);
public static StartupScene[] ContainedScenes
=> StartupScenes.Where(scene => Arguments.Contains(scene.StartupParameterName)).ToArray();
@jbvrtx
jbvrtx / FrameTimeBudget.cs
Last active June 1, 2023 09:52
Profiling Tool for Unity that Finds Peaks in Frame Time Usage (Lags)
using System.Collections.Generic;
using System.Linq;
using UnityEngine;
public class FrameTimeBudget : MonoBehaviour
{
// Serialized Fields
[SerializeField]
[Tooltip("The target frame rate. This is used to calculate the available frame time.\n\n" +
"30 fps = 33.333 ms per frame\n60 fps = 16.666 ms per frame\n90 fps = 11.111 ms per frame")]
@jbvrtx
jbvrtx / ProgressLogger.cs
Last active June 12, 2023 14:34
Statically Create Logs of Completed Tasks in Unity Editor
using Newtonsoft.Json;
using System;
using System.Linq;
using System.Collections.Generic;
using System.IO;
using UnityEngine;
namespace Logging
{
public static class ProgressLogger
@jbvrtx
jbvrtx / ComponentBulkOperationBase.cs
Last active June 12, 2023 14:35
Basis for Editor Tools in Unity Editor. Accumulate Components in selected GameObjects to process them in bulk.
using System.Collections.Generic;
using System.Linq;
using UnityEditor;
using UnityEngine;
namespace TXL
{
/// <summary>
/// Editor script base class for collecting and processing Unity components based on a selection of GameObjects.
/// </summary>

Keybase proof

I hereby claim:

  • I am jbvrtx on github.
  • I am jannik_vrtx (https://keybase.io/jannik_vrtx) on keybase.
  • I have a public key ASAdZFGtYej_NGyee9pyW58bLQpL9awPYkc5F1sjwvzbAgo

To claim this, I am signing this object: