-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
Feature/improved commandline
- Loading branch information
There are no files selected for viewing
This file was deleted.
This file was deleted.
This file was deleted.
This file was deleted.
This file was deleted.
This file was deleted.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
namespace UniTools.Build | ||
{ | ||
public abstract class BuildParameterPresenter | ||
{ | ||
|
||
public abstract string CliKey { get; } | ||
|
||
public abstract void Draw(bool duplicated); | ||
} | ||
} |
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,26 @@ | ||
using UnityEngine; | ||
|
||
namespace UniTools.Build | ||
{ | ||
[CreateAssetMenu( | ||
fileName = nameof(StringBuildParameter), | ||
menuName = MenuPaths.Parameters + "Int" | ||
)] | ||
public sealed class IntBuildParameter : ScriptableBuildParameter<int> | ||
{ | ||
protected override bool TryParseFromCommandLine(string commandLine, out int v) | ||
{ | ||
if (CommandLineParser.TryToParseValue(commandLine, CliKey, out object obj)) | ||
{ | ||
if (int.TryParse(obj.ToString(), out v)) | ||
{ | ||
return true; | ||
} | ||
} | ||
|
||
v = int.MinValue; | ||
|
||
return false; | ||
} | ||
} | ||
} |
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,65 @@ | ||
using System.Linq; | ||
using UnityEditor; | ||
using UnityEngine; | ||
|
||
namespace UniTools.Build | ||
{ | ||
[CustomEditor(typeof(IntBuildParameter))] | ||
public sealed class IntBuildParameterEditor : Editor | ||
{ | ||
private IntBuildParameter m_target = default; | ||
private SerializedProperty m_value = default; | ||
private SerializedProperty m_options = default; | ||
|
||
private void OnEnable() | ||
{ | ||
m_value = serializedObject.FindProperty(nameof(m_value)); | ||
m_options = serializedObject.FindProperty(nameof(m_options)); | ||
m_target = target as IntBuildParameter; | ||
} | ||
|
||
public override void OnInspectorGUI() | ||
{ | ||
Draw(m_target, serializedObject, m_value, m_options); | ||
} | ||
|
||
/// <summary> | ||
/// This method is using to draw the same editor in different windows | ||
/// </summary> | ||
public static void Draw(IntBuildParameter target, SerializedObject serializedObject, SerializedProperty value, SerializedProperty options) | ||
{ | ||
bool copyToClipboard = false; | ||
|
||
if (target.Options == null || target.Options.Count <= 0) | ||
{ | ||
EditorGUILayout.PropertyField(value); | ||
} | ||
else | ||
{ | ||
int index = target.Options.IndexOf(value.intValue); | ||
index = EditorGUILayout.Popup(index, target.Options.Select(o => o.ToString()).ToArray()); | ||
|
||
if (index >= 0 && index <= target.Options.Count) | ||
{ | ||
value.intValue = target.Options[index]; | ||
} | ||
} | ||
|
||
EditorGUILayout.PropertyField(options); | ||
|
||
EditorGUILayout.BeginHorizontal(); | ||
{ | ||
EditorGUILayout.LabelField($"CLI: {target.CliKey} {value.intValue}"); | ||
copyToClipboard = GUILayout.Button("Copy"); | ||
} | ||
EditorGUILayout.EndHorizontal(); | ||
|
||
serializedObject.ApplyModifiedProperties(); | ||
|
||
if (copyToClipboard) | ||
{ | ||
EditorGUIUtility.systemCopyBuffer = $"{target.CliKey} {value.intValue}"; | ||
} | ||
} | ||
} | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.