Skip to content

Instantly share code, notes, and snippets.

@nomnomab
nomnomab / MaxLengthAttribute.cs
Created February 2, 2022 23:17
Constrains a string field's length
using UnityEngine;
#if UNITY_EDITOR
using UnityEditor;
#endif
public class MaxLengthAttribute : PropertyAttribute {
public readonly uint Length;
public MaxLengthAttribute(uint length) {
#nullable enable
#region Usings
using Unity.Burst;
using Unity.Collections;
using Unity.Entities;
using Unity.Jobs;
using Unity.Mathematics;
using Unity.Transforms;
using UnityEngine.InputSystem;
#endregion
@IronWarrior
IronWarrior / UnityProjectJunctionTool.cs
Last active March 14, 2024 01:35
Unity editor tool to create dummy Unity projects to allow a single project to be open in multiple editor instances.
// gist by Roystan (IronWarrior): https://gist.github.com/IronWarrior/005f649e443bf51b656729231d0b8af4
// Video demo: https://twitter.com/DavigoGame/status/1300842800964018178
//
// CONTRIBUTIONS:
// Mac and Linux support added by Creature Coding: https://creaturecoding.com/
//
// PURPOSE:
// Unity does not permit a project to be open in two different editor instances.
// This can be frustrating when building projects with multiplayer networking,
// as it would require you to create a build every time you wish you test your netcode.
@mzaks
mzaks / EntityExtensions.cs
Created July 22, 2019 07:45
Examples for Entity extensions
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static T GetComponentData<T>(this Entity entity, World world = null) where T: struct, IComponentData
{
if (world == null)
{
world = World.Active;
}
return world.EntityManager.GetComponentData<T>(entity);
}
@meain
meain / loading_messages.js
Last active April 27, 2024 09:54
Funny loading messages
export default [
"Reticulating splines...",
"Generating witty dialog...",
"Swapping time and space...",
"Spinning violently around the y-axis...",
"Tokenizing real life...",
"Bending the spoon...",
"Filtering morale...",
"Don't think of purple hippos...",
"We need a new fuse...",
@FreyaHolmer
FreyaHolmer / RigidbodyMassCalculator.cs
Created December 18, 2015 19:54
Used to approximate a proper mass value for all the colliders in a given Rigidbody
using UnityEngine;
using System.Linq;
[RequireComponent(typeof(Rigidbody))]
public class RigidbodyMassCalculator : MonoBehaviour {
public float density = 1f;
public bool recalculateOnAwake = true;
Rigidbody rb;