Skip to content

Instantly share code, notes, and snippets.

View xavierarpa's full-sized avatar
😎
Breaking Rules

Xavier Arpa xavierarpa

😎
Breaking Rules
View GitHub Profile
using System;
public sealed class BehaviorSubject<TValue>
{
private TValue lastValue;
public Action<TValue> action = default;
public Action actionVoid = default;
public BehaviorSubject( TValue initValue = default )
{
lastValue = initValue;
}
@xavierarpa
xavierarpa / ListEnum.cs
Created November 19, 2022 12:27
Enumerate a List<Enum,T>. Useful to inspector
using System;
using System.Linq;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using XavHelpTo;
using XavHelpTo.Get;
using XavHelpTo.Set;
using XavHelpTo.Know;
using System;
using UnityEngine;
using XavHelpTo.Set;
[Serializable]
public struct SmoothTransition
{
#region Variables
public const float MIN_RANGE = .1f;
public const float MAX_RANGE = 10f;
@xavierarpa
xavierarpa / PackageCreator.cs
Last active May 27, 2024 06:35
Folder to package.tgz
#if UNITY_EDITOR
using System.IO;
using UnityEditor;
using UnityEditor.PackageManager;
using UnityEditor.PackageManager.Requests;
public static class PackageCreator
{
public static void CreateTgzPackage(string packagePath, string sourcePath)
{
PackRequest packRequest = Client.Pack(sourcePath, packagePath);
@xavierarpa
xavierarpa / unity-generate-uml.yml
Last active September 13, 2023 02:34
C# to UML Diagram
name: Generate UML
on:
push:
branches:
- master
workflow_dispatch:
jobs:
generate-uml:
name: 'Generate UML'
Shader "Custom/GradientWave2" {
Properties {
_MainTex ("Texture", 2D) = "white" {}
_ColorStart ("Start Color", Color) = (1, 1, 1, 1)
_ColorEnd ("End Color", Color) = (0, 0, 0, 1)
_Speed ("Speed", Range(0, 10)) = 1
_WaveSpeedH ("Wave Speed Horizontal", Range(-10, 10)) = 0.5
_WaveSpeedV ("Wave Speed Vertical", Range(-10, 10)) = 0.5
_WaveAmountH ("Wave Amount Horizontal", Range(0, 1)) = 0.1
_WaveAmountV ("Wave Amount Vertical", Range(0, 1)) = 0.1
Shader "Custom/UI Gradient" {
Properties {
_MainTex ("Texture", 2D) = "white" {}
_GradientDirection ("Gradient Direction", Range(0, 360)) = 0
_Color1 ("Color 1", Color) = (1,1,1,1)
_Color2 ("Color 2", Color) = (0,0,0,1)
}
SubShader {
Tags { "Queue"="Transparent" "RenderType"="Transparent" }
// c# companion script
// SpriteUVToShader.cs -------------------------------------------------------------------------------------------------------------------------------- //
// Save you your project, add to your SpriteRenderer gameObject
using UnityEngine;
using System.Collections;
using System.Collections.Generic;
[ExecuteInEditMode]
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using System.Threading.Tasks;
public static class AsyncExtensorUtils
{
public static IEnumerator ToCoroutine(this Task _task)
{
while (!_task.IsCompleted) yield return null;
@xavierarpa
xavierarpa / AsyncExtensorUtils.cs
Created October 20, 2023 08:34
change Task to Coroutine and to Task
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using System.Threading.Tasks;
public static class AsyncExtensorUtils
{
public static IEnumerator ToCoroutine(this Task _task)
{
while (!_task.IsCompleted) yield return null;