Skip to content

Instantly share code, notes, and snippets.

View LotteMakesStuff's full-sized avatar
💤
sleepy

LotteMakesStuff LotteMakesStuff

💤
sleepy
View GitHub Profile
@LotteMakesStuff
LotteMakesStuff / Flicker.cs
Created June 16, 2021 04:49
Quake/Halflife style light flicker
using UnityEngine;
public class Flicker : MonoBehaviour
{
public string LightStyle = "mmamammmmammamamaaamammma";
private Light light;
public float loopTime = 2f;
[SerializeField]
private int currentIndex = 0;
@LotteMakesStuff
LotteMakesStuff / NetworkingTools.cs
Last active April 28, 2023 09:49
Since Unity 2018.3 we've had this cool new tool called [SettingsProvider] that we can use to add custom settings menu into Unitys settings screens. This short example shows how i use [SettingsProvider] and some [MenuItems] to help build and run test clients when im developing a multiplayer game. My usecase is that i want a quick way to build and…
using System.Collections.Generic;
using System.Diagnostics;
using UnityEditor;
using UnityEditor.Build.Reporting;
using UnityEngine;
using Debug = UnityEngine.Debug;
public static class NetworkingTools
{
@LotteMakesStuff
LotteMakesStuff / PhysicsTool.cs
Created August 26, 2019 01:23
In Unity 2019.1 Unity added a new custom EditorTool API, heres some example code showing some tools we could make with it!
// Put me in an editor folder!
using System.Collections;
using System.Collections.Generic;
using System.Runtime.InteropServices;
using UnityEditor;
using UnityEditor.EditorTools;
using UnityEngine;
[EditorTool("PhysicsDrop Tool", typeof(Rigidbody))]
public class PhysicsTool : EditorTool
@LotteMakesStuff
LotteMakesStuff / LookatTool.cs
Last active November 2, 2023 21:04
In Unity 2019.1 Unity added a new custom EditorTool API, heres some example code showing some tools we could make with it!
using UnityEditor;
using UnityEditor.EditorTools;
using UnityEngine;
[EditorTool("LookAt Tool")]
public class LookatTool : EditorTool
{
GUIContent cachedIcon;
// NOTE: as were caching this, unity will serialize it between compiles! so if we want to test out new looks,
@LotteMakesStuff
LotteMakesStuff / LayoutUtils.cs
Last active November 2, 2023 21:04
Simple tool for importing editor layout files (.wlt files) from the asset folder. this is cool cos you can then share layouts with your team via source control
// put me in an Editor folder
using System.IO;
using UnityEditor;
using UnityEditorInternal;
using UnityEngine;
public static class LayoutUtils
{
// unity stores layouts in a path referenced in WindowLayout.LayoutsPreferencesPath.
// Unfortunately, thats internal - well just creat the path in the same way they do!
@LotteMakesStuff
LotteMakesStuff / AutohookAttribute.cs
Last active January 2, 2024 13:54
[Autohook] property drawer for unity - Add this [Autohook] attribute to a property to and the inspector will automagically hook up a valid reference for you if it can find a component attached to the same game object that matches the field you put it on. You can watch a demo of this in action here https://youtu.be/faVt09NGzws <3
// NOTE DONT put in an editor folder!
using UnityEngine;
public class AutohookAttribute : PropertyAttribute
{
}
using System;
using Unity.Collections;
using Unity.Collections.LowLevel.Unsafe;
using Unity.Mathematics;
using UnityEngine;
public class NativeMesh : IDisposable
{
public NativeArray<float3> VertexBuffer;
public NativeArray<float3> NormalBuffer;
@LotteMakesStuff
LotteMakesStuff / SegmentFont.cs
Last active May 20, 2022 10:21
a silly 14 segment vector font implementation that outputs text into a unity scene (in 2D) via Debug.DrawLine() calls.
using System.Collections;
using System.Collections.Generic;
using System.Threading;
using UnityEngine;
// Usage Example
// position message string color fontsize
// SegmentFont.Print(new Vector2(0,0), "Message you wanna print", Color.green, 0.2f);
@LotteMakesStuff
LotteMakesStuff / NativeMeshTest.cs
Created August 8, 2018 00:30
[NativeCollections] How to copy a regular .C# array into a NativeArray suuuuuper quick using memcpy. its about as fast as its ever gunna get!
using Unity.Collections;
using Unity.Collections.LowLevel.Unsafe;
using Unity.Mathematics;
using UnityEngine;
public class NativeMeshTest : MonoBehaviour
{
private NativeArray<float3> vertexBuffer;
private Vector3[] vertexArray;
@LotteMakesStuff
LotteMakesStuff / PackageManagerExtentionExample.cs
Last active September 4, 2023 02:25
As of v1.9.3, Unity has added a simple extention API to the PackageManager UI. This small example shows you how to implment it and add a new window to the package manager. Note: you will need to change to the Staging package repository as time of writing. This code needs to go in an Editor folder
using System.Linq;
using UnityEditor;
using UnityEditor.PackageManager.UI;
using UnityEngine;
using UnityEngine.Experimental.UIElements;
using UnityEngine.Experimental.UIElements.StyleEnums;
using PackageInfo = UnityEditor.PackageManager.PackageInfo;
[InitializeOnLoad]
public class PackageManagerExtentionExample : IPackageManagerExtension