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
using Unity.Entities;
using Unity.Rendering;
// https://answers.unity.com/questions/1695108/boneindexoffset-error-with-usdz-model-and-ecs.html
[UpdateInGroup(typeof(InitializationSystemGroup))]
public class BugFixCopySkinnedEntityData : SystemBase
{
/* Suppresses the error: "ArgumentException: A component with type:BoneIndexOffset
* has not been added to the entity.", until the Unity bug is fixed. */
[Test, TestCategory(TestCategory.Integrity)]
public void EnqueuesToCorrectThread([Values(1, 10, 100)] int jobCount, [Values(1, 2, 10)] int numPerThread)
{
var threadIds = new NativeArray<int>(jobCount, Allocator.TempJob);
var threadUsages = new NativeArray<int>(JobsUtility.MaxJobThreadCount, Allocator.TempJob);
var (baseQueue, componentQueue, bufferQueue) = new QueueRig<EcsTestData, EcsIntElement>(Allocator.TempJob);
try
{
var handle = IJobParallelForExtensions.Schedule(new EnqueuesToCorrectThreadJob
using System;
using System.Collections.Generic;
using Unity.Collections;
using Unity.Collections.LowLevel.Unsafe;
using Unity.Entities;
namespace Assets.Scripts.Providers
{
public interface INativeProvider
{
@jeffvella
jeffvella / SharedStaticTests.cs
Created April 6, 2020 16:36
An example of storing data in SharedStatic.
namespace SomeTests
{
public class SharedStaticTests : SimpleTestFixture
{
public unsafe static class MyData
{
private static readonly SharedStatic<Container> SharedData;
private class Key { }
public class Test1 : SystemBase
{
protected override void OnUpdate()
{
var someCDFE = GetComponentDataFromEntity<Translation>();
int externalVal = 2;
Entities.ForEach((Entity e) =>
{
var a = someCDFE[e];
if (externalVal == 2)
using Assets.Scripts.Components;
using Assets.Scripts.Components.Events;
using Unity.Collections;
using Unity.Entities;
using Unity.Mathematics;
using Unity.Transforms;
using Vella.Events;
namespace Assets.Scripts.Systems
{
https://gist.githubusercontent.com/jeffvella/fc9e674b7edd02e8a343929256087764/raw/cc85a155b32df303500f00f798eeb786431d0eb6/gistfile1.txt
protected override void OnUpdate()
{
var collisionEvents = _collisionEvents;
var detectors = _buffer;
detectors.Clear();
Entities.ForEach((Entity entity, ref CollisionDetector detector, in Translation pos, in OwnerRef owner) =>
{
detectors.Add(new DetectorInfo
{
using NUnit.Framework;
using System;
using System.Diagnostics;
using System.Linq;
using Unity.Collections;
using Unity.Entities;
using Unity.PerformanceTesting;
namespace Packages.com.vella.events.Tests
{
using NUnit.Framework;
using System;
using System.Diagnostics;
using System.Linq;
using Unity.Collections;
using Unity.Entities;
using Unity.PerformanceTesting;
namespace Packages.com.vella.events.Tests
{