Skip to content

Instantly share code, notes, and snippets.

View pyjamads's full-sized avatar

pyjamads

View GitHub Profile
@pyjamads
pyjamads / ComponentPropertyDrawer.cs
Last active October 5, 2020 18:06
Component Selector Dropdown Property Drawer, how the component property drawer should always have been displayed.
[CustomPropertyDrawer(typeof(Component))]
public class ComponentPropertyDrawer : PropertyDrawer
{
public override void OnGUI(Rect position, SerializedProperty property, GUIContent label)
{
EditorGUILayout.BeginHorizontal();
var pos = new Rect(position);
pos.width = EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
pos.x = position.x + position.width - pos.width;
@pyjamads
pyjamads / AutoExpandGridLayoutGroup.cs
Last active December 29, 2022 10:07
A Unity UI Auto expanding grid layout group, that automatically changes column and row count - adapted from collin_patrick's AutoExpandGridLayoutGroup https://forum.unity.com/threads/solved-how-to-make-grid-layout-group-cell-size-x-auto-expand.448534/
namespace UnityEngine.UI
{
[AddComponentMenu("Layout/Auto Expand Grid Layout Group", 152)]
public class AutoExpandGridLayoutGroup : LayoutGroup
{
public enum Corner { UpperLeft = 0, UpperRight = 1, LowerLeft = 2, LowerRight = 3 }
public enum Axis { Horizontal = 0, Vertical = 1 }
public enum Constraint { Flexible = 0, FixedColumnCount = 1, FixedRowCount = 2 }
[SerializeField]