Skip to content

Instantly share code, notes, and snippets.

Avatar
🐤

Süleyman Yasir KULA yasirkula

🐤
View GitHub Profile
@yasirkula
yasirkula / FileDownloader.cs
Last active January 14, 2023 10:59
C# Download Public File From Google Drive™ (works for large files as well)
View FileDownloader.cs
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.IO;
using System.Net;
using System.Text;
/* EXAMPLE USAGE
FileDownloader fileDownloader = new FileDownloader();
@yasirkula
yasirkula / EditorCollapseAll.cs
Last active November 7, 2022 07:52
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.
View EditorCollapseAll.cs
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 / 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.
View TimeManager.cs
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 / 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.
View DeviceOrientationManager.cs
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 / CircleGraphic.cs
Last active October 17, 2022 02:23
Create circles/ellipses in Unity UI system in one of three modes: FillInside, FillOutside and Edge.
View CircleGraphic.cs
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 / GradientGraphic.cs
Last active December 24, 2022 10:31
Create 4-color gradient UI graphics in Unity
View GradientGraphic.cs
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.Sprites;
using UnityEngine.UI;
#if UNITY_2017_4 || UNITY_2018_2_OR_NEWER
using UnityEngine.U2D;
#endif
using Sprites = UnityEngine.Sprites;
#if UNITY_EDITOR
@yasirkula
yasirkula / HorizontalCamera.cs
Last active November 22, 2022 22:33
A script to fix the horizontal FOV/orthographic size of a camera to a specified value in Unity
View HorizontalCamera.cs
using UnityEngine;
[ExecuteInEditMode]
[RequireComponent( typeof( Camera ) )]
public class HorizontalCamera : MonoBehaviour
{
private Camera m_camera;
private float lastAspect;
#pragma warning disable 0649
@yasirkula
yasirkula / SimpleArchive.cs
Created May 22, 2019 12:24
Tar-like archive in pure C# (.NET 2.0 compatible)
View SimpleArchive.cs
using System;
using System.Collections.Generic;
using System.IO;
using System.Text;
namespace SimplePatchToolCore
{
public class SimpleArchive
{
// Archive Structure
@yasirkula
yasirkula / content.js
Last active November 28, 2022 18:29
Restore fullscreen button on embedded YouTube videos (Chrome Extension)
View content.js
var checkDocument = function( doc )
{
var frames = doc.getElementsByTagName( "iframe" );
for( var i = 0, l = frames.length; i < l; i++ )
checkIframe( frames[i] );
};
var checkIframe = function(iframe)
{
if( iframe.src.indexOf( "https://www.youtube" ) == 0 )
@yasirkula
yasirkula / PluginJARExtractor.cs
Last active March 2, 2021 14:42
Automatically extract classes.jar file from Android Studio's .aar archive in Unity (for native Android plugin developers)
View PluginJARExtractor.cs
// Uses ZipStorer (c) 2016 Jaime Olivares [v3.4.0; August 4, 2017] (MIT-License: https://github.com/jaime-olivares/zipstorer/blob/master/LICENSE.md)
using System.Collections.Generic;
using System.Text;
using System;
using System.IO;
using System.IO.Compression;
using UnityEditor;
using UnityEngine;