Skip to content

Instantly share code, notes, and snippets.

View ErnSur's full-sized avatar

Ernest Suryś ErnSur

View GitHub Profile
@ErnSur
ErnSur / UIElements.Scope.cs
Created July 8, 2019 20:19
Unity UI-Elements Scope implementation
namespace UnityEngine.UIElements
{
public class Scope : IDisposable
{
public static VisualElement CurrentRoot { get; private set; }
public readonly VisualElement root;
private VisualElement _previousRoot;
@ErnSur
ErnSur / SerializableInterfaceDrawer.cs
Last active May 16, 2020 11:10
[Unity] SerializedInterface 2020
[CustomPropertyDrawer(typeof(Object<>))]
public class SerializableInterfaceDrawer : PropertyDrawer
{
public override void OnGUI(Rect position, SerializedProperty property, GUIContent label)
{
var serializedValueProperty = property.FindPropertyRelative("serializedValue");
var interfaceType = fieldInfo.FieldType.GetGenericArguments()[0];
serializedValueProperty.objectReferenceValue =
@ErnSur
ErnSur / quickeyehub-manifest.json
Last active April 14, 2020 09:18
QuickEye Hub Manifest
{
"packages": [
{
"name": "Window Cloner",
"url": "https://github.com/ErnSur/WindowCloner.git"
},
{
"name": "Baking Tools",
"url": "https://github.com/ErnSur/BakingTools.git"
},
@ErnSur
ErnSur / LoopingInt.cs
Last active March 2, 2022 11:32
[C#] int struct that goes back to 0 when value equals max
/// <summary>
/// int struct that goes back to 0 when value equals max
/// and goes back to max when equals -1
/// </summary>
public struct LoopingInt
{
public int max;
private int _value;
@ErnSur
ErnSur / Dice.cs
Last active December 31, 2019 09:12
Random number generator with modifiable chance for each value
using UnityEngine;
using System.Linq;
public abstract class Dice
{
protected Side[] Sides { get; }
public Dice(Side[] sides)
{
Sides = sides;
@ErnSur
ErnSur / GetScenes.cs
Created July 7, 2020 13:58
Get Unity Build Scenes
public static string[] GetScenes() =>
(
from scene in EditorBuildSettings.scenes
where scene.enabled
select scene.path
).ToArray();
/(\d+)(?:\.(\d+)(?:\.(\d+))?)?(?:(\w)(?:(\d+))?)?/
using System;
using System.Collections;
using System.Collections.Generic;
using System.Text.RegularExpressions;
using UnityEditor;
namespace QuickEye.Editor
{
public class SerializedArrayProperty : IReadOnlyList<SerializedProperty>, IList
{
@ErnSur
ErnSur / CustomRectHandles.cs
Created August 27, 2021 06:31 — forked from yasirkula/CustomRectHandles.cs
Drawing Rect handles in Unity (similar to built-in Rect tool)
using System.Collections.Generic;
using System.Reflection;
using UnityEditor;
using UnityEngine;
using UnityEngine.Rendering;
public class CustomRectHandles : ScriptableObject
{
public class Rect3D
{
using System;
using UnityEditor;
using UnityEngine;
using System.IO;
using System.Linq;
using System.Diagnostics;
using Debug = UnityEngine.Debug;
// Modified version of https://github.com/karl-/unity-symlink-utility
// I added option to create symlinks in Pakcages folder