Skip to content

Instantly share code, notes, and snippets.

View karljj1's full-sized avatar

Karl Jones karljj1

View GitHub Profile
@karljj1
karljj1 / EditorBootScene.cs
Created February 11, 2021 14:17
Initializes the localization settings before entering into a scene in play mode
using UnityEditor;
using UnityEditor.SceneManagement;
using UnityEngine.Localization.Settings;
using UnityEngine.SceneManagement;
[InitializeOnLoad]
public static class EditorBootScene
{
static EditorBootScene()
{
@karljj1
karljj1 / ChangePlayerLoop.cs
Created February 1, 2021 15:33
Change the particle system update so that LateUpdate is taken into account
using System.Linq;
using UnityEngine;
using UnityEngine.LowLevel;
using UnityEngine.PlayerLoop;
using static UnityEngine.PlayerLoop.PreLateUpdate;
public class ChangePlayerLoop : MonoBehaviour
{
public bool defaultLoop = true;
@karljj1
karljj1 / gist:fb2d61a9ea72c6cd9eff705220810d94
Created January 15, 2021 18:39
An example of how a UI Toolkit TextField Suggestion field could be created
using UnityEditor;
using UnityEngine;
using UnityEngine.UIElements;
public class TextEditorWindow : EditorWindow
{
VisualElement m_Suggestion;
TextField m_TextField;
[MenuItem("Test/Window")]
@karljj1
karljj1 / IMGUIWindow.cs
Created December 4, 2020 13:06
Animated IMGUI Background
using UnityEditor;
using UnityEditor.AnimatedValues;
using UnityEngine;
public class IMGUIWindow : EditorWindow
{
[MenuItem("Test/Window")]
static void ShowWn()
{
CreateWindow<IMGUIWindow>();
using UnityEditor.Localization;
using UnityEditor.Localization.Plugins.Google.Columns;
using UnityEngine.Localization;
using UnityEngine.Localization.Metadata;
using UnityEngine.Localization.Tables;
public class SmartStringColumn : LocaleMetadataColumn<SmartFormatTag>
{
public override PushFields PushFields => PushFields.Value;
/*
* Legacy Particle System Updater
* A tool that can be used to convert Legacy Particle Systems into new Particle System Components.
* https://forum.unity.com/threads/release-legacy-particle-system-updater.510879/
*
* v1.0
* Initial release
*
* v1.1
* Fixed incorrect billboard mode
@karljj1
karljj1 / SerializedPropertyExtensionMethods.cs
Last active September 25, 2022 21:11
Some useful extras when dealing with SerializedProperty
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Text.RegularExpressions;
using NUnit.Framework;
namespace UnityEditor.Localization
{
static class SerializedPropertyExtensionMethods
@karljj1
karljj1 / Display.RelativeMouseAt.cs
Created September 16, 2020 10:32
Emulate multiple display input using GameViews
Vector3 RelativeMouseAt()
{
var mouseOverWindow = EditorWindow.mouseOverWindow;
System.Reflection.Assembly assembly = typeof(UnityEditor.EditorWindow).Assembly;
Type type = assembly.GetType("UnityEditor.GameView");
int displayID = 0;
if (type.IsInstanceOfType(mouseOverWindow))
{
var displayField = type.GetField("m_TargetDisplay", BindingFlags.NonPublic | BindingFlags.Instance);
using UnityEngine;
using UnityEngine.LowLevel;
using UnityEngine.PlayerLoop;
public static class AddPlayerLoopCallback
{
// Add a callback to the PreUpdate phase
[RuntimeInitializeOnLoadMethod(RuntimeInitializeLoadType.BeforeSceneLoad)]
static void Setup()
{
using UnityEditor;
using UnityEngine.LowLevel;
using UnityEngine.UIElements;
public class ShowPlayerLoopWindow : EditorWindow
{
[MenuItem("Window/Player Loop")]
static void ShowWindow()
{
var wind = GetWindow<ShowPlayerLoopWindow>(false, "Player Loop");