-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
- Loading branch information
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
# see http://editorconfig.org/ for docs on this file | ||
|
||
root = true | ||
|
||
[*] | ||
# help with sharing files across os's (i.e. network share or through local vm) | ||
#end_of_line = lf | ||
#charset temporarily disabled due to bug in VS2017 changing to UTF-8 with BOM (https://favro.com/card/c564ede4ed3337f7b17986b6/Uni-17877) | ||
#charset = utf-8 | ||
trim_trailing_whitespace = true | ||
insert_final_newline = true | ||
|
||
# formattable file extensions (keep in sync with format.ini from unity-meta repo) | ||
# | ||
# Note: We need to split the formattable files configs into shorter duplicate entries (logically grouped) | ||
# due to known issue in VS editorconfig extension where there is a limit of 51 characters (empirically determined). | ||
# see: https://github.com/editorconfig/editorconfig-visualstudio/issues/21 | ||
# | ||
## uncrustify | ||
[*.{c,h,cpp,hpp,m,mm,cc,cs}] | ||
indent_style = space | ||
indent_size = 4 | ||
|
||
## generic formatter (shaders) | ||
[*.{cg,cginc,glslinc,hlsl,shader,y,ypp,yy}] | ||
indent_style = space | ||
indent_size = 4 | ||
|
||
## generic formatter (misc) | ||
[*.{asm,s,S,pch,pchmm,java,sh,uss}] | ||
indent_style = space | ||
indent_size = 4 | ||
|
||
## perltidy | ||
[*.{pl,pm,t,it}] | ||
indent_style = space | ||
indent_size = 4 | ||
|
||
## unity special | ||
[*.{bindings,mem.xml}] | ||
indent_style = space | ||
indent_size = 4 | ||
|
||
# other filetypes we want to overwrite default configuration to preserve the standard | ||
[{Makefile,makefile}] | ||
# TAB characters are part of the Makefile format | ||
indent_style = tab | ||
|
||
[*.{md,markdown}] | ||
# trailing whitespace is significant in markdown (bad choice, bad!) | ||
trim_trailing_whitespace = false | ||
|
||
# keep these and the VS stuff below in sync with .hgeol's CRLF extensions | ||
[*.{vcproj,bat,cmd,xaml,tt,t4,ttinclude}] | ||
end_of_line = crlf | ||
|
||
# this VS-specific stuff is based on experiments to see how VS will modify a file after it has been manually edited. | ||
# the settings are meant to closely match what VS does to minimize unnecessary diffs. this duplicates some settings in * | ||
# but let's be explicit here to be safe (in case someone wants to copy-paste this out to another .editorconfig). | ||
[*.{vcxproj,vcxproj.filters,csproj,props,targets}] | ||
indent_style = space | ||
indent_size = 2 | ||
end_of_line = crlf | ||
charset = utf-8-bom | ||
trim_trailing_whitespace = true | ||
insert_final_newline = false | ||
[*.{sln,sln.template}] | ||
indent_style = tab | ||
indent_size = 4 | ||
end_of_line = crlf | ||
charset = utf-8 | ||
trim_trailing_whitespace = true | ||
insert_final_newline = false |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
/[Ll]ibrary/ | ||
/[Tt]emp/ | ||
/[Oo]bj/ | ||
/[Bb]uild/ | ||
/[Bb]uilds/ | ||
/Assets/AssetStoreTools* | ||
**/Excluded/ | ||
**/Excluded.meta | ||
|
||
|
||
# Visual Studio 2015 cache directory | ||
/.vs/ | ||
|
||
# Autogenerated VS/MD/Consulo solution and project files | ||
ExportedObj/ | ||
.consulo/ | ||
*.csproj | ||
*.unityproj | ||
*.sln | ||
*.suo | ||
*.tmp | ||
*.user | ||
*.userprefs | ||
*.pidb | ||
*.booproj | ||
*.svd | ||
*.pdb | ||
|
||
# Unity3D generated meta files | ||
*.pidb.meta | ||
|
||
# Unity3D Generated File On Crash Reports | ||
sysinfo.txt | ||
|
||
# Builds | ||
*.apk | ||
*.unitypackage |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
|
||
namespace NoiseCrimeStudios.Core | ||
{ | ||
public static class LinqExtensions | ||
{ | ||
/// <summary>Helper method to choose between ascending or descending Order.</summary> | ||
/// <remarks>Taken from Unity's TreeViewExamples demo.</remarks> | ||
public static IOrderedEnumerable<T> OrderBy<T, TKey>( this IEnumerable<T> source, Func<T, TKey> selector, bool ascending ) | ||
{ | ||
if ( ascending ) | ||
return source.OrderBy( selector ); | ||
|
||
return source.OrderByDescending( selector ); | ||
} | ||
|
||
/// <summary>Helper method to choose between ascending or descending ThenBy.</summary> | ||
/// <remarks>Taken from Unity's TreeViewExamples demo.</remarks> | ||
public static IOrderedEnumerable<T> ThenBy<T, TKey>( this IOrderedEnumerable<T> source, Func<T, TKey> selector, bool ascending ) | ||
{ | ||
if ( ascending ) | ||
return source.ThenBy( selector ); | ||
|
||
return source.ThenByDescending( selector ); | ||
} | ||
} | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,142 @@ | ||
using UnityEngine; | ||
|
||
// String.Format Notes | ||
// http://azuliadesigns.com/string-formatting-examples/ | ||
// https://msdn.microsoft.com/en-us/library/system.string.format(v=vs.110).aspx | ||
|
||
namespace NoiseCrimeStudios.Core.Formatting | ||
{ | ||
public static class Numerical | ||
{ | ||
// Overall this has proven to be the most efficeint method to use from this page | ||
// https://stackoverflow.com/questions/281640/how-do-i-get-a-human-readable-file-size-in-bytes-abbreviation-using-net#4975942 | ||
// Returns the human-readable file size for an arbitrary, 64-bit file size. However it reverts to bytes for long.MinValue | ||
public static string ByteCountToSuffixHumbads( long byteCount ) | ||
{ | ||
// Get absolute value | ||
long absolute_i = (byteCount < 0 ? -byteCount : byteCount); | ||
|
||
// Determine the suffix and readable value | ||
string suffix; | ||
double readable; | ||
|
||
if ( absolute_i >= 0x1000000000000000 ) // Exabyte | ||
{ | ||
suffix = "EB"; | ||
readable = ( byteCount >> 50 ); | ||
} | ||
else if ( absolute_i >= 0x4000000000000 ) // Petabyte | ||
{ | ||
suffix = "PB"; | ||
readable = ( byteCount >> 40 ); | ||
} | ||
else if ( absolute_i >= 0x10000000000 ) // Terabyte | ||
{ | ||
suffix = "TB"; | ||
readable = ( byteCount >> 30 ); | ||
} | ||
else if ( absolute_i >= 0x40000000 ) // Gigabyte | ||
{ | ||
suffix = "GB"; | ||
readable = ( byteCount >> 20 ); | ||
} | ||
else if ( absolute_i >= 0x100000 ) // Megabyte | ||
{ | ||
suffix = "MB"; | ||
readable = ( byteCount >> 10 ); | ||
} | ||
else if ( absolute_i >= 0x400 ) // Kilobyte | ||
{ | ||
suffix = "KB"; | ||
readable = byteCount; | ||
} | ||
else | ||
{ | ||
return string.Format( "{0:F1} B", byteCount); // Byte | ||
} | ||
|
||
// Divide by 1024 to get fractional value | ||
readable = ( readable / 1024 ); | ||
|
||
// Return formatted number with suffix | ||
return string.Format( "{0:F1} {1}", readable, suffix ); | ||
} | ||
|
||
#if UNITY_EDITOR | ||
[UnityEditor.MenuItem( "Window/NoiseCrimeStudios/Validations/Support_Formatting", false, 1300 )] | ||
public static void TestByteCountToSuffix() | ||
{ | ||
long[] testValues = new long[]{ -1, 0, 1, 1000, 10000, 100000, 1000000, int.MaxValue, int.MinValue, long.MaxValue }; //, long.MinValue }; | ||
|
||
string result; | ||
|
||
result = ""; | ||
for ( int i = 0; i < testValues.Length; i++ ) | ||
result += string.Format( "ByteCountToSuffixHumbads: {0} = {1}\n", testValues[ i ], ByteCountToSuffixHumbads( testValues[ i ] ) ); | ||
|
||
Debug.Log( result ); | ||
} | ||
#endif | ||
|
||
|
||
|
||
#if ALTERNATIVES | ||
// Don't use these methods, they are just for reference and not as efficeint as ByteCountToSuffixHumbads() | ||
|
||
static string[] suffixArray = { "B", "KB", "MB", "GB", "TB", "PB", "EB" }; //Longs run out around EB | ||
|
||
// Note: Reverts to bytes for int.MinValue & long.MinValue | ||
[System.Obsolete("Obsolete. For reference only. Reverts to bytes for int.MinValue & long.MinValue")] | ||
public static string ByteCountToSuffixNC( long byteCount ) | ||
{ | ||
int index = 0; | ||
double output = byteCount; | ||
|
||
while ( output >= 1024 ) | ||
{ | ||
output = output / 1024.0; | ||
index++; | ||
} | ||
|
||
if ( index >= suffixArray.Length ) return "err"; | ||
|
||
return string.Format( "{0:F1} {1}", output, suffixArray[ index ] ); | ||
} | ||
|
||
|
||
// Note: Fails on long.MinValue - DO NOT USE! | ||
[System.Obsolete("Obsolete. For reference only. Fails on long.MinValue with exception error.")] | ||
public static string ByteCountToSuffixDeepee( long byteCount ) | ||
{ | ||
if ( byteCount == 0 ) return "0" + suffixArray[ 0 ]; | ||
|
||
long bytes = Math.Abs(byteCount); | ||
int index = Convert.ToInt32(Math.Floor(Math.Log(bytes, 1024))); | ||
double num = Math.Round(bytes / Math.Pow(1024, index), 1); | ||
|
||
return string.Format( "{0:F1} {1}", Math.Sign( byteCount ) * num, suffixArray[ index ] ); | ||
} | ||
|
||
|
||
// Requires NoiseCrimeStudio's StopWatchProfiler | ||
public static void PerformanceTestByteCountToSuffix() | ||
{ | ||
long[] testValues = new long[]{ -1, 0, 1, 1000, 10000, 100000, 1000000, int.MaxValue, int.MinValue, long.MaxValue }; //, long.MinValue }; | ||
|
||
StopWatchProfiler.NewFrame(); | ||
|
||
StopWatchProfiler.BeginSample( "ByteCountToSuffixHumbads" ); | ||
for ( int p = 0; p < 100000; p++ ) | ||
{ | ||
for ( int i = 0; i < testValues.Length; i++ ) | ||
ByteCountToSuffixHumbads( testValues[ i ] ); | ||
} | ||
StopWatchProfiler.EndSample(); | ||
|
||
Debug.Log( StopWatchProfiler.GetResults() ); | ||
} | ||
#endif | ||
|
||
} | ||
|
||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.