Skip to content

Instantly share code, notes, and snippets.


baba_s baba-s

View GitHub Profile
View Internal-GUITextureClipText.shader
// Unity built-in shader source. Copyright (c) 2016 Unity Technologies. MIT license (see license.txt)
Shader "Hidden/Internal-GUITextureClipText"
Properties { _MainTex ("Texture", 2D) = "white" {} }
#pragma vertex vert
#pragma fragment frag
majstudio / Example.cs
Created Jan 26, 2018
Fancy Vector3 Range in Unity Inspector
View Example.cs
using UnitEngine;
public class Example : MonoBehaviour
//As easy as this !
//You can adjust the slider limits in the inspector as well
public Vector3Range v3Range;
partlyhuman /
Created Jan 9, 2018
Find all references to Unity object
# usage: send path of an asset in. the script will find the GUID from the associated meta file, and look for usages of this GUID anywhere.
# of course only works with text mode (YAML) serialization
GUID=$(grep -Po '(?<=guid: )\w+' $1.meta)
echo "Object has GUID $GUID"
echo "Searching for instances..."
find . \( -name "*.asset" -o -name "*.prefab" -o -name "*.unity" \) -exec grep -l $GUID {} \;
View EventSystemManaged.cs
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.EventSystems;
public class EventSystemManaged : EventSystem
static Stack<EventSystem> ms_PrevEventSystem = new Stack<EventSystem>();
static bool ms_Forced = false;
protected override void OnEnable()
QubitsDev / ScrollRectAutoScroll.cs
Last active Aug 16, 2021
Unity3d ScrollRect Auto-Scroll, Dropdown Use: Places this component in the Template of Dropdown (with the ScrollRect component)
View ScrollRectAutoScroll.cs
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.EventSystems;
using UnityEngine.UI;
[AddComponentMenu("UI/ScrollRect Auto-Scroll")]
public class ScrollRectAutoScroll : MonoBehaviour, IPointerEnterHandler, IPointerExitHandler
public float scrollSpeed = 10f;
private bool mouseOver = false;
View Sprites-PixelArt.shader
Basic Sprite Shader for aligning pixel art to the same grid, based on the Unity Sprite Shader.
Create one Material where you assign the same Pixels Per Unit value you use on your imported Sprites,
then reuse this Material on all appropriate Sprite Renderers.
(You can use Shader.SetGlobalFloat to set that Pixels Per Unit value for all your shaders:
This is not for scaled or rotated artwork. If you need those features, look at low res render textures.
Use this however you want.
View Draw.cs
/// Draw lines at runtime
/// by Nothke
/// unlicensed, aka do whatever you want with it
/// made during Stugan 2016 :)
/// ..(it's midnight, and Robbie clicks A LOT, LOUDLY!)
/// Important:
/// - Should be called in OnPostRender() (after everything else has been drawn)
/// therefore the script that calls it must be attached to the camera
View ShowToastUnityAndroid.cs
public static void ShowToast(string text)
if (Application.platform == RuntimePlatform.Android)
AndroidJavaClass unityPlayer = new AndroidJavaClass("com.unity3d.player.UnityPlayer");
AndroidJavaObject activity = unityPlayer.GetStatic<AndroidJavaObject>("currentActivity");
activity.Call("runOnUiThread", new AndroidJavaRunnable(
MattRix / UnityEditorIcons.txt
Last active Oct 5, 2021
A list of all the built-in EdtiorGUI icons in Unity. Use EditorGUIUtility.IconContent([icon name]) to access them.
View UnityEditorIcons.txt
ScriptableObject Icon
EsProgram / SceneViewCamera.cs
Last active Aug 23, 2021
View SceneViewCamera.cs
using UnityEngine;
/// <summary>
/// GameビューにてSceneビューのようなカメラの動きをマウス操作によって実現する
/// </summary>
public class SceneViewCamera : MonoBehaviour
[SerializeField, Range(0.1f, 10f)]
private float wheelSpeed = 1f;