mirror of
https://github.com/GrahamKracker/UnityExplorer.git
synced 2025-07-14 23:56:36 +08:00
1.6.8
* Added a ModConfig, allowing you to define the main menu toggle keybind and the default window size (so far). * Made the parsing of arguments more intelligent, should now behave as expected for null or empty arguments.
This commit is contained in:
@ -244,30 +244,41 @@ namespace Explorer
|
||||
var input = m_argumentInput[i];
|
||||
var type = m_arguments[i].ParameterType;
|
||||
|
||||
if (type == typeof(string))
|
||||
// First, try parse the input and use that.
|
||||
if (!string.IsNullOrEmpty(input))
|
||||
{
|
||||
parsedArgs.Add(input);
|
||||
}
|
||||
else
|
||||
{
|
||||
try
|
||||
// strings can obviously just be used directly
|
||||
if (type == typeof(string))
|
||||
{
|
||||
parsedArgs.Add(type.GetMethod("Parse", new Type[] { typeof(string) })
|
||||
.Invoke(null, new object[] { input }));
|
||||
parsedArgs.Add(input);
|
||||
continue;
|
||||
}
|
||||
catch
|
||||
else
|
||||
{
|
||||
if (m_arguments[i].HasDefaultValue)
|
||||
// try to invoke the parse method and use that.
|
||||
try
|
||||
{
|
||||
parsedArgs.Add(m_arguments[i].DefaultValue);
|
||||
parsedArgs.Add(type.GetMethod("Parse", new Type[] { typeof(string) })
|
||||
.Invoke(null, new object[] { input }));
|
||||
|
||||
continue;
|
||||
}
|
||||
else
|
||||
catch
|
||||
{
|
||||
// Try add a null arg I guess
|
||||
parsedArgs.Add(null);
|
||||
MelonLogger.Log($"Argument #{i} '{m_arguments[i].Name}' ({type.Name}), could not parse input '{input}'.");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Didn't use input, see if there is a default value.
|
||||
if (m_arguments[i].HasDefaultValue)
|
||||
{
|
||||
parsedArgs.Add(m_arguments[i].DefaultValue);
|
||||
continue;
|
||||
}
|
||||
|
||||
// Try add a null arg I guess
|
||||
parsedArgs.Add(null);
|
||||
}
|
||||
|
||||
return parsedArgs.ToArray();
|
||||
|
Reference in New Issue
Block a user