Skip to content

Instantly share code, notes, and snippets.

View StewMcc's full-sized avatar

Stewart Mccready StewMcc

View GitHub Profile
@StewMcc
StewMcc / GitCommands.psm1
Last active July 23, 2019 20:36
Recursively cleans up all the .git repositories, down the directory tree from the powershells current location
function Use-GitCleanRecursively
{
$ErrorActionPreference= 'silentlycontinue'
$initialPath = Get-Location
Get-ChildItem -recurse -force |
Where-Object {$_.name -eq ".git"} |
ForEach-Object {
Set-Location $_.parent.FullName
Write-Output $_.parent.FullName
@StewMcc
StewMcc / manifest.json
Created April 29, 2018 14:43
Simple gist for Unity Package Manager, so doesn't include a bunch of default unity packages. place in the folder Packages (2018.1 > ) or UnityPackageManager (2017.4 <)
{
"dependencies": {
"com.unity.purchasing": "exclude",
"com.unity.ads": "exclude",
"com.unity.analytics": "exclude",
"com.unity.standardevents": "exclude"
}
}
public class MathUtilities {
/// <summary>
/// Smoothly lerps between start and end positions within transition time.
/// Uses Mathf.SmoothStep to ensure 0 - 1 translation.
/// </summary>
/// <param name="startPosition"> Point at which Moving should start. </param>
/// <param name="endPosition"> Destination point. </param>
/// <param name="startTime"> Initial time it started at. </param>
/// <param name="transitionTime"> The maximum amount of time it should take to complete. </param>
public class UnityUiExtensions {
/// <summary>
/// Check if the mouse or first finger is over Unity UI element.
/// </summary>
/// <returns></returns>
private bool IsOverUi() {
#if (UNITY_ANDROID || UNITY_IOS) && !UNITY_EDITOR
return EventSystem.current.IsPointerOverGameObject(Input.GetTouch(0).fingerId);
#else
public class NavMeshExtensions {
/// <summary>
/// Generates a random point on the navmesh within the radius around the centre.
/// </summary>
/// <param name="center"> Centre point to create sphere around. </param>
/// <param name="radius"> Radius of Sphere. </param>
/// <param name="result"> Resultant NavMesh Point found. Vector3.zero if not found. </param>
/// <param name="maxAttempts"> Maximum number of times to try and find a point default value 30. </param>
/// <returns> Whether or not a navmesh point was found. If false result is Vector3.zero (bad idea to use this) </returns>
@StewMcc
StewMcc / GameObjectExtensions.cs
Created April 25, 2018 17:12
Simple editor extensions for gameobjects.
/// <summary>
/// GameObject manipulation extensions.
/// </summary>
public class GameObjectExtensions : MonoBehaviour {
private static Transform selectedRoot = null;
/// <summary>
/// Flattens all children to parent level, can be an expensive as recursive.
/// </summary>
@StewMcc
StewMcc / CommonAndroid.cs
Created March 30, 2018 00:06
Used for retrieving common Android classes, and objects for use with plug-ins or JNI calls.
//#undef UNITY_EDITOR // Lets you edit Android code easily with formatting, comment out before going back to editor.
#if UNITY_ANDROID && !UNITY_EDITOR // stop auto formatter removing unused using.
using UnityEngine;
#endif
/// <summary>
/// @StewMcc 21/02/2018
/// </summary>
namespace LittleLot {
@StewMcc
StewMcc / Singleton.cs
Created March 30, 2018 00:01
Singleton for use with Unity that will delete duplicates.
using UnityEngine;
/// <summary>
/// @StewMcc 9/10/2017
/// </summary>
namespace LittleLot {
/// <summary>
/// Singleton class that ensures there is only ever one of itself in the scene.
/// The singleton will delete itself if one already exists.
@StewMcc
StewMcc / omnisharp.json
Created December 21, 2017 15:02
VSCode CSharp Settings for omnisharp
{
"FormattingOptions": {
"NewLine": "\n",
"UseTabs": true,
"TabSize": 4,
"IndentationSize": 4,
"SpacingAfterMethodDeclarationName": false,
"SpaceWithinMethodDeclarationParenthesis": false,
"SpaceBetweenEmptyMethodDeclarationParentheses": false,
"SpaceAfterMethodCallName": false,
@StewMcc
StewMcc / WwiseIDConverter.cs
Created December 21, 2017 13:15 — forked from wavebit/WwiseIDConverter.cs
Wwise ID Converter #Wwise
using System.Collections;
using System.Collections.Generic;
using System.IO;
using System.Text;
using UnityEditor;
using UnityEngine;
internal class WwiseIDConverter {
private enum State {
Init,