This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System.Collections; | |
using System.Collections.Generic; | |
using UnityEngine; | |
// a different way of generating random values that may "feel" better than true randomness | |
// every possible value will show up once, but in a random order | |
// it simply draws from the "bag" every time you get NextValue | |
// | |
// construct either with a list of values, or a size for the most common use | |
// list values like: new {1, 1, 2, 2, 3, 4}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// surface shader version of https://forum.unity.com/threads/gltfutility-a-simple-gltf-plugin.654319/page-4#post-6854009 | |
// how to enable transparency for surface shaders | |
// https://forum.unity.com/threads/transparency-with-standard-surface-shader.394551/ | |
// https://forum.unity.com/threads/simply-adding-alpha-fade-makes-my-shader-only-work-in-scene-view.546852/ | |
Shader "Custom/LitTransparentWithDepth" | |
{ | |
Properties | |
{ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// addresses https://forum.unity.com/threads/gltfutility-a-simple-gltf-plugin.654319/page-3#post-6041123 | |
// relevant documentation: | |
// https://docs.unity3d.com/Manual/SL-Blend.html | |
// https://docs.unity3d.com/Manual/SL-CullAndDepth.html | |
// https://forum.unity.com/threads/function-of-the-clip-command.93179/ | |
// clip() is basically the same as 'discard' https://learnopengl.com/Advanced-OpenGL/Blending | |
// https://answers.unity.com/questions/1242982/discard-pixels-from-fragment-shader-based-on-scree.html | |
// if you don't want 'float4 _MainTex_ST;' and TRANSFORM_TEX(v.uv, _MainTex); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// https://gamedev.stackexchange.com/questions/129116/how-to-create-a-boxcollider-which-surrounds-the-gameobject-and-all-of-his-child | |
private void AddColliderAroundChildren(GameObject assetModel) | |
{ | |
var pos = assetModel.transform.localPosition; | |
var rot = assetModel.transform.localRotation; | |
var scale = assetModel.transform.localScale; | |
// need to clear out transforms while encapsulating bounds | |
assetModel.transform.localPosition = Vector3.zero; | |
assetModel.transform.localRotation = Quaternion.identity; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// blur shader from https://stackoverflow.com/questions/29030321/unity3d-blur-the-background-of-a-ui-canvas | |
// added toggle https://forum.unity.com/threads/shader-properties-no-bool-support.157580/#post-3013337 | |
Shader "Custom/TintedUIBlur" { | |
Properties { | |
_Size("Blur", Range(0, 30)) = 3 | |
[HideInInspector] _MainTex("Masking Texture", 2D) = "white" {} | |
_AdditiveColor("Additive Tint color", Color) = (0, 0, 0, 0) | |
_MultiplyColor("Multiply Tint color", Color) = (1, 1, 1, 1) | |
[Toggle(MAKE_DESATURATED)] _MakeDesaturated ("Desaturate", Float) = 0 |