Skip to content

Instantly share code, notes, and snippets.

View RoeiRubach's full-sized avatar

Roei Rubach RoeiRubach

View GitHub Profile
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.SceneManagement;
[RequireComponent(typeof(LineRenderer))]
public class LineProjection : MonoBehaviour
{
[SerializeField] private Transform _obstaclesParent;
[SerializeField] private int _maxPhysicsFrameIterations = 100;
@RoeiRubach
RoeiRubach / ConsoleReporter.cs
Created November 12, 2021 10:11
[Unity Editor Console Reporter]
using UnityEngine;
public static class ConsoleReporter
{
private static readonly string _cantFind = "coulnd't be found!";
private static readonly string _redError = "<b><color=red>Error: </color></b>";
private static readonly string _clickHighlight = "Click to highlight in hierarchy";
private static readonly string _inspectorWasntSet = "was not set in the inspector!";
public static void LogNullObject(string objectName)
@RoeiRubach
RoeiRubach / FlexibleGridLayout.cs
Created November 11, 2021 11:18
[Flexible Grid Layout]
using UnityEngine;
using UnityEngine.UI;
public class FlexibleGridLayout : LayoutGroup
{
[SerializeField] private FlexibleGrid _grid;
public override void CalculateLayoutInputHorizontal()
{
base.CalculateLayoutInputHorizontal();
@RoeiRubach
RoeiRubach / CharacterMovement.cs
Last active October 19, 2021 12:09
[Character Movement] Basic character movement using Unity's CharacterController component
using UnityEngine;
public class CharacterMovement
{
private const float JUMP_HEIGHT = 8f;
private const float GRAVITY_VALUE = 9.81f;
private readonly float _speed;
private float _turnSmoothVelocity;
private readonly Transform _target;
@RoeiRubach
RoeiRubach / GenericCachingMethod.cs
Created October 14, 2021 13:23
[Generic Caching Method]
private void ShouldCacheThing<TComponentType>(GameObject target, ref TComponentType field) where TComponentType : UnityEngine.Object //might need to be Component here
{
if (!field)
field = target.GetComponent<TComponentType>();
}
@RoeiRubach
RoeiRubach / UDPManager.cs
Last active September 14, 2021 18:52
[UDPManager] Simple UDP that manages sending & receiving messages #UDP
using System;
using System.IO;
using System.Net;
using System.Net.Sockets;
using System.Text;
using System.Threading;
using UnityEngine;
public class UDPManager
{
@RoeiRubach
RoeiRubach / PauseMenuController.unity
Last active May 17, 2020 14:55
[Pause Menu] Pause menu controller #PauseMenu
using UnityEngine;
public class PauseMenuController : MonoBehaviour
{
public static bool IsGamePaused = false;
[SerializeField] private GameObject _onGameUI;
[SerializeField] private GameObject _pauseMenuUI;
[SerializeField] private GameObject _optionsMenuUI;
@RoeiRubach
RoeiRubach / EnemyPoolController.unity
Created April 19, 2020 21:58
[Enemy Pool Controller] a collection for accessing any that currently exist. I do this frequently with what I call a 'MultitonPool'.
using UnityEngine;
using System.Collections.Generic;
public class EnemyPoolController : MonoBehaviour
{
public readonly static HashSet<EnemyPoolController> Pool = new HashSet<EnemyPoolController>();
private void OnEnable()
{
EnemyPoolController.Pool.Add(this);
@RoeiRubach
RoeiRubach / SwipeDetector.unity
Last active April 5, 2020 20:33
[Mobile Finger Swiping Detector] #SwipeDetector
using System;
using UnityEngine;
public struct SwipeData
{
public Vector2 StartPosition, EndPosition;
public SwipeDirection Direction;
}
public enum SwipeDirection
@RoeiRubach
RoeiRubach / Unity Android Support
Last active June 30, 2025 06:07
[Unity Android Support] How to delete and reinstall Unity Android Support #HowTo
1. Restart the PC
2. Go to:
C:\Program Files\Unity\Hub\Editor\2019.2.6f1\Editor\Data\PlaybackEngines\
(this example is for 2019.2.6f1 but you can choose any other)
3. You will find there a folder "AndroidPlayer". Delete that AndroidPlayer folder.
You will need to be a User with Admin rights, and this is probably why Unity fails on uninstall, it has no permission to delete the folder.