Skip to content

Instantly share code, notes, and snippets.

View chexpk's full-sized avatar
👋

Vladimir Belousov chexpk

👋
View GitHub Profile
@viruseg
viruseg / .Interaction in unity with Gradient via jobs + burst.cs
Last active March 11, 2025 03:02
Interaction in unity with Gradient via jobs + burst
Interaction in unity with Gradient via jobs + burst
var gradient = new Gradient();
//Access Gradient.colorKeys and Gradient.alphaKey via NativeArray without a Garbage Collector:
//Single threaded mode:
var gradientPtr = gradient.DirectAccess();
using var colorKeys = gradientPtr->GetColorKeys(Allocator.Temp);
using var alphaKeys = gradientPtr->GetAlphaKeys(Allocator.Temp);
@Rokobokode
Rokobokode / TweenExtensions.cs
Created February 11, 2020 20:37
Unity3D: DOTween: Tween As Task
public static class TweenExtensions
{
public static Task AsTask(this Tween tween, CancellationToken cancellationToken)
{
var taskCompletionSource = new TaskCompletionSource<bool>();
tween.OnComplete(() => { taskCompletionSource.TrySetResult(true); });
tween.OnKill(() => { taskCompletionSource.TrySetCanceled(); });
if (cancellationToken != CancellationToken.None)
@Srfigie
Srfigie / .gitattributes
Created February 2, 2020 14:30 — forked from nemotoo/.gitattributes
.gitattributes for Unity3D with git-lfs
## Unity ##
*.cs diff=csharp text
*.cginc text
*.shader text
*.mat merge=unityyamlmerge eol=lf
*.anim merge=unityyamlmerge eol=lf
*.unity merge=unityyamlmerge eol=lf
*.prefab merge=unityyamlmerge eol=lf
@Glavak
Glavak / CameraConstantWidth.cs
Last active March 15, 2025 01:34
Скрипт для поддержания постоянной ширины камеры в Unity, для туториала https://youtu.be/0cmxFjP375Y
using UnityEngine;
/// <summary>
/// Keeps constant camera width instead of height, works for both Orthographic & Perspective cameras
/// Made for tutorial https://youtu.be/0cmxFjP375Y
/// </summary>
public class CameraConstantWidth : MonoBehaviour
{
public Vector2 DefaultResolution = new Vector2(720, 1280);
[Range(0f, 1f)] public float WidthOrHeight = 0;
@bitinn
bitinn / .a-unity-git-config.md
Last active April 2, 2025 07:53
My Unity git config
@ditzel
ditzel / CameraEffects.cs
Last active October 1, 2023 08:12
Camera Shake Effect. Just put in on the camera and call Shake()
using UnityEngine;
namespace DitzeGames.Effects
{
/// <summary>
/// Camera Effects
/// </summary>
public class CameraEffects : MonoBehaviour
{
@IJEMIN
IJEMIN / .gitignore
Last active February 10, 2025 18:44
Unity + Rider gitignore
# Created by https://www.gitignore.io/api/unity
# Edit at https://www.gitignore.io/?templates=unity
# Jetbrain Rider Cache
.idea/
Assets/Plugins/Editor/JetBrains*
# Visual Studio Code
.vscode/
@oanhnn
oanhnn / using-multiple-github-accounts-with-ssh-keys.md
Last active October 31, 2025 17:04
Using multiple github accounts with ssh keys

Problem

I have two Github accounts: oanhnn (personal) and superman (for work). I want to use both accounts on same computer (without typing password everytime, when doing git push or pull).

Solution

Use ssh keys and define host aliases in ssh config file (each alias for an account).

How to?

  1. Generate ssh key pairs for accounts and add them to GitHub accounts.
@yuri-tikhomirov
yuri-tikhomirov / FastList.cs
Last active September 16, 2025 01:48
FastList<T> is a System.Collections.Generic.List<T> modification such, that allows to not produce garbage when using foreach.
/*
FastList<T> is a System.Collections.Generic.List<T> modification such, that allows to not produce garbage when using foreach.
Useful for old versions of c# runtime (like Mono 2.x), i.e. for Unity.
It implements own instance-type enumerator and caches only one instance of this enumerator inside.
Instance-type enumerator allows to avoid boxing that occurs when foreach converts IEnumerator to IDisposable and calls Dispose().
(Default List<T> enumerator is value-type (struct), so when foreach converts to IDisposable, boxing occurs and 20 bytes of garbage will be collected.)
Warnings: