Skip to content

Instantly share code, notes, and snippets.

@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;
@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 / 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 / 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 / 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 / RandomPointOnMesh.cs
Last active April 9, 2024 12:14 — forked from v21/gist:5378391
Random point on a mesh, for Unity3D
using UnityEngine;
using System.Collections.Generic;
/// <summary>
/// Get total area of each triangle.
/// Find a random point within that total area.
/// Lookup which triangle that point relates to
/// Find a randiom point which point that triangle
/// This works for all mesh types, and gives fully distributed results.
/// Gist: https://gist.github.com/danieldownes/b1c9bab09cce013cc30a4198bfeda0aa
@danieldownes
danieldownes / commitFilesByModificationDate.sh
Last active May 21, 2024 05:04
Commit file and use last modified date as author commit date
#!/bin/bash
# Run directly from bash without download:
# curl -s https://gist.githubusercontent.com/danieldownes/c31b2107879555ebcb436a4e10d2826a/raw/ca495f5f28af778c72712472d279e27698c5606f/commitFilesByModificationDate.sh | bash
# Get list of all files in all folders and subfolders
# ignore file and '.git' folder
# Sort by modification date, desc
@danieldownes
danieldownes / github-ci-unity-hololens2-windows-uwp.yml
Created March 30, 2022 10:19 — forked from cookieofcode/github-ci-unity-hololens2-windows-uwp.yml
Github Actions CI Unity HoloLens 2 Build (Windows, UWP)
# GitHub Actions CI for Unity Hololens 2 UWP running on windows.
name: CI
on:
# Triggers the workflow on push or pull request events but only for the master branch
push:
branches: [ master ]
pull_request:
branches: [ master ]
@danieldownes
danieldownes / ToolsMenu.cs
Last active March 5, 2023 06:04
Unity Tools Menu - Clear PlayPrefs and Screenshot
using System;
using UnityEngine;
using UnityEditor;
public class ToolsMenu
{
[MenuItem("Tools/Clear PlayerPrefs")]
private static void ClearPlayerPrefs()
{
PlayerPrefs.DeleteAll();
@danieldownes
danieldownes / SearchForComponents.cs
Last active March 5, 2023 06:04
UnityEditor: Search For Components
//Assets/Editor/SearchForComponents.cs
using UnityEngine;
using UnityEditor;
using System.Collections;
using System.Collections.Generic;
public class SearchForComponents : EditorWindow
{
[MenuItem("Tools/Search For Components")]
static void Init ()