Skip to content

Instantly share code, notes, and snippets.

View danieldownes's full-sized avatar

Daniel Downes danieldownes

View GitHub Profile
@danieldownes
danieldownes / ConvertRange.cs
Created March 11, 2022 13:01
ConvertRange oldValue, oldMin, oldMax, newMin, newMax
public static float ConvertRange(float oldValue, float oldMin, float oldMax, float newMin = 0, float newMax = 1)
{
float oldRange = (oldMax - oldMin);
if (oldRange == 0)
return newMin;
else
return (((oldValue - oldMin) * (newMax - newMin)) / oldRange) + newMin;
}
@danieldownes
danieldownes / vimrcconfig
Created October 5, 2021 13:41
vim config
syntax on
set noerrorbells
set tabstop=4
set shiftwidth=4
set smartindent
set nu
set nowrap
set smartcase
set noswapfile
@danieldownes
danieldownes / SetViewportToUiRect.cs
Created September 2, 2021 21:50
Camera Viewport to Ui Rect
using System;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
// Note ensure editor resolution matches Canvas fixed resolution (1024 x 768)
//
/// <summary>
/// The intention is to allow the viewport to be move around the screen as controlled by a RectTransform, which it does.
@danieldownes
danieldownes / .editorconfig
Created April 19, 2021 15:59
.editorconfig
# http://EditorConfig.org
# This file is the top-most EditorConfig file
root = true
# All Files
[*]
charset = utf-8
end_of_line = crlf
indent_style = space
@danieldownes
danieldownes / ToggleGroupIndexed.cs
Last active April 19, 2021 15:59
Unity ToggleGroupIndexed
using System;
using UnityEngine;
using UnityEngine.Events;
using UnityEngine.UI;
namespace Ui
{
public class ToggleGroupIndexed : MonoBehaviour
{
public event Action<int> SelectedChanged;