Skip to content

Instantly share code, notes, and snippets.

@HajiyevEl
HajiyevEl / VertBend.cs
Created August 13, 2023 09:00 — forked from MattRix/VertBend.cs
Example of doing a vertex modifer for Unity UI stuff
using UnityEngine.UI;
using System.Collections.Generic;
using System;
using UnityEngine;
public class VertBend : BaseMeshEffect
{
public override void ModifyMesh(VertexHelper vh)
{
if(!IsActive()) return;
@HajiyevEl
HajiyevEl / UnityAsyncOperationAwaiter.cs
Created August 13, 2023 09:00 — forked from mattyellen/UnityAsyncOperationAwaiter.cs
Allows the use of async/await (instead of yield) with any Unity AsyncOperation
public static class ExtensionMethods
{
public static TaskAwaiter GetAwaiter(this AsyncOperation asyncOp)
{
var tcs = new TaskCompletionSource<object>();
asyncOp.completed += obj => { tcs.SetResult(null); };
return ((Task)tcs.Task).GetAwaiter();
}
}
Shader "Name" {
Properties {
_Name ("display name", Range (min, max)) = number
_Name ("display name", Float) = number
_Name ("display name", Int) = number
_Name ("display name", Color) = (number,number,number,number)
_Name ("display name", Vector) = (number,number,number,number)
@HajiyevEl
HajiyevEl / BlurImage.shader
Created July 24, 2023 09:44 — forked from nilpunch/BlurImage.shader
Blur for UI elements. Compatible with Built in RP, HDRP, URP and SRP.
Shader "UI/BlurImage"
{
Properties
{
[PerRendererData] _MainTex ("Sprite Texture", 2D) = "white" {}
_Color ("Tint", Color) = (1,1,1,1)
[Space(50)]
_BlurX ("X Blur", Range(0.0, 0.5)) = 0.001
_BlurY ("Y Blur", Range(0.0, 0.5)) = 0.001
@HajiyevEl
HajiyevEl / SafeTask.cs
Created July 9, 2023 12:28 — forked from marcospgp/SafeTask.cs
Cancel async tasks in Unity upon exiting play mode
using System;
using System.Threading;
using System.Threading.Tasks;
namespace MarcosPereira.UnityUtilities {
/// <summary>
/// A replacement for `Task.Run()` that cancels tasks when exiting play
/// mode, which Unity doesn't do by default.
/// Also registers a UnobservedTaskException handler to prevent exceptions
/// from being swallowed in both Tasks and SafeTasks, when these are
@HajiyevEl
HajiyevEl / CubemapTextureBuilder.cs
Created December 6, 2022 21:32 — forked from RemyUnity/CubemapTextureBuilder.cs
Unity utility to convert 6 texture to a single cubemap texture
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEditor;
using System.Linq;
using System.IO;
public class CubemapTextureBuilder : EditorWindow
{
[MenuItem("Tools/Cubemap Builder")]
@HajiyevEl
HajiyevEl / SkinnedMeshObjectPreviewExample.cs
Created October 7, 2022 10:07 — forked from radiatoryang/SkinnedMeshObjectPreviewExample.cs
An example of a custom ObjectPreview rendering out a SkinnedMesh for Unity Editor C#... I used it for facial expressions and blendshape editing, you might want to use it for something else. I hereby place it under MIT License. Full write-up here: http://www.blog.radiator.debacle.us/2016/06/working-with-custom-objectpreviews-and.html
using UnityEngine;
using UnityEditor;
using System;
using System.Collections;
[CustomPreview(typeof(YourCustomScriptableObject))] // THIS IS VERY IMPORTANT, this is so the editor knows what this is supposed to be previewing at all
public class SkinnedMeshObjectPreviewExample : ObjectPreview {
PreviewRenderUtility m_PreviewUtility;
@HajiyevEl
HajiyevEl / SkinnedMeshCombiner.cs
Created October 7, 2022 10:06 — forked from radiatoryang/SkinnedMeshCombiner.cs
example code for combining SkinnedMeshRenderers at runtime (for optimization reasons usually), which I use in my games for Mixamo Fuse models specifically... PLEASE DON'T ASK ME FOR HELP WITH THIS, this is more for learning purposes, and it's not really an easy-to-use Asset Store thing? also I have a lot of weird hacks specific for my uses... ag…
// this code is under MIT License, by Robert Yang + others (credits in comments)
// a lot of this is based on http://wiki.unity3d.com/index.php?title=SkinnedMeshCombiner
// but I removed the atlasing stuff because I don't need it
using UnityEngine;
using System.Collections;
using System.Collections.Generic;
using System.Linq;