Skip to content

Instantly share code, notes, and snippets.

@Jura-Z
Jura-Z / Burst2ManagedCall.cs
Last active June 17, 2023 18:05
Burst -> Managed C# call
internal static class Burst2ManagedCall<T, Key>
{
private static T s_Delegate;
// alignment 16 is important to not crash on arm cpu
private static readonly SharedStatic<FunctionPointer<T>> s_SharedStatic = SharedStatic<FunctionPointer<T>>.GetOrCreate<FunctionPointer<T>, Key>(16);
public static bool IsCreated => s_SharedStatic.Data.IsCreated;
public static void Init(T @delegate)
{
CheckIsNotCreated();
@Jura-Z
Jura-Z / 81-C# Script-NewBehaviourScript.cs.txt
Created January 8, 2022 22:17
81-C# Script-NewBehaviourScript.cs.txt
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using UnityEngine;
using Debug = UnityEngine.Debug;
//[RequireComponent(typeof(Collider))]
public class #SCRIPTNAME# : MonoBehaviour
{
//[SerializeField] private Collider m_Collider;
using System.Collections;
using NUnit.Framework;
using Unity.Burst;
using Unity.Collections;
using Unity.Jobs;
using Unity.Mathematics;
using UnityEngine;
using UnityEngine.TestTools;
namespace BurstHexasphere.Tests
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using Newtonsoft.Json.Linq;
namespace Table
{
[DebuggerDisplay("{name} | {local_score} | #{id}")]
//IndexOutOfRangeException: Index 2 is out of range of '2' Length.
//Unity.Collections.NativeArray`1[T].FailOutOfRangeError (System.Int32 index) (at /Users/builduser/buildslave/unity/build/Runtime/Export/NativeArray/NativeArray.cs:255)
//Unity.Collections.NativeArray`1[T].CheckElementReadAccess (System.Int32 index) (at /Users/builduser/buildslave/unity/build/Runtime/Export/NativeArray/NativeArray.cs:115)
//Unity.Collections.NativeArray`1[T].get_Item (System.Int32 index) (at /Users/builduser/buildslave/unity/build/Runtime/Export/NativeArray/NativeArray.cs:140)
//Unity.Transforms.TRSToLocalToWorldSystem+TRSToLocalToWorld.Execute (Unity.Entities.ArchetypeChunk chunk, System.Int32 chunkIndex, System.Int32 entityOffset) (at Packages/com.unity.entities/Unity.Transforms/TRSToLocalToWorldSystem.cs:95)
//Unity.Entities.JobChunkExtensions+JobChunk_Process`1[T].ExecuteInternal (Unity.Entities.JobChunkExtensions+JobChunkData`1[T]& jobData, Unity.Jobs.LowLevel.Unsafe.JobRanges& ranges, System.Int32 jobIndex) (at Packages/
@Jura-Z
Jura-Z / iota.d
Created December 29, 2018 07:23
Pythagorean Triples, iota/ranges
import std.stdio;
import std.range;
import std.typecons;
import std.algorithm;
import std.concurrency : Generator, yield;
import core.time;
alias Triple = Tuple!(int, "x", int, "y", int, "z");
void main()
@Jura-Z
Jura-Z / foreach.d
Created December 29, 2018 07:20
Pythagorean Triples, foreach
import std.stdio;
import std.range;
import std.typecons;
import std.algorithm;
import std.concurrency : Generator, yield;
import core.time;
alias Triple = Tuple!(int, "x", int, "y", int, "z");
void main()