[TASK] Initial commit with basic product setup

This commit is contained in:
2019-08-18 13:50:14 +02:00
commit 01a66a8e1f
2548 changed files with 167528 additions and 0 deletions

View File

@@ -0,0 +1,46 @@
using System;
namespace WoLfulus.LineEnding
{
[Flags]
public enum Mode
{
Error = 1,
Assert = 2,
Log = 4,
Fatal = 16,
DontPreprocessCondition = 32,
AssetImportError = 64,
AssetImportWarning = 128,
ScriptingError = 256,
ScriptingWarning = 512,
ScriptingLog = 1024,
ScriptCompileError = 2048,
ScriptCompileWarning = 4096,
StickyError = 8192,
MayIgnoreLineNumber = 16384,
ReportBug = 32768,
DisplayPreviousErrorInStatusBar = 65536,
ScriptingException = 131072,
DontExtractStacktrace = 262144,
ShouldClearOnPlay = 524288,
GraphCompileError = 1048576,
ScriptingAssertion = 2097152,
}
[Flags]
public enum ConsoleFlags
{
Collapse = 1,
ClearOnPlay = 2,
ErrorPause = 4,
Verbose = 8,
StopForAssert = 16,
StopForError = 32,
Autoscroll = 64,
LogLevelLog = 128,
LogLevelWarning = 256,
LogLevelError = 512,
}
}

View File

@@ -0,0 +1,12 @@
fileFormatVersion: 2
guid: 66ccfdf2ae714c24fbb83439bccd54f6
timeCreated: 1500149996
licenseType: Store
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,201 @@
using System.Collections.Generic;
using System.IO;
using UnityEditor;
using UnityEditor.Callbacks;
using UnityEngine;
//#pragma warning disable 0414
namespace WoLfulus.LineEnding
{
/// <summary>
/// Initialize on load
/// </summary>
[InitializeOnLoad]
public class FileMonitor
{
private const string WindowsStyle = "\r\n";
private const string UnixStyle = "\n";
private const string MacStyle = "\r";
private const string MenuPrefix = "Tools/Line Endings Fixer/";
private const string MenuWindows = MenuPrefix + "Windows";
private const string MenuUnix = MenuPrefix + "Unix";
private const string MenuMac = MenuPrefix + "Mac OSX";
private const string ConfigurationId = "WoLfulus_LEF_Type";
/// <summary>
/// Initializer
/// </summary>
static FileMonitor()
{
EditorApplication.delayCall += () =>
{
if (!EditorPrefs.HasKey(ConfigurationId))
{
EditorPrefs.SetString(ConfigurationId, "win");
}
Menu.SetChecked(MenuWindows, false);
Menu.SetChecked(MenuUnix, false);
Menu.SetChecked(MenuMac, false);
var type = EditorPrefs.GetString(ConfigurationId);
if (type == "win")
{
Menu.SetChecked(MenuWindows, true);
}
else if (type == "unix")
{
Menu.SetChecked(MenuUnix, true);
}
else if (type == "mac")
{
Menu.SetChecked(MenuMac, true);
}
};
}
/// <summary>
/// Windows style
/// </summary>
[MenuItem(MenuWindows)]
private static void SetWindows()
{
Menu.SetChecked(MenuWindows, true);
Menu.SetChecked(MenuUnix, false);
Menu.SetChecked(MenuMac, false);
Debug.Log("Line endings changed to Windows");
EditorPrefs.SetString(ConfigurationId, "win");
}
/// <summary>
/// Windows style
/// </summary>
[MenuItem(MenuUnix)]
private static void SetUnix()
{
Menu.SetChecked(MenuWindows, false);
Menu.SetChecked(MenuUnix, true);
Menu.SetChecked(MenuMac, false);
Debug.Log("Line endings changed to Unix");
EditorPrefs.SetString(ConfigurationId, "unix");
}
/// <summary>
/// Windows style
/// </summary>
[MenuItem(MenuMac)]
private static void SetMac()
{
Menu.SetChecked(MenuWindows, false);
Menu.SetChecked(MenuUnix, false);
Menu.SetChecked(MenuMac, true);
Debug.Log("Line endings changed to Mac OSX");
EditorPrefs.SetString(ConfigurationId, "mac");
}
/// <summary>
/// Collect files from log entries
/// </summary>
private static IEnumerable<string> Collect()
{
var files = new List<string>();
var flags = LogEntries.consoleFlags;
LogEntries.SetConsoleFlag((int)ConsoleFlags.LogLevelLog, false);
LogEntries.SetConsoleFlag((int)ConsoleFlags.LogLevelWarning, true);
LogEntries.SetConsoleFlag((int)ConsoleFlags.LogLevelError, false);
LogEntries.StartGettingEntries();
var count = LogEntries.GetCount();
for (int i = 0; i < count; i++)
{
LogEntries.GetEntryInternal(i, LogEntry.instance);
if ((LogEntry.mode & Mode.AssetImportWarning) != 0)
{
var condition = LogEntry.condition;
if (!string.IsNullOrEmpty(condition) && condition.Contains("inconsistent line endings"))
{
files.Add(LogEntry.file);
}
}
}
LogEntries.EndGettingEntries();
LogEntries.consoleFlags = flags;
return files.ToArray();
}
/// <summary>
/// Fix stuff
/// </summary>
static void FixFiles()
{
var files = Collect();
var endingType = EditorPrefs.GetString(ConfigurationId);
var ending = "\r\n";
if (endingType == "win")
{
ending = WindowsStyle;
}
else if (endingType == "unix")
{
ending = UnixStyle;
}
else if (endingType == "mac")
{
ending = MacStyle;
}
else
{
Debug.Log("Line Endings Fixer settings not detected. You might want to select a line ending style.");
return;
}
int filesFixed = 0;
foreach (var file in files)
{
if (!File.Exists(file))
{
Debug.LogError("File '" + file + "' is reported to have wrong line endings but the file itself couldn't be found.");
continue;
}
var fileContents = File.ReadAllText(file).Replace("\r\n", "\n").Replace("\r", "\n").Replace("\n", ending);
File.WriteAllText(file, fileContents);
EditorApplication.delayCall += () =>
{
AssetDatabase.ImportAsset(file, ImportAssetOptions.ForceUpdate);
};
filesFixed++;
}
if (filesFixed > 0)
{
Debug.Log("Fixed " + filesFixed + " files with mixed line endings.");
}
}
/// <summary>
/// Scripts reloaded
/// </summary>
[DidReloadScripts]
static void ScriptsReloaded()
{
if (!EditorApplication.isPlaying)
{
FixFiles();
}
}
}
}

