Skip to content

Instantly share code, notes, and snippets.

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
public class RaycastInverter : Mask
{
public override bool IsRaycastLocationValid(Vector2 sp, Camera eventCamera)
{
return !base.IsRaycastLocationValid(sp, eventCamera);
@koster
koster / LocSystem.cs
Created August 1, 2024 20:06
Silly loc system lol.
using System.Collections.Generic;
using System;
using System.Collections.Generic;
using System.Reflection;
public class LocString
{
public string en;
public string ru;
@koster
koster / CMSEntity.cs
Created June 28, 2024 14:46
A snippet from my ECS-like system.
public class CMSEntity
{
public string id;
public List<CMSComponentDefinition> components = new List<CMSComponentDefinition>() { new AnythingTag() };
public T Define<T>() where T : CMSComponentDefinition, new()
{
var t = Get<T>();
using UnityEngine;
public class ScrollUVVFX : MonoBehaviour
{
public Vector2 speed;
private Material materialToScroll;
private Vector2 uvOffset;
void Start()
{
Shader "Custom/SpriteScrollShaderWithColor" {
Properties {
_MainTex ("Texture", 2D) = "white" {}
_UVOffset ("UV Offset", Vector) = (0,0,0,0)
_Color ("Color", Color) = (1,1,1,1)
}
SubShader {
Tags { "Queue"="Transparent" "RenderType"="Transparent" }
LOD 100
@koster
koster / ListPool.cs
Last active June 19, 2024 15:18
Use this to stop allocating lists, stop allocs now❌❌❌❌❌❌❌ (Unity)
using System.Collections.Generic;
public static class ListPool<T>
{
const int InitialPoolSize = 32;
static List<List<T>> pool = new List<List<T>>(InitialPoolSize);
public static List<T> Request(int minSize = 32)
{
@koster
koster / RoundedCornersGradientShader.shader
Last active June 13, 2024 15:08
Create material, apply to ui image, tweak corner radius etc
Shader "Custom/RoundedCornersGradientShader"
{
Properties
{
_MainTex ("Texture", 2D) = "white" {}
_ColorTop ("Top Color", Color) = (1,1,1,1)
_ColorBottom ("Bottom Color", Color) = (1,1,1,1)
_CornerRadius ("Corner Radius", Range(0, 0.5)) = 0.1
}
SubShader
@koster
koster / CardSetAlign.cs
Last active June 7, 2024 09:38
A component that aligns stuff in a straight line, pretty straightforward. Put this on a transform and add children to it, adjust width.
using UnityEngine;
[ExecuteInEditMode]
public class CardSetAlign : MonoBehaviour
{
public float width = 1f;
void Update()
{
var count = transform.childCount;
@koster
koster / PlayfabSaveManager.cs
Last active June 7, 2024 09:37
Example implementation of a player save manager using Playfab.
using System;
using System.Collections.Generic;
using UnityEngine;
using PlayFab;
using PlayFab.ClientModels;
public class PlayFabManager : MonoBehaviour
{
private const string PlayFabTitleId = "YOUR_PLAYFAB_TITLE_ID"; // Замените на ваш Title ID
private string backupSaveData;
@koster
koster / SFX.cs
Last active June 7, 2024 09:13
Super basic SFX system.
using System;
using UnityEngine;
using Random = UnityEngine.Random;
[Serializable]
public class SFXData
{
public AudioClip clip;
public float vol = 1f;
}