Skip to content

Instantly share code, notes, and snippets.

@andrew-raphael-lukasik
andrew-raphael-lukasik / .write_to_managed_array_from_Burst-compiled_IJob.md
Last active September 15, 2024 06:29
Write to managed arrays from an `IJob` ! A collections of useful utilities when working with `Unity.Jobs`.

👉write to managed array from a Burst-compiled IJob

Highlights:

  • cast T[] to NativeArray<T>
  • schedule jobs that read/write to managed arrays
  • pointer safety assertion that prevent crashes and data corruption

more info in the first comment under the source code

@karljj1
karljj1 / ObjectChangeEventsExample.cs
Last active November 6, 2024 10:39
Example of how to use ObjectChangeEvents in Unity
using System.Text;
using UnityEditor;
using UnityEngine;
[InitializeOnLoad]
public class ObjectChangeEventsExample
{
static ObjectChangeEventsExample()
{
ObjectChangeEvents.changesPublished += ChangesPublished;
@andrew-raphael-lukasik
andrew-raphael-lukasik / Mem.cs
Last active November 29, 2022 23:24
MemCpy between unmanaged and managed arrays
// src* https://gist.github.com/andrew-raphael-lukasik/b5cd9eb0c6f36388069d3211554409de
using UnityEngine;
using Unity.Collections;
using Unity.Collections.LowLevel.Unsafe;
// Project Settings/Player/Other Settings/Script Compilation/Allow `Unsafe` Code = ☑
public static class Mem
{
public static unsafe bool Cpy<SRC, DST>(NativeArray<SRC> src, DST[] dst)
@AlexMerzlikin
AlexMerzlikin / UniversalRenderPipelineTemplateWithDotsInstancing.shader
Last active November 7, 2024 09:33
Template unlit URP shader that supports DOTS instancing to use as a guide to create shaders for BatchRendererGroup since BRG only works with DOTS instancing compatible shaders. Unfortunately, the official docs about it haven't helped me that much, and I thought others might face the same issues.
Shader "Universal Render Pipeline/Custom/UnlitWithDotsInstancing"
{
Properties
{
_BaseMap ("Base Texture", 2D) = "white" {}
_BaseColor ("Base Colour", Color) = (1, 1, 1, 1)
}
SubShader
{
@scooterpsu
scooterpsu / config.ps1
Last active December 30, 2022 04:36
Gotify client for Windows Notifications
$domain = "p.domain.com"
$token = "AAAAAAAA"
$useHeaders = $false
@forcepusher
forcepusher / Program.cs
Last active May 14, 2023 13:41
Unity "void Main" OOP template
using System.Diagnostics;
using System.Threading.Tasks;
using UnityEngine;
using UnityEngine.SceneManagement;
namespace BananaParty.FurryGame.Client
{
/// <summary>
/// Entry point for wiring up the engine and executing main loop.
/// </summary>
@codebykyle
codebykyle / connect.ps1
Last active October 14, 2024 19:04
Windows Terminal Split Pane Powershell Script - v2
using namespace System.Collections.Generic
# Encapsulate an arbitrary command
class PaneCommand {
[string]$Command
PaneCommand() {
$this.Command = "";
}
@dylan2intel
dylan2intel / README.md
Last active December 30, 2021 04:31
WSL2 Cisco AnyConnect VPN Client Networking Connection Issue Workaround

How to use the above files?

Step 1: Copy files updateInterfaceMetric.ps1, updateDns.ps1, autodns.sh to your Windows path %HOMEPATH%\WSL2\scripts, if not exists, create this folder.

Step 2: Win+R Run taskschd.msc will open "Task Schedulder" application, import two tasks with files UpdateInterfaceMetric.xml, updateDns.xml one by one.

@unitycoder
unitycoder / UnityForumBoardSearchHelper.js
Last active June 15, 2023 16:52
Unity Forum Search : AutoSelect current board item inside Search select list (based on referrer url)
// ==UserScript==
// @name Unity Forum Search : AutoSelect current board item inside Search select list (based on referrer url)
// @namespace https://unitycoder.com
// @version 1
// @include https://forum.unity.com/search/?type=post
// @grant none
// ==/UserScript==
// more info https://unitycoder.com/blog/2021/05/26/unity-forums-auto-select-current-subforum-in-search-greasemonkey-script/
// get referring board url
@OscarAbraham
OscarAbraham / PlainDataInstancer.cs
Last active March 18, 2024 15:58
PlainDataInstancer ScriptableObject for Unity, so you can create deep clones of data stored in SO assets at runtime without the overhead of ScriptableObject copies.
using System.Collections.Generic;
using UnityEngine;
// TData should be a plain class or struct with the [System.Serializable] attribute.
// TData can implement ISerializationCallbackReceiver if needed for more advanced uses.
public class PlainDataInstancer<TData> : ScriptableObject
{
private static bool s_DataTypeValidated;
[SerializeField] private TData m_PrototypeData;