View File

@@ -0,0 +1,12 @@
fileFormatVersion: 2
guid: 878946dea992d444bbb127ad0bd8aa95
timeCreated: 1500149996
licenseType: Store
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,150 @@
using System;
using System.Reflection;
using UnityEditor;
namespace WoLfulus.LineEnding
{
[InitializeOnLoad]
public static class LogEntries
{
private static Type _type;
private static PropertyInfo _consoleFlags;
private static MethodInfo _SetConsoleFlag;
private static MethodInfo _RowGotDoubleClicked;
private static MethodInfo _GetStatusText;
private static MethodInfo _GetStatusMask;
private static MethodInfo _StartGettingEntries;
private static MethodInfo _EndGettingEntries;
private static MethodInfo _GetFirstTwoLinesEntryTextAndModeInternal;
private static MethodInfo _GetEntryCount;
private static MethodInfo _GetEntryInternal;
private static MethodInfo _GetCount;
private static MethodInfo _GetCountsByType;
private static MethodInfo _GetStatusViewErrorIndex;
private static MethodInfo _ClickStatusBar;
private static MethodInfo _Clear;
static LogEntries()
{
var flags = BindingFlags.Static | BindingFlags.Public;
if (_type == null)
{
Assembly assembly = Assembly.GetAssembly(typeof(Editor));
_type = assembly.GetType("UnityEditorInternal.LogEntries");
if (_type == null) // 2017 Fix
{
_type = assembly.GetType("UnityEditor.LogEntries");
}
_consoleFlags = _type.GetProperty("consoleFlags", flags);
_SetConsoleFlag = _type.GetMethod("SetConsoleFlag", flags);
_RowGotDoubleClicked = _type.GetMethod("RowGotDoubleClicked", flags);
_GetStatusText = _type.GetMethod("GetStatusText", flags);
_GetStatusMask = _type.GetMethod("GetStatusMask", flags);
_StartGettingEntries = _type.GetMethod("StartGettingEntries", flags);
_EndGettingEntries = _type.GetMethod("EndGettingEntries", flags);
_GetFirstTwoLinesEntryTextAndModeInternal = _type.GetMethod("GetFirstTwoLinesEntryTextAndModeInternal", flags);
_GetEntryCount = _type.GetMethod("GetEntryCount", flags);
_GetEntryInternal = _type.GetMethod("GetEntryInternal", flags);
_GetCount = _type.GetMethod("GetCount", flags);
_GetCountsByType = _type.GetMethod("GetCountsByType", flags);
_GetStatusViewErrorIndex = _type.GetMethod("GetStatusViewErrorIndex", flags);
_ClickStatusBar = _type.GetMethod("ClickStatusBar", flags);
_Clear = _type.GetMethod("Clear", flags);
}
}
public static int consoleFlags
{
get
{
return (int)_consoleFlags.GetValue(null, null);
}
set
{
_consoleFlags.SetValue(null, value, null);
}
}
public static void RowGotDoubleClicked(int index)
{
_RowGotDoubleClicked.Invoke(null, new object[1] { index });
}
public static string GetStatusText()
{
return (string)_GetStatusText.Invoke(null, new object[0]);
}
public static int GetStatusMask()
{
return (int)_GetStatusMask.Invoke(null, new object[0]);
}
public static int StartGettingEntries()
{
return (int)_StartGettingEntries.Invoke(null, new object[0]);
}
public static void SetConsoleFlag(int bit, bool value)
{
_SetConsoleFlag.Invoke(null, new object[2] { bit, value });
}
public static void EndGettingEntries()
{
_EndGettingEntries.Invoke(null, new object[0]);
}
public static int GetCount()
{
return (int)_GetCount.Invoke(null, new object[0]);
}
public static void GetCountsByType(ref int errorCount, ref int warningCount, ref int logCount)
{
_GetCountsByType.Invoke(null, new object[3] { errorCount, warningCount, logCount });
}
public static void GetFirstTwoLinesEntryTextAndModeInternal(int row, ref int mask, ref string outString)
{
_GetFirstTwoLinesEntryTextAndModeInternal.Invoke(null, new object[3] { row, mask, outString });
}
public static bool GetEntryInternal(int row, object outputEntry)
{
return (bool)_GetEntryInternal.Invoke(null, new object[2] { row, outputEntry });
}
public static int GetEntryCount(int row)
{
return (int)_GetEntryCount.Invoke(null, new object[1] { row });
}
public static void Clear()
{
_Clear.Invoke(null, new object[0]);
}
public static int GetStatusViewErrorIndex()
{
return (int)_GetStatusViewErrorIndex.Invoke(null, new object[0]);
}
public static void ClickStatusBar(int count)
{
_ClickStatusBar.Invoke(null, new object[1] { count });
}
}
}

View File

@@ -0,0 +1,12 @@
fileFormatVersion: 2
guid: 99af3a8e663ff6e41a5551d6b28f7b91
timeCreated: 1500149996
licenseType: Store
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,117 @@
using System;
using System.Reflection;
using UnityEditor;
namespace WoLfulus.LineEnding
{
public static class LogEntry
{
public static object instance = null;
public static string condition
{
get
{
return (string)_condition.GetValue(instance);
}
}
public static int errorNum
{
get
{
return (int)_errorNum.GetValue(instance);
}
}
public static string file
{
get
{
return (string)_file.GetValue(instance);
}
}
public static int line
{
get
{
return (int)_line.GetValue(instance);
}
}
public static Mode mode
{
get
{
return (Mode)((int)_mode.GetValue(instance));
}
}
public static int instanceID
{
get
{
return (int)_instanceID.GetValue(instance);
}
}
public static int identifier
{
get
{
return (int)_identifier.GetValue(instance);
}
}
public static int isWorldPlaying
{
get
{
return (int)_isWorldPlaying.GetValue(instance);
}
}
private static Type _type = null;
private static FieldInfo _condition;
private static FieldInfo _errorNum;
private static FieldInfo _file;
private static FieldInfo _line;
private static FieldInfo _mode;
private static FieldInfo _instanceID;
private static FieldInfo _identifier;
private static FieldInfo _isWorldPlaying;
static LogEntry()
{
Initialize();
}
static void Initialize()
{
if (_type == null)
{
var flags = BindingFlags.Instance | BindingFlags.Public;
var assembly = Assembly.GetAssembly(typeof(Editor));
_type = assembly.GetType("UnityEditorInternal.LogEntry");
if (_type == null) // 2017 Fix
{
_type = assembly.GetType("UnityEditor.LogEntry");
}
_condition = _type.GetField("condition", flags);
_errorNum = _type.GetField("errorNum", flags);
_file = _type.GetField("file", flags);
_line = _type.GetField("line", flags);
_mode = _type.GetField("mode", flags);
_instanceID = _type.GetField("instanceID", flags);
_identifier = _type.GetField("identifier", flags);
_isWorldPlaying = _type.GetField("isWorldPlaying", flags);
instance = Activator.CreateInstance(_type);
}
}
}
}

View File

@@ -0,0 +1,12 @@
fileFormatVersion: 2
guid: ef774846cf2b8b2409ad3a7a2334828e
timeCreated: 1500149996
licenseType: Store
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant: