Skip to content

Instantly share code, notes, and snippets.

@partlyhuman
partlyhuman / unity-find-usages.sh
Created January 9, 2018 02:28
Find all references to Unity object
#!/bin/bash
# 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 {} \;
@yagero
yagero / EventSystemManaged.cs
Created November 7, 2017 10:14
EventSystemManaged
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()
@unitycoder
unitycoder / Internal-GUITextureClipText.shader
Last active January 20, 2019 12:45
UpdateShaders in Editor
// Unity built-in shader source. Copyright (c) 2016 Unity Technologies. MIT license (see license.txt)
Shader "Hidden/Internal-GUITextureClipText"
{
Properties { _MainTex ("Texture", 2D) = "white" {} }
CGINCLUDE
#pragma vertex vert
#pragma fragment frag
@FabienDehopre
FabienDehopre / Identifier.cs
Last active January 27, 2021 08:23
Validate C# identifier name
using System;
using System.Linq;
using System.Text.RegularExpressions;
public static class IdentifierExtensions
{
// definition of a valid C# identifier: http://msdn.microsoft.com/en-us/library/aa664670(v=vs.71).aspx
private const string FORMATTING_CHARACTER = @"\p{Cf}";
private const string CONNECTING_CHARACTER = @"\p{Pc}";
private const string DECIMAL_DIGIT_CHARACTER = @"\p{Nd}";
Windows Registry Editor Version 5.00
[HKEY_CLASSES_ROOT\Folder\shell\Unity5]
@=""
"Icon"="%ProgramFiles%\\Unity\\Editor\\Unity.exe"
"MUIVerb"="Open as Unity Project"
[HKEY_CLASSES_ROOT\Folder\shell\Unity5\Command]
@="cmd /c start /D\"c:\\Program Files\\Unity\\Editor\\\" Unity.exe -projectPath \"%1\""
@majstudio
majstudio / Example.cs
Created January 26, 2018 04:50
Fancy Vector3 Range in Unity Inspector
using UnitEngine;
public class Example : MonoBehaviour
{
//As easy as this !
//You can adjust the slider limits in the inspector as well
public Vector3Range v3Range;
//...
@TarasOsiris
TarasOsiris / ShowToastUnityAndroid.cs
Created April 15, 2016 12:52
Shows toast on Android
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(
()=>
{
@QubitsDev
QubitsDev / ScrollRectAutoScroll.cs
Last active July 22, 2023 21:43
Unity3d ScrollRect Auto-Scroll, Dropdown Use: Places this component in the Template of Dropdown (with the ScrollRect component)
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.EventSystems;
using UnityEngine.UI;
[RequireComponent(typeof(ScrollRect))]
[AddComponentMenu("UI/ScrollRect Auto-Scroll")]
public class ScrollRectAutoScroll : MonoBehaviour, IPointerEnterHandler, IPointerExitHandler
{
public float scrollSpeed = 10f;
private bool mouseOver = false;
@nothke
nothke / Draw.cs
Last active January 20, 2024 06:58
///
/// 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
@EsProgram
EsProgram / SceneViewCamera.cs
Last active February 22, 2024 03:41
Unityのカメラ用スクリプト。Sceneビューのようなマウス操作でカメラを移動可能にする。
using UnityEngine;
/// <summary>
/// GameビューにてSceneビューのようなカメラの動きをマウス操作によって実現する
/// </summary>
[RequireComponent(typeof(Camera))]
public class SceneViewCamera : MonoBehaviour
{
[SerializeField, Range(0.1f, 10f)]
private float wheelSpeed = 1f;