This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Developed by Tom Kail at Inkle | |
// Released under the MIT Licence as held at https://opensource.org/licenses/MIT | |
// Must be placed within a folder named "Editor" | |
using System; | |
using System.Reflection; | |
using System.Collections; | |
using System.Collections.Generic; | |
using UnityEngine; | |
using UnityEditor; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using UnityEngine; | |
using System; | |
using System.Reflection; | |
using System.Text.RegularExpressions; | |
[AttributeUsage (AttributeTargets.Field,Inherited = true)] | |
public class ReadOnlyAttribute : PropertyAttribute {} | |
#if UNITY_EDITOR | |
[UnityEditor.CustomPropertyDrawer (typeof(ReadOnlyAttribute))] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System.Linq; | |
using UnityEditor; | |
using UnityEngine; | |
[InitializeOnLoad] | |
public class CustomHierarchy : MonoBehaviour | |
{ | |
private static Vector2 offset = new Vector2(0, 2); | |
static CustomHierarchy() |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public static class UrlDownloader | |
{ | |
public static void DownloadText(string url, Action<string> callback); | |
} | |
// Brute force way of doing it | |
IEnumerator MyAsyncFunction() | |
{ | |
var done = false; | |
var result = default(string); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using UnityEditor; | |
using UnityEditor.Build; | |
using UnityEditor.Build.Reporting; | |
using UnityEngine; | |
[InitializeOnLoad] | |
class VersionIncrementor : IPreprocessBuildWithReport | |
{ | |
public int callbackOrder => 0; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using UnityEngine; | |
using UnityEngine.UI; | |
public static class ScrollRectExtensions | |
{ | |
/// <summary> | |
/// Tell the Scroll Rect View to snap to the given element (top). | |
/// </summary> | |
public static void SnapTo( | |
this ScrollRect scrollRect, |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
static public class ObjectExtensions | |
{ | |
static public T DeepClone<T>(this T a) | |
{ | |
using (MemoryStream stream = new MemoryStream()) | |
{ | |
BinaryFormatter formatter = new BinaryFormatter(); | |
formatter.Serialize(stream, a); | |
stream.Position = 0; | |
return (T)formatter.Deserialize(stream); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using static UnityEngine.TouchPhase; | |
using UnityEngine; | |
public class TwoFingersObjectRotation : MonoBehaviour | |
{ | |
[SerializeField] | |
private Transform _target; | |
private Vector2 _startPosition; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
static class TouchHelper | |
{ | |
// OG version: https://www.reddit.com/r/Unity3D/comments/6o9zsy/comment/dkgxa1i/?utm_source=share&utm_medium=web2x&context=3 | |
public static bool IsOverUI() | |
{ | |
PointerEventData pointerData = new PointerEventData(EventSystem.current); | |
pointerData.position = Input.mousePosition; | |
List<RaycastResult> results = new List<RaycastResult>(); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
void Main() | |
{ | |
string foo = "Hello"; | |
// a.then(f).then(g).then(j) | |
foo.Then(x => x.Trim().Ret()) | |
.Then(x => x.Substring(0, 5).Ret()) | |
.Then(x => x.Length.Ret()) |
OlderNewer