Skip to content

Instantly share code, notes, and snippets.

Avatar
💤
sleepy

LotteMakesStuff LotteMakesStuff

💤
sleepy
View GitHub Profile
@LotteMakesStuff
LotteMakesStuff / Flicker.cs
Created Jun 16, 2021
Quake/Halflife style light flicker
View Flicker.cs
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 Sep 7, 2022
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…
View NetworkingTools.cs
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 Aug 26, 2019
In Unity 2019.1 Unity added a new custom EditorTool API, heres some example code showing some tools we could make with it!
View PhysicsTool.cs
// 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 Jul 1, 2022
In Unity 2019.1 Unity added a new custom EditorTool API, heres some example code showing some tools we could make with it!
View LookatTool.cs
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 Jul 1, 2022
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
View LayoutUtils.cs
// 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 Jun 16, 2022
[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
View AutohookAttribute.cs
// NOTE DONT put in an editor folder!
using UnityEngine;
public class AutohookAttribute : PropertyAttribute
{
}
View NativeMesh.cs
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
a silly 14 segment vector font implementation that outputs text into a unity scene (in 2D) via Debug.DrawLine() calls.
View SegmentFont.cs
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 Aug 8, 2018
[NativeCollections] How to copy a regular .C# array into a NativeArray suuuuuper quick using memcpy. its about as fast as its ever gunna get!
View NativeMeshTest.cs
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 Jul 1, 2022
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
View PackageManagerExtentionExample.cs
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