Skip to content

Instantly share code, notes, and snippets.

Yurii Selinnyi quizcanners

Block or report user

Report or block quizcanners

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View SimplePegiTemplate.cs
// Article:
using System.Collections.Generic;
using PlayerAndEditorGUI;
using UnityEditor;
public class SomeScript : MonoBehaviour: IPEGI {
quizcanners / ImageCropper.cs
Last active Apr 24, 2019
Image cropper for Unity. Doesn't change the texture, only allows to adjust rectangle. Works for a square Raw Image and any size of the texture.
View ImageCropper.cs
public RawImage img;
public float zoom = 1;
public float maxZoom = 2f;
public float scrollSpeed = 0.1f;
public float allignmentSpeed = 1f;
public Vector2 position = * 0.5f;
private Vector2 startPosition;
View GettingSmoothEdge.shader
inline float3 DetectSmoothEdge(float3 edge, float3 junkNorm, float3 sharpNorm, float3 edge0, float3 edge1, float3 edge2) {
edge = max(0, edge -0.965) * 28;
 float allof = edge.r + edge.g + edge.b;
float border = min(1, allof);
float3 edgeN = edge0*edge.r + edge1*edge.g + edge2*edge.b;
float junk = min(1, (edge.g*edge.b + edge.r*edge.b + edge.r*edge.g)*2);
return normalize((sharpNorm*(1- border)+ border*edgeN)*(1- junk) + junk*(junkNorm));
View SurfaceShaderCheatSheet.shader
// Transparency
alpha:fade // Means it is not a glass
Tags { "Queue" = "Transparent" "RenderType" = "Transparent" }
ZWrite Off
Blend SrcAlpha OneMinusSrcAlpha
// Adjusting strength of the Normal
o.Normal = UnpackNormal(bump0);
o.Normal.xy *= wet;
o.Normal.z = 1;
View InspectwithPEGIinitializer.cs
using PlayerAndEditorGUI;
using UnityEditor;
public class YourCoolClassDrawer : PEGI_Inspector<YourCoolClass> { }
public class YourCoolClass2BlaBlaBlaDrawer : PEGI_Inspector<YourCoolClass2BlaBlaBla> { }
View ComparisonWithPEGI.cs
public bool Inspect()
if ("Object's Transparency:".edit(ref transparency))
if (transparency != 0.5f && icon.Refresh.Click("Will load default value",25).nl())
transparency = 0.5f;
return false;
View ComparisonWithPEGI_NativeWay.cs
public override void OnInspectorGUI() {
var controller = (MyMaterialController )target;
controller .transparency = EditorGUILayout.FloatField("Object's Transparency:", controller .transparency);
View MatrixOperations.cs
View Matrix : camera.worldToCameraMatrix
// How to project a texture:
projectionMatrix = camera.projectionMatrix * camera.worldToCameraMatrix
View Shader Notes.cs
// All functions:
// Performance
// Accessing with "_Name" is slower
Shader.SetGlobalFloat("_Name", value); // =>
int id = Shader.PropertyToID("_Name"); // Once at Start/ OnEnable
Shader.SetGlobalFloat(id, value);
// Trouble-shooting:
// Black Pixels on some devices = Division by zero
quizcanners / Circle.shader
Last active Apr 25, 2019
Vert Frag Shader Template
View Circle.shader
// This is a starting point for most effects I make.
Shader "Playtime Painter/Effects/Circle" {
_MainTex("Albedo (RGB)", 2D) = "white" {}
[Toggle(_DEBUG)] debugOn("Debug", Float) = 0
You can’t perform that action at this time.