Skip to content

Instantly share code, notes, and snippets.

@yasirkula
yasirkula / CircleGraphic.cs
Last active March 2, 2025 21:47
Create circles/ellipses in Unity UI system in one of three modes: FillInside, FillOutside and Edge.
using UnityEngine;
using UnityEngine.UI;
#if UNITY_EDITOR
using UnityEditor;
// Custom Editor to order the variables in the Inspector similar to Image component
[CustomEditor( typeof( CircleGraphic ) ), CanEditMultipleObjects]
public class CircleGraphicEditor : Editor
{
@yasirkula
yasirkula / DeviceOrientationManager.cs
Created February 8, 2018 22:14
Easily enable/disable auto screen orientation in Unity and receive callback upon orientation change. See the comments section below for instructions.
using UnityEngine;
public class DeviceOrientationManager : MonoBehaviour
{
private const float ORIENTATION_CHECK_INTERVAL = 0.5f;
private float nextOrientationCheckTime;
private static ScreenOrientation m_currentOrientation;
public static ScreenOrientation CurrentOrientation
@yasirkula
yasirkula / TimeManager.cs
Created February 8, 2018 22:12
Easily handle pause requests from multiple sources and receive callbacks upon pause/unpause and time scale changes in Unity. See the comments section below for instructions.
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.SceneManagement;
public static class TimeManager
{
private static List<object> pauseHolders = new List<object>();
public static event System.Action<bool> OnPauseStateChanged = null;
public static event System.Action<float> OnTimeScaleChanged = null;
@yasirkula
yasirkula / EditorCollapseAll.cs
Last active October 24, 2024 06:17
An editor script for Unity 3D to collapse all GameObject's in Hierarchy view or to collapse all folders in Project view. See the comments section below for instructions.
using System.Collections.Generic;
using System.Reflection;
using UnityEditor;
using UnityEditor.IMGUI.Controls;
using UnityEditorInternal;
using UnityEngine.SceneManagement;
public static class EditorCollapseAll
{
private const BindingFlags INSTANCE_FLAGS = BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance;
@yasirkula
yasirkula / FileDownloader.cs
Last active April 16, 2025 03:33
C# Download Public File From Google Drive™ (works for large files as well)
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.IO;
using System.Net;
using System.Text;
/* EXAMPLE USAGE
FileDownloader fileDownloader = new FileDownloader();