Skip to content

Instantly share code, notes, and snippets.

View AGeorgy's full-sized avatar

George Ananchenko AGeorgy

View GitHub Profile
@Anthelmed
Anthelmed / WorldSpaceUIDocument.cs
Last active April 5, 2025 18:19
Until Unity decide to make it official, this is a custom WorldSpaceUIDocument component. Code is under the MIT license: https://github.com/git/git-scm.com/blob/main/MIT-LICENSE.txt
using UnityEngine;
using UnityEngine.EventSystems;
using UnityEngine.Rendering;
using UnityEngine.UIElements;
#if ENABLE_INPUT_SYSTEM
using UnityEngine.InputSystem.UI;
#endif
#if UNITY_EDITOR
using UnityEditor;
@andrew-raphael-lukasik
andrew-raphael-lukasik / simd.cs
Last active December 13, 2022 11:10
my thoughts on simd and Burst
using Unity.Collections;
using Unity.Jobs;
using Unity.Mathematics;
using BurstCompile = Unity.Burst.BurstCompileAttribute;
[BurstCompile] public unsafe struct NoSimd : IJob
{
public float a, b;
public float* c;
void IJob.Execute () { *c = a * b; }
@andrew-raphael-lukasik
andrew-raphael-lukasik / .LetsCubeMarch.cs.md
Last active September 28, 2023 18:51
multi-threaded cube marching where geometry is sourced from a mesh asset template (artist-friendly)

4re4y77i96o6kjerewarezarhea323ef2

// src: https://gist.github.com/andrew-raphael-lukasik/bc05310efcb1bcb2875a376494414f36
using Unity.Collections;
using Unity.Collections.LowLevel.Unsafe;
public interface INativeMinHeapComparer<I,V>
where I : unmanaged
where V : unmanaged
{
int Compare ( I lhs , I rhs , NativeSlice<V> comparables );
}
// src: https://gist.github.com/andrew-raphael-lukasik/709c19dd2305a2d1a0fa32ee82717b5c
using Unity.Collections;
public unsafe struct NativeStack <T> : System.IDisposable
where T : unmanaged
{
NativeList<T> _list;
public bool IsCreated => _list.IsCreated;
public int Length => _list.Length;
@yasirkula
yasirkula / WavyImage.cs
Last active April 21, 2025 04:26
Create UI image with wave animation in Unity
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.Sprites;
using UnityEngine.UI;
#if UNITY_2017_4 || UNITY_2018_2_OR_NEWER
using UnityEngine.U2D;
#endif
#if UNITY_EDITOR
using UnityEditor;
@yasirkula
yasirkula / ScrollViewFocusFunctions.cs
Created October 23, 2021 10:09
Focus/center Scroll View to the specified point/item in Unity
using System.Collections;
using UnityEngine;
using UnityEngine.UI;
public static class ScrollViewFocusFunctions
{
public static Vector2 CalculateFocusedScrollPosition( this ScrollRect scrollView, Vector2 focusPoint )
{
Vector2 contentSize = scrollView.content.rect.size;
Vector2 viewportSize = ( (RectTransform) scrollView.content.parent ).rect.size;
@totallyRonja
totallyRonja / MaterialGradientDrawer.cs
Last active March 31, 2025 13:38
A Material Property Drawer for the [Gradient] attribute which lets you edit gradients and adds them to the shader as textures. More information here: https://twitter.com/totallyRonja/status/1368704187580682240
using System;
using System.Collections.Generic;
using System.Linq;
using UnityEditor;
using UnityEngine;
using Object = UnityEngine.Object;
public class MaterialGradientDrawer : MaterialPropertyDrawer {
private int resolution;
using System.Collections.Generic;
using UnityEngine;
public static class ObjectPreviewer
{
struct Node
{
public Matrix4x4 transform;
public Mesh mesh;
public Material[] mats;
@sabresaurus
sabresaurus / HierarchyEmptyObjectDisplay.cs
Created December 3, 2020 12:20
Shows empty game objects in the hierarchy
// MIT License
//
// Copyright (c) 2020 Sabresaurus
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions: