Simple tu use and foolproof. It uses abstraction to make it almost invisible on your code and easy to reuse it.
| // Original shader by @bgolus, modified slightly by @alexanderameye for URP, modified slightly more | |
| // by @gravitonpunch for ECS/DOTS/HybridRenderer. | |
| // https://twitter.com/bgolus | |
| // https://medium.com/@bgolus/the-quest-for-very-wide-outlines-ba82ed442cd9 | |
| // https://alexanderameye.github.io/ | |
| // https://twitter.com/alexanderameye/status/1332286868222775298 | |
| Shader "Hidden/Outline" | |
| { | |
| Properties |
| // Original shader by @bgolus, modified slightly by @alexanderameye for URP, modified slightly more | |
| // by @gravitonpunch for ECS/DOTS/HybridRenderer. | |
| // https://twitter.com/bgolus | |
| // https://medium.com/@bgolus/the-quest-for-very-wide-outlines-ba82ed442cd9 | |
| // https://alexanderameye.github.io/ | |
| // https://twitter.com/alexanderameye/status/1332286868222775298 | |
| Shader "Hidden/Outline" | |
| { | |
| Properties |
| using System.Collections.Generic; | |
| /// <summary> | |
| /// A simple static class to get and set globally accessible variables through a key-value approach. | |
| /// </summary> | |
| /// <remarks> | |
| /// <para>Uses a key-value approach (dictionary) for storing and modifying variables.</para> | |
| /// <para>It also uses a lock to ensure consistency between the threads.</para> | |
| /// </remarks> | |
| public static class GlobalVariables |
| /* Credit */ | |
| // Inspired by grimmdev's code - https://gist.github.com/grimmdev/979877fcdc943267e44c | |
| /* Dependency */ | |
| // Import SimpleJSON Scripts : http://wiki.unity3d.com/index.php/SimpleJSON | |
| // You can use your own JSON Parser if you want. | |
| /* Limitations */ | |
| // translate.googleapis.com is free, but it only allows about 100 requests per one hour. | |
| // After that, you will receive 429 error response. |
| Shader "Custom/UIBlur" | |
| { | |
| Properties | |
| { | |
| [Toggle(IS_BLUR_ALPHA_MASKED)] _IsAlphaMasked("Image Alpha Masks Blur", Float) = 1 | |
| [Toggle(IS_SPRITE_VISIBLE)] _IsSpriteVisible("Show Image", Float) = 1 | |
| // Internally enforced by MAX_RADIUS | |
| _Radius("Blur Radius", Range(0, 64)) = 1 |
| IEnumerator Shake() { | |
| float elapsed = 0.0f; | |
| Vector3 originalCamPos = Camera.main.transform.position; | |
| while (elapsed < duration) { | |
| elapsed += Time.deltaTime; | |
| using UnityEngine; | |
| public static class RendererArrayExtension | |
| { | |
| public static Bounds ComputeBounds(this Renderer[] renderers) | |
| { | |
| Bounds bounds = new Bounds(); | |
| for (int ir = 0; ir < renderers.Length; ir++) | |
| { | |
| Renderer renderer = renderers[ir]; |