Skip to content

Instantly share code, notes, and snippets.

View abdelfattahradwan's full-sized avatar
🏠
Working from home

abdelfattahradwan

🏠
Working from home
View GitHub Profile
@abdelfattahradwan
abdelfattahradwan / Singleton.cs
Last active November 2, 2019 11:16
a simple generic singleton class for unity
using UnityEngine;
public class Singleton<T> : MonoBehaviour where T : MonoBehaviour
{
protected bool Persists { get; set; }
protected bool PreventDuplicates { get; set; }
public static T Instance { get; private set; }
protected virtual void Awake()
@abdelfattahradwan
abdelfattahradwan / ViewManager.cs
Last active October 16, 2024 17:13
The View Manager script from the my UI management system YouTube video tutorial (https://youtu.be/rdXC2om16lo)
using System.Collections.Generic;
using UnityEngine;
public class ViewManager : MonoBehaviour
{
private static ViewManager s_instance;
[SerializeField] private View _startingView;
@abdelfattahradwan
abdelfattahradwan / View.cs
Created September 20, 2020 05:04
The View script from the UI management system YouTube video tutorial (https://youtu.be/rdXC2om16lo)
using UnityEngine;
public abstract class View : MonoBehaviour
{
public abstract void Initialize();
public virtual void Hide() => gameObject.SetActive(false);
public virtual void Show() => gameObject.SetActive(true);
}
@abdelfattahradwan
abdelfattahradwan / Cropper.cs
Created November 28, 2020 08:59
Texture cropping MonoBehaviour
using System;
using UnityEngine;
public class Cropper : MonoBehaviour
{
[SerializeField] private Color _backgroundColor;
[SerializeField] private Texture2D _originalTexture;
[SerializeField] private Texture2D _croppedTexture;
@abdelfattahradwan
abdelfattahradwan / ObservableList.cs
Created April 5, 2021 10:39
An observable list for Unity engine.
using System;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
[Serializable]
public sealed class ObservableList<T> : IList<T>
{
[SerializeReference] private List<T> _items = new List<T>();
using System;
using System.Collections.Generic;
namespace BoardGame
{
public static class ArrayUtility
{
public static int Wrap<T>(this IList<T> list, int index)
{
if (index < 0)
@abdelfattahradwan
abdelfattahradwan / snake.html
Last active April 30, 2021 23:37
A simple Snake game made using HTML and JavaScript.
<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<style>
^(?:\+|\-)?(?:(\.\d+)|(?:\d+(?:\.\d+)?))$ - Real numbers (No scientific notation).
^(?:\+|\-)?\d+$ - Integers.
@abdelfattahradwan
abdelfattahradwan / hue_colors.md
Created May 9, 2021 18:02 — forked from popcorn245/hue_colors.md
XY Color Conversion

FROM HUE DESIGN DOCS

https://github.com/PhilipsHue/PhilipsHueSDK-iOS-OSX/blob/00187a3db88dedd640f5ddfa8a474458dff4e1db/ApplicationDesignNotes/RGB%20to%20xy%20Color%20conversion.md

#Conversion between RGB and xy in the CIE 1931 colorspace for hue The conversion between RGB and xy in the CIE 1931 colorspace is not something Philips invented, but we have an optimized conversion for our different light types, like hue bulbs and LivingColors. It is important to differentiate between the various light types, because they do not all support the same color gamut. For example, the hue bulbs are very good at showing nice whites, while the LivingColors are generally a bit better at colors, like green and cyan.

@abdelfattahradwan
abdelfattahradwan / SimpleCharacterController.cs
Created July 6, 2021 04:13
Simple FPS Character Controller for Unity
using UnityEngine;
public sealed class SimpleCharacterController : MonoBehaviour
{
[SerializeField] private float speed;
[SerializeField] private float jumpSpeed;
private Vector3 _velocity;
[SerializeField] private CharacterController characterController;