Skip to content

Instantly share code, notes, and snippets.

@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;
}
@koster
koster / PlayfabLeaderboardManager.cs
Last active June 7, 2024 09:39
Example implementation of a leaderboard manager using Playfab
using System.Collections;
using System.Collections.Generic;
using PlayFab;
using PlayFab.ClientModels;
using UnityEngine;
public class PlayfabLeaderboardManager : MonoBehaviour
{
private bool isConnected = false;
@koster
koster / MoveableSmoothDamp.cs
Last active June 7, 2024 09:12
Movement a la balatro
using UnityEngine;
public class MoveableSmoothDamp : MonoBehaviour
{
public Vector2 targetPosition;
private Vector2 velocity;
public float smoothTime = 0.3F;
public float maxVelocity = 10f;
private Vector2 currentVelocity;
@koster
koster / ScreenShake.cs
Last active June 7, 2024 09:38
Screen shake a la balatro (put this on your camera)
using UnityEngine;
public class ScreenShake : MonoBehaviour
{
public float screenShakeSetting = 8f;
private float shakeAmount;
private float originalShakeAmount;
private Vector3 originalPosition;
private Quaternion originalRotation;
@koster
koster / SineWaveTextAnimation.cs
Last active June 7, 2024 09:12
Animated text, makes text mesh pro do the sine wave!
using UnityEngine;
using TMPro;
public class SineWaveTextAnimation : MonoBehaviour
{
public TMP_Text textMesh;
public float frequency = 5.0f;
public float amplitude = 5.0f;
private TMP_TextInfo textInfo;
private bool[] animateCharFlags;