Skip to content

Instantly share code, notes, and snippets.

View jeffvella's full-sized avatar
🏠
Working from home

Jeffrey Vella jeffvella

🏠
Working from home
  • Montréal, Canada
View GitHub Profile
@jeffvella
jeffvella / ExtendedScriptableObjectDrawer.cs
Created September 7, 2024 22:24 — forked from tomkail/ExtendedScriptableObjectDrawer.cs
Displays the fields of a ScriptableObject in the inspector
// Developed by Tom Kail at Inkle
// Released under the MIT Licence as held at https://opensource.org/licenses/MIT
// Must be placed within a folder named "Editor"
using System;
using System.Reflection;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEditor;
@jeffvella
jeffvella / ReorderableList.cs
Created March 24, 2021 22:58 — forked from EddieCameron/ReorderableList.cs
ReorderableList Property Drawer
using System;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
/// In Unity pre 2020, each different type you want to make a list from needs its own subclass, like UnityEvents.
/// eg :
/// [Serializable] public class IntReorderableList : ReorderableList<int> {}
[Serializable]
@jeffvella
jeffvella / DynamicBufferTestSystem.cs
Created August 21, 2020 23:52
DynamicBufferTestSystem
public class DynamicBufferTestSystem : SystemBase
{
private EntityQuery _query;
private Entity _entity;
protected override void OnCreate()
{
_query = GetEntityQuery(ComponentType.ReadWrite<MyBufferData>());
_entity = EntityManager.CreateEntity(ComponentType.ReadWrite<MyBufferData>());
EntityManager.GetBuffer<MyBufferData>(_entity).Add(default);
@jeffvella
jeffvella / BurstLogger.cs
Last active November 1, 2023 18:38
BurstLogger
// MIT LICENSE Copyright (c) 2020 Jeffrey Vella
// https://gist.github.com/jeffvella/dee1a82bd5edfcdc9d3067d8c038f95c/edit
using Unity.Burst;
using Unity.Collections;
using Unity.Collections.LowLevel.Unsafe;
using Unity.Entities;
using Unity.Jobs.LowLevel.Unsafe;
using UnityEngine;
using Unity.Mathematics;
namespace Unity.Collections
{
public static class SpatialIndexingUtility
public struct MovementData
{
public float SomethingRelevent;
}
[StructLayout(LayoutKind.Explicit)]
public unsafe struct Movement : IComponentData,IMovementBehavior
{
public enum MovementType : int
{
@jeffvella
jeffvella / GridUtility.cs
Created May 5, 2020 14:07
Model for burst function use.
internal struct GridUtility
{
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static unsafe void SetFlags(int* flagsPtr, int length, ref NodeFlags addFlags)
{
var flagToSet = (int4)(int)addFlags;
var batchFlags = (int4*)flagsPtr;
// array length must be 4x aligned for overrun on last batch
var batchLen = length / 4 + math.select(1, 0, length % 4 != 0);
@jeffvella
jeffvella / AddressablesLoader.cs
Last active April 29, 2024 16:55
Loader script for caching addressables to load syncronously.
using System;
using System.Collections.Generic;
using Unity.Collections.LowLevel.Unsafe;
using UnityEngine;
using UnityEngine.AddressableAssets;
using UnityEngine.ResourceManagement.AsyncOperations;
using UnityEngine.ResourceManagement.ResourceLocations;
using Object = UnityEngine.Object;
public class AddressableLabels
using System;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.AddressableAssets;
using UnityEngine.ResourceManagement.AsyncOperations;
using UnityEngine.ResourceManagement.ResourceLocations;
using UnityEngine.ResourceManagement.ResourceProviders;
using Object = UnityEngine.Object;
@jeffvella
jeffvella / SelectionHandler1.cs
Last active May 2, 2020 23:35
Observe the scene selection rect events without taking over the event with .Use()/HotControl
public static class SelectionHandler<T> where T : IHandleSelectable, IEquatable<T>
{
private static int _selectionHandleHash = nameof(SelectionHandler<T>).GetHashCode();
public static bool IsSelecting { get; private set; }
public static Vector2 StartPosition { get; private set; }
public static Vector2 CurrentPosition{ get; private set; }
public static HashSet<T> Selections { get; } = new HashSet<T>();
public delegate void SelectionEvent();