Skip to content

Instantly share code, notes, and snippets.

View pinkas's full-sized avatar

Benoit Pinkasfeld pinkas

  • Sydney, Australia
View GitHub Profile
@pinkas
pinkas / Traverse.cs
Last active February 12, 2022 11:57
Recursive free way to traverse through ALL the child game objects of a parent
public static void Traverse(GameObject gameObject, Action<GameObject> action)
{
if (gameObject == null)
{
throw new ArgumentNullException("gameObject");
}
if (action == null)
{
using Sirenix.OdinInspector.Editor;
using Sirenix.Utilities;
using Sirenix.Utilities.Editor;
using UnityEditor;
public class DbBrowser : OdinMenuEditorWindow
{
[MenuItem("Db/Browser")]
public static void Open()
{
@pinkas
pinkas / RectTransformExplained.cs
Last active August 10, 2020 10:33
Make sense of the RecTransform in edit mode! (without changing the inspector to debug mode)
using UnityEngine;
[ExecuteInEditMode]
public class RectTransformExplained : MonoBehaviour
{
RectTransform rt;
[Header("Anchored position")]
[SerializeField] Vector2 anchorePosition;
@pinkas
pinkas / StringCacher.cs
Created February 26, 2019 21:59
Will cache a collection of string based on a delegate you pass in - Useful when you need to do lots of string concatenation during gameplay
using System;
namespace SlugLib
{
public class StringCacher
{
public delegate string StringConstructor(int index);
private string[] strings;
private StringConstructor stringConstructor;
@pinkas
pinkas / MonoBehaviourCachedRectTransform.cs
Created February 26, 2019 21:38
The class name should self explanatory enough
using System;
using UnityEngine;
public class MonoBehaviourCachedRectTransform : MonoBehaviour
{
[HideInInspector, NonSerialized]
private RectTransform rectTransform;
public RectTransform RectTransform
{
@pinkas
pinkas / VerySimpleObjectPool.cs
Last active February 12, 2022 11:15
Very basic Unity game object pool
using System.Collections.Generic;
using UnityEngine;
public class VerySimpleObjectPool : MonoBehaviour
{
[SerializeField] private GameObject pooledObject = null;
[SerializeField] private int pooledAmount = 2;
[SerializeField] private bool canGrow = true;
[SerializeField] bool asyncInstantiate = false;