Init
This commit is contained in:
@@ -0,0 +1,63 @@
|
||||
using System;
|
||||
using UnityEditor;
|
||||
using UnityEngine;
|
||||
|
||||
namespace QFSW.QC.Editor
|
||||
{
|
||||
public class DataEntryPopup : PopupWindowContent
|
||||
{
|
||||
private readonly string _title;
|
||||
private readonly string _btnName;
|
||||
|
||||
private string _data;
|
||||
private string _errors;
|
||||
private bool _success;
|
||||
|
||||
private GUIStyle _errorStyle;
|
||||
private GUIStyle _successStyle;
|
||||
|
||||
private readonly Action<string> _submitCallback;
|
||||
|
||||
public DataEntryPopup(string title, string btnName, Action<string> SubmitCallback)
|
||||
{
|
||||
CreateStyles();
|
||||
_title = title;
|
||||
_btnName = btnName;
|
||||
_submitCallback = SubmitCallback;
|
||||
}
|
||||
|
||||
public override Vector2 GetWindowSize() { return new Vector2(500, 100); }
|
||||
|
||||
private void CreateStyles()
|
||||
{
|
||||
_errorStyle = new GUIStyle(EditorStyles.wordWrappedLabel);
|
||||
_errorStyle.normal.textColor = new Color(1, 0, 0);
|
||||
|
||||
_successStyle = new GUIStyle(EditorStyles.wordWrappedLabel);
|
||||
_successStyle.normal.textColor = new Color(0, 0.5f, 0);
|
||||
}
|
||||
|
||||
public override void OnGUI(Rect rect)
|
||||
{
|
||||
_data = EditorGUILayout.TextField(_title, _data);
|
||||
GUI.enabled = !string.IsNullOrWhiteSpace(_data);
|
||||
if (GUILayout.Button(_btnName))
|
||||
{
|
||||
try
|
||||
{
|
||||
_submitCallback(_data);
|
||||
_success = true;
|
||||
_errors = "";
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
_errors = e.Message;
|
||||
_success = false;
|
||||
}
|
||||
}
|
||||
|
||||
if (!string.IsNullOrWhiteSpace(_errors)) { EditorGUILayout.LabelField(_errors, _errorStyle); }
|
||||
else if (_success) { EditorGUILayout.LabelField("Success!", _successStyle); }
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 5eaadd4a6e56548a0bac180051d85654
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,95 @@
|
||||
using QFSW.QC.QGUI;
|
||||
using UnityEditor;
|
||||
using UnityEngine;
|
||||
|
||||
namespace QFSW.QC.Editor
|
||||
{
|
||||
public static class EditorHelpers
|
||||
{
|
||||
private struct SupportItem
|
||||
{
|
||||
public string Name;
|
||||
public string Tooltip;
|
||||
public string Url;
|
||||
}
|
||||
|
||||
private static readonly SupportItem[] _supportItems =
|
||||
{
|
||||
new SupportItem
|
||||
{
|
||||
Name = "Docs",
|
||||
Tooltip = "Official and up to date documentation for Quantum Console.",
|
||||
Url = "https://qfsw.co.uk/docs/QC/"
|
||||
},
|
||||
new SupportItem
|
||||
{
|
||||
Name = "Email",
|
||||
Tooltip = "Email address for support and other inquiries.",
|
||||
Url = "mailto:support@qfsw.co.uk"
|
||||
},
|
||||
new SupportItem
|
||||
{
|
||||
Name = "Discord",
|
||||
Tooltip = "Discord server for customer support, WIPs and more.",
|
||||
Url = "https://discord.gg/g8SJ7X6"
|
||||
},
|
||||
new SupportItem
|
||||
{
|
||||
Name = "Twitter",
|
||||
Tooltip = "Get in touch or show off what you've made with QC.",
|
||||
Url = "https://twitter.com/QFSW1024"
|
||||
},
|
||||
new SupportItem
|
||||
{
|
||||
Name = "Review",
|
||||
Tooltip = "Leave a review to share your opinion and support Quantum Console!",
|
||||
Url = "https://assetstore.unity.com/packages/tools/utilities/quantum-console-211046#reviews"
|
||||
},
|
||||
new SupportItem
|
||||
{
|
||||
Name = "Survey",
|
||||
Tooltip = "A short survey to help me get feedback on Quantum Console and prioritize what needs the most focus.",
|
||||
Url = "https://forms.gle/TZbpg1t6hc6sypZA9"
|
||||
}
|
||||
};
|
||||
|
||||
private static Rect[] _supportItemRects = new Rect[_supportItems.Length];
|
||||
|
||||
public static void DrawBanner(Texture2D banner, float sizeMultiplier = 1f)
|
||||
{
|
||||
if (banner)
|
||||
{
|
||||
sizeMultiplier = Mathf.Clamp01(sizeMultiplier);
|
||||
Rect bannerRect = GUILayoutUtility.GetRect(0.0f, 0.0f);
|
||||
bannerRect.height = Screen.width / EditorGUIUtility.pixelsPerPoint * banner.height / banner.width;
|
||||
bannerRect.x += bannerRect.width * (1 - sizeMultiplier) / 2;
|
||||
bannerRect.width *= sizeMultiplier;
|
||||
bannerRect.height *= sizeMultiplier;
|
||||
|
||||
GUILayout.Space(bannerRect.height);
|
||||
GUI.Label(bannerRect, banner);
|
||||
}
|
||||
}
|
||||
|
||||
public static void DrawSupportRow()
|
||||
{
|
||||
LayoutController layout = new LayoutController(EditorGUILayout.GetControlRect());
|
||||
layout.SpliceRow(_supportItemRects.Length, ref _supportItemRects);
|
||||
|
||||
for (int i = 0; i < _supportItems.Length; i++)
|
||||
{
|
||||
SupportItem item = _supportItems[i];
|
||||
if (GUI.Button(_supportItemRects[i], new GUIContent(item.Name, item.Tooltip)))
|
||||
{
|
||||
Application.OpenURL(item.Url);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static void DrawHeader(Texture2D banner)
|
||||
{
|
||||
DrawBanner(banner);
|
||||
DrawSupportRow();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: b2819424558646f42af68616ef5e127a
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,42 @@
|
||||
using QFSW.QC.QGUI;
|
||||
using UnityEditor;
|
||||
using UnityEngine;
|
||||
|
||||
namespace QFSW.QC.Editor
|
||||
{
|
||||
[CustomPropertyDrawer(typeof(ModifierKeyCombo), true)]
|
||||
public class ModifierKeyComboEditor : PropertyDrawer
|
||||
{
|
||||
private readonly GUIContent _shiftLabel = new GUIContent("shift");
|
||||
private readonly GUIContent _altLabel = new GUIContent("alt");
|
||||
private readonly GUIContent _ctrlLabel = new GUIContent("ctrl");
|
||||
|
||||
public override void OnGUI(Rect position, SerializedProperty property, GUIContent label)
|
||||
{
|
||||
LayoutController layout = new LayoutController(position);
|
||||
EditorGUI.BeginProperty(layout.CurrentRect, label, property);
|
||||
|
||||
const float boolWidth = 10;
|
||||
bool enableState = GUI.enabled;
|
||||
float boolLabelWidth = QGUILayout.GetMaxContentSize(EditorStyles.label, _shiftLabel, _altLabel, _ctrlLabel).x;
|
||||
|
||||
SerializedProperty key = property.FindPropertyRelative("Key");
|
||||
SerializedProperty ctrl = property.FindPropertyRelative("Ctrl");
|
||||
SerializedProperty alt = property.FindPropertyRelative("Alt");
|
||||
SerializedProperty shift = property.FindPropertyRelative("Shift");
|
||||
|
||||
GUI.enabled &= ((KeyCode)key.enumValueIndex) != KeyCode.None;
|
||||
EditorGUI.LabelField(layout.ReserveHorizontalReversed(boolLabelWidth), _shiftLabel);
|
||||
EditorGUI.PropertyField(layout.ReserveHorizontalReversed(boolWidth), shift, GUIContent.none);
|
||||
EditorGUI.LabelField(layout.ReserveHorizontalReversed(boolLabelWidth), _altLabel);
|
||||
EditorGUI.PropertyField(layout.ReserveHorizontalReversed(boolWidth), alt, GUIContent.none);
|
||||
EditorGUI.LabelField(layout.ReserveHorizontalReversed(boolLabelWidth), _ctrlLabel);
|
||||
EditorGUI.PropertyField(layout.ReserveHorizontalReversed(boolWidth), ctrl, GUIContent.none);
|
||||
|
||||
GUI.enabled = enableState;
|
||||
EditorGUI.PropertyField(layout.CurrentRect, key, label);
|
||||
|
||||
EditorGUI.EndProperty();
|
||||
}
|
||||
}
|
||||
}
|
||||
+11
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: a359df86554203048b60947f59468558
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,47 @@
|
||||
using QFSW.QC.Utilities;
|
||||
using System;
|
||||
using System.IO;
|
||||
using UnityEditor;
|
||||
using UnityEngine;
|
||||
|
||||
namespace QFSW.QC.Editor
|
||||
{
|
||||
public class QCInspectorBase : UnityEditor.Editor
|
||||
{
|
||||
const string ROOT_PATH = "Source";
|
||||
protected string BannerName => "BannerEditor.png";
|
||||
protected Texture2D Banner { get; private set; }
|
||||
|
||||
protected T LoadAssetInSource<T>(string assetName, string root) where T : UnityEngine.Object
|
||||
{
|
||||
MonoScript src = MonoScript.FromScriptableObject(this);
|
||||
string srcPath = AssetDatabase.GetAssetPath(src);
|
||||
string dirPath = Path.GetDirectoryName(srcPath);
|
||||
string[] pathParts = dirPath.Split(new string[] { root }, StringSplitOptions.None);
|
||||
string rootPath = string.Join(root, pathParts.SkipLast()) + root;
|
||||
string[] files = Directory.GetFiles(rootPath, assetName, SearchOption.AllDirectories);
|
||||
|
||||
if (files.Length > 0)
|
||||
{
|
||||
string bannerPath = files[0];
|
||||
return AssetDatabase.LoadAssetAtPath<T>(bannerPath);
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
protected virtual void OnEnable()
|
||||
{
|
||||
if (!Banner)
|
||||
{
|
||||
Banner = LoadAssetInSource<Texture2D>(BannerName, ROOT_PATH);
|
||||
}
|
||||
}
|
||||
|
||||
public override void OnInspectorGUI()
|
||||
{
|
||||
EditorHelpers.DrawHeader(Banner);
|
||||
base.OnInspectorGUI();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 117a477a3c59db341907364ce3923b02
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,19 @@
|
||||
{
|
||||
"name": "QFSW.QC.Editor",
|
||||
"references": [
|
||||
"QFSW.QC",
|
||||
"QFSW.QC.Editor.Tools",
|
||||
"QFSW.QC.QGUI",
|
||||
"Unity.TextMeshPro"
|
||||
],
|
||||
"optionalUnityReferences": [],
|
||||
"includePlatforms": [
|
||||
"Editor"
|
||||
],
|
||||
"excludePlatforms": [],
|
||||
"allowUnsafeCode": false,
|
||||
"overrideReferences": false,
|
||||
"precompiledReferences": [],
|
||||
"autoReferenced": true,
|
||||
"defineConstraints": []
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 50b2bdd4833ec8043a7227258a04ccb7
|
||||
AssemblyDefinitionImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 979ba78ee0b3f154ab44f1295d48ce61
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,7 @@
|
||||
namespace QFSW.QC.QGUI
|
||||
{
|
||||
public interface IGUIItem
|
||||
{
|
||||
void DrawGUI(LayoutController layout);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 506cdc118faa64bd7b040644b69c623b
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,140 @@
|
||||
using UnityEditor;
|
||||
using UnityEngine;
|
||||
|
||||
namespace QFSW.QC.QGUI
|
||||
{
|
||||
public class LayoutController
|
||||
{
|
||||
public static float HorizontalPadding => 4;
|
||||
public static float RowPadding => EditorGUIUtility.standardVerticalSpacing;
|
||||
public static float RowHeight => EditorGUIUtility.singleLineHeight;
|
||||
|
||||
public bool IsValid
|
||||
{
|
||||
get
|
||||
{
|
||||
if (_currentRect.width < 0) { return false; }
|
||||
if (_currentRect.height < 0) { return false; }
|
||||
if (_currentRect.x < TotalDrawRect.x) { return false; }
|
||||
if (_currentRect.y < TotalDrawRect.y) { return false; }
|
||||
if (_currentRect.x + _currentRect.width > TotalDrawRect.x + TotalDrawRect.width) { return false; }
|
||||
if (_currentRect.y + _currentRect.height > TotalDrawRect.y + TotalDrawRect.height) { return false; }
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
public Rect TotalDrawRect { get; }
|
||||
public Rect CurrentRect => _currentRect;
|
||||
|
||||
private Rect _currentRect;
|
||||
|
||||
public LayoutController(Rect drawRect)
|
||||
{
|
||||
TotalDrawRect = drawRect;
|
||||
_currentRect = drawRect;
|
||||
_currentRect.height = RowHeight;
|
||||
}
|
||||
|
||||
public Rect BeginNewLine()
|
||||
{
|
||||
_currentRect.y += RowPadding + RowHeight;
|
||||
_currentRect.x = TotalDrawRect.x;
|
||||
_currentRect.width = TotalDrawRect.width;
|
||||
return _currentRect;
|
||||
}
|
||||
|
||||
public Rect ReserveHorizontal(float width)
|
||||
{
|
||||
Rect drawRect = _currentRect;
|
||||
drawRect.width = width;
|
||||
drawRect.width -= HorizontalPadding;
|
||||
|
||||
_currentRect.x += width;
|
||||
_currentRect.width -= width;
|
||||
|
||||
return drawRect;
|
||||
}
|
||||
|
||||
public Rect ReserveHorizontalPercentage(float widthPercentage)
|
||||
{
|
||||
float width = _currentRect.width * widthPercentage;
|
||||
return ReserveHorizontal(width);
|
||||
}
|
||||
|
||||
public Rect ReserveHorizontalReversed(float width)
|
||||
{
|
||||
Rect drawRect = _currentRect;
|
||||
drawRect.x += drawRect.width;
|
||||
drawRect.x -= width;
|
||||
drawRect.width = width;
|
||||
|
||||
_currentRect.width -= HorizontalPadding;
|
||||
_currentRect.width -= width;
|
||||
|
||||
return drawRect;
|
||||
}
|
||||
|
||||
public Rect ReserveHorizontalReversedPercentage(float widthPercentage)
|
||||
{
|
||||
float width = _currentRect.width * widthPercentage;
|
||||
return ReserveHorizontalReversed(width);
|
||||
}
|
||||
|
||||
public Rect ResizeRectHeight(Rect rect, float height)
|
||||
{
|
||||
rect.y += (rect.height - height) / 2;
|
||||
rect.height = height;
|
||||
|
||||
return rect;
|
||||
}
|
||||
|
||||
public Rect ReserveHorizontal(float width, float height)
|
||||
{
|
||||
return ResizeRectHeight(ReserveHorizontal(width), height);
|
||||
}
|
||||
|
||||
public Rect ReserveHorizontalReversed(float width, float height)
|
||||
{
|
||||
return ResizeRectHeight(ReserveHorizontalReversed(width), height);
|
||||
}
|
||||
|
||||
public Rect ReserveSquare()
|
||||
{
|
||||
return ReserveHorizontal(RowHeight);
|
||||
}
|
||||
|
||||
public Rect ReserveSquareReversed()
|
||||
{
|
||||
return ReserveHorizontalReversed(RowHeight);
|
||||
}
|
||||
|
||||
public Rect ReserveAuto(GUIContent content, GUIStyle style)
|
||||
{
|
||||
Vector2 size = style.CalcSize(content);
|
||||
return ReserveHorizontal(size.x, size.y);
|
||||
}
|
||||
|
||||
public Rect ReserveAutoReversed(GUIContent content, GUIStyle style)
|
||||
{
|
||||
Vector2 size = style.CalcSize(content);
|
||||
return ReserveHorizontalReversed(size.x, size.y);
|
||||
}
|
||||
|
||||
public void SpliceRow(int colCount, ref Rect[] rects)
|
||||
{
|
||||
float width = _currentRect.width / colCount;
|
||||
for (int i = 0; i < rects.Length; i++)
|
||||
{
|
||||
rects[i] = ReserveHorizontal(width);
|
||||
}
|
||||
}
|
||||
|
||||
public Rect[] SpliceRow(int colCount)
|
||||
{
|
||||
Rect[] rects = new Rect[colCount];
|
||||
SpliceRow(colCount, ref rects);
|
||||
return rects;
|
||||
}
|
||||
}
|
||||
}
|
||||
+11
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 481da05e0c09175429ec2db6589454a5
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,14 @@
|
||||
{
|
||||
"name": "QFSW.QC.QGUI",
|
||||
"references": [],
|
||||
"optionalUnityReferences": [],
|
||||
"includePlatforms": [
|
||||
"Editor"
|
||||
],
|
||||
"excludePlatforms": [],
|
||||
"allowUnsafeCode": false,
|
||||
"overrideReferences": false,
|
||||
"precompiledReferences": [],
|
||||
"autoReferenced": true,
|
||||
"defineConstraints": []
|
||||
}
|
||||
+7
@@ -0,0 +1,7 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 2c8115fef53c440a1873e4077e45b326
|
||||
AssemblyDefinitionImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,49 @@
|
||||
using System;
|
||||
using UnityEditor;
|
||||
using UnityEngine;
|
||||
|
||||
namespace QFSW.QC.QGUI
|
||||
{
|
||||
public static class QGUILayout
|
||||
{
|
||||
public static T EnumPopup<T>(T selected, params GUILayoutOption[] options) where T : Enum
|
||||
{
|
||||
return (T)EditorGUILayout.EnumPopup(selected, options);
|
||||
}
|
||||
|
||||
public static T EnumPopup<T>(GUIContent content, T selected, params GUILayoutOption[] options) where T : Enum
|
||||
{
|
||||
return (T)EditorGUILayout.EnumPopup(content, selected, options);
|
||||
}
|
||||
|
||||
public static T EnumFlagsField<T>(GUIContent content, T enumValue, params GUILayoutOption[] options) where T : Enum
|
||||
{
|
||||
return (T)EditorGUILayout.EnumFlagsField(content, enumValue, options);
|
||||
}
|
||||
|
||||
public static bool ButtonAuto(GUIContent content, GUIStyle style)
|
||||
{
|
||||
Vector2 size = style.CalcSize(content);
|
||||
return GUILayout.Button(content, style, GUILayout.Width(size.x));
|
||||
}
|
||||
|
||||
public static bool ButtonAuto(LayoutController layout, GUIContent content, GUIStyle style)
|
||||
{
|
||||
Rect rect = layout.ReserveAuto(content, style);
|
||||
return GUI.Button(rect, content, style);
|
||||
}
|
||||
|
||||
public static Vector2 GetMaxContentSize(GUIStyle style, params GUIContent[] contents)
|
||||
{
|
||||
Vector2 maxSize = new Vector2();
|
||||
foreach (GUIContent content in contents)
|
||||
{
|
||||
Vector2 size = style.CalcSize(content);
|
||||
maxSize.x = Mathf.Max(maxSize.x, size.x);
|
||||
maxSize.y = Mathf.Max(maxSize.y, size.y);
|
||||
}
|
||||
|
||||
return maxSize;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: df613967b4fdf486d9a4e932822cec60
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,267 @@
|
||||
using QFSW.QC.Editor.Tools;
|
||||
using QFSW.QC.QGUI;
|
||||
using UnityEditor;
|
||||
using UnityEngine;
|
||||
|
||||
namespace QFSW.QC.Editor
|
||||
{
|
||||
[CustomEditor(typeof(QuantumConsole), true)]
|
||||
public class QuantumConsoleInspector : QCInspectorBase
|
||||
{
|
||||
private QuantumConsole QCInstance;
|
||||
|
||||
private SerializedProperty _themeProperty;
|
||||
private SerializedProperty _keyConfigProperty;
|
||||
private SerializedProperty _localizationProperty;
|
||||
|
||||
private SerializedProperty _verboseLoggingProperty;
|
||||
private SerializedProperty _verboseErrorsProperty;
|
||||
private SerializedProperty _loggingLevelProperty;
|
||||
|
||||
private SerializedProperty _openOnLogLevelProperty;
|
||||
private SerializedProperty _supportedStateProperty;
|
||||
private SerializedProperty _autoScrollProperty;
|
||||
private SerializedProperty _interceptDebugProperty;
|
||||
private SerializedProperty _interceptInactiveProperty;
|
||||
private SerializedProperty _prependTimestampsProperty;
|
||||
private SerializedProperty _activateOnStartupProperty;
|
||||
private SerializedProperty _initialiseOnStartupProperty;
|
||||
private SerializedProperty _focusOnActivateProperty;
|
||||
private SerializedProperty _closeOnSubmitProperty;
|
||||
private SerializedProperty _singletonModeProperty;
|
||||
private SerializedProperty _inputProperty;
|
||||
private SerializedProperty _inputPlaceholderProperty;
|
||||
private SerializedProperty _logProperty;
|
||||
private SerializedProperty _containerProperty;
|
||||
private SerializedProperty _scrollRectProperty;
|
||||
private SerializedProperty _suggestionProperty;
|
||||
private SerializedProperty _popupProperty;
|
||||
private SerializedProperty _popupTextProperty;
|
||||
private SerializedProperty _jobCounterTextProperty;
|
||||
private SerializedProperty _jobCounterRectProperty;
|
||||
private SerializedProperty _panelsProperty;
|
||||
|
||||
private SerializedProperty _commandHistoryProperty;
|
||||
private SerializedProperty _commandHistorySizeProperty;
|
||||
private SerializedProperty _commandHistoryDuplicatesProperty;
|
||||
private SerializedProperty _commandHistoryAdjacentDuplicatesProperty;
|
||||
|
||||
private SerializedProperty _enableAutocompleteProperty;
|
||||
private SerializedProperty _usePopupProperty;
|
||||
private SerializedProperty _maxSuggestionProperty;
|
||||
private SerializedProperty _popupOrderProperty;
|
||||
private SerializedProperty _fuzzyProperty;
|
||||
private SerializedProperty _caseSensitiveProperty;
|
||||
private SerializedProperty _collapseSuggestionOverloadsProperty;
|
||||
|
||||
private SerializedProperty _showCurrentJobsProperty;
|
||||
private SerializedProperty _blockOnAsyncProperty;
|
||||
private SerializedProperty _maxStoredLogsProperty;
|
||||
private SerializedProperty _maxLogSizeProperty;
|
||||
private SerializedProperty _showInitLogsProperty;
|
||||
|
||||
protected override void OnEnable()
|
||||
{
|
||||
base.OnEnable();
|
||||
|
||||
QCInstance = (QuantumConsole)target;
|
||||
QCInstance.OnStateChange += Repaint;
|
||||
|
||||
FetchSerializedProperties();
|
||||
}
|
||||
|
||||
private void FetchSerializedProperties()
|
||||
{
|
||||
_themeProperty = serializedObject.FindProperty("_theme");
|
||||
_keyConfigProperty = serializedObject.FindProperty("_keyConfig");
|
||||
_localizationProperty = serializedObject.FindProperty("_localization");
|
||||
|
||||
_verboseLoggingProperty = serializedObject.FindProperty("_verboseLogging");
|
||||
_verboseErrorsProperty = serializedObject.FindProperty("_verboseErrors");
|
||||
_loggingLevelProperty = serializedObject.FindProperty("_loggingLevel");
|
||||
_openOnLogLevelProperty = serializedObject.FindProperty("_openOnLogLevel");
|
||||
_supportedStateProperty = serializedObject.FindProperty("_supportedState");
|
||||
_autoScrollProperty = serializedObject.FindProperty("_autoScroll");
|
||||
_interceptDebugProperty = serializedObject.FindProperty("_interceptDebugLogger");
|
||||
_interceptInactiveProperty = serializedObject.FindProperty("_interceptWhilstInactive");
|
||||
_prependTimestampsProperty = serializedObject.FindProperty("_prependTimestamps");
|
||||
_activateOnStartupProperty = serializedObject.FindProperty("_activateOnStartup");
|
||||
_initialiseOnStartupProperty = serializedObject.FindProperty("_initialiseOnStartup");
|
||||
_focusOnActivateProperty = serializedObject.FindProperty("_focusOnActivate");
|
||||
_closeOnSubmitProperty = serializedObject.FindProperty("_closeOnSubmit");
|
||||
_singletonModeProperty = serializedObject.FindProperty("_singletonMode");
|
||||
_containerProperty = serializedObject.FindProperty("_containerRect");
|
||||
_scrollRectProperty = serializedObject.FindProperty("_scrollRect");
|
||||
_popupProperty = serializedObject.FindProperty("_suggestionPopupRect");
|
||||
_jobCounterRectProperty = serializedObject.FindProperty("_jobCounterRect");
|
||||
_panelsProperty = serializedObject.FindProperty("_panels");
|
||||
_commandHistoryProperty = serializedObject.FindProperty("_storeCommandHistory");
|
||||
_commandHistoryDuplicatesProperty = serializedObject.FindProperty("_storeDuplicateCommands");
|
||||
_commandHistoryAdjacentDuplicatesProperty = serializedObject.FindProperty("_storeAdjacentDuplicateCommands");
|
||||
_commandHistorySizeProperty = serializedObject.FindProperty("_commandHistorySize");
|
||||
_showCurrentJobsProperty = serializedObject.FindProperty("_showCurrentJobs");
|
||||
_blockOnAsyncProperty = serializedObject.FindProperty("_blockOnAsync");
|
||||
_enableAutocompleteProperty = serializedObject.FindProperty("_enableAutocomplete");
|
||||
_usePopupProperty = serializedObject.FindProperty("_showPopupDisplay");
|
||||
_maxSuggestionProperty = serializedObject.FindProperty("_maxSuggestionDisplaySize");
|
||||
_popupOrderProperty = serializedObject.FindProperty("_suggestionDisplayOrder");
|
||||
_fuzzyProperty = serializedObject.FindProperty("_useFuzzySearch");
|
||||
_caseSensitiveProperty = serializedObject.FindProperty("_caseSensitiveSearch");
|
||||
_collapseSuggestionOverloadsProperty = serializedObject.FindProperty("_collapseSuggestionOverloads");
|
||||
_maxStoredLogsProperty = serializedObject.FindProperty("_maxStoredLogs");
|
||||
_maxLogSizeProperty = serializedObject.FindProperty("_maxLogSize");
|
||||
_showInitLogsProperty = serializedObject.FindProperty("_showInitLogs");
|
||||
|
||||
_inputProperty = serializedObject.FindProperty("_consoleInput");
|
||||
_inputPlaceholderProperty = serializedObject.FindProperty("_inputPlaceholderText");
|
||||
_logProperty = serializedObject.FindProperty("_consoleLogText");
|
||||
_suggestionProperty = serializedObject.FindProperty("_consoleSuggestionText");
|
||||
_popupTextProperty = serializedObject.FindProperty("_suggestionPopupText");
|
||||
_jobCounterTextProperty = serializedObject.FindProperty("_jobCounterText");
|
||||
}
|
||||
|
||||
private void OnDisable()
|
||||
{
|
||||
QCInstance.OnStateChange -= Repaint;
|
||||
}
|
||||
|
||||
public override void OnInspectorGUI()
|
||||
{
|
||||
serializedObject.Update();
|
||||
EditorHelpers.DrawHeader(Banner);
|
||||
|
||||
if (QuantumConsoleProcessor.TableGenerated || QuantumConsoleProcessor.TableIsGenerating)
|
||||
{
|
||||
EditorGUILayout.LabelField("Quantum Console Processor Information", EditorStyles.miniBoldLabel);
|
||||
if (QuantumConsoleProcessor.TableIsGenerating) { EditorGUILayout.LabelField("Command Table Generating...", EditorStyles.miniLabel); }
|
||||
EditorGUILayout.LabelField($"Commands Loaded: {QuantumConsoleProcessor.LoadedCommandCount}", EditorStyles.miniLabel);
|
||||
EditorGUILayout.Space();
|
||||
}
|
||||
|
||||
EditorGUILayout.LabelField(new GUIContent("General Settings", "All general and basic settings for the Quantum Console."), EditorStyles.boldLabel);
|
||||
EditorGUILayout.BeginHorizontal();
|
||||
EditorGUILayout.PropertyField(_themeProperty, new GUIContent("Theme", "QuantumTheme to use for this Quantum Console."));
|
||||
if (_themeProperty.objectReferenceValue)
|
||||
{
|
||||
GUIContent applyBtnContent = new GUIContent("Apply", "Forces an application of the theme now allowing you to see any GUI changes it would make");
|
||||
if (QGUILayout.ButtonAuto(applyBtnContent, EditorStyles.miniButton))
|
||||
{
|
||||
Undo.RecordObject(QCInstance, "Applied a theme to the Quantum Console");
|
||||
QCInstance.ApplyTheme((QuantumTheme)_themeProperty.objectReferenceValue, true);
|
||||
PrefabUtil.RecordPrefabInstancePropertyModificationsFullyRecursive(QCInstance.gameObject);
|
||||
EditorUtility.SetDirty(QCInstance);
|
||||
}
|
||||
}
|
||||
EditorGUILayout.EndHorizontal();
|
||||
EditorGUILayout.PropertyField(_keyConfigProperty, new GUIContent("Key Configuration", "Key configuration for the various keyboard shortcuts used by Quantum Console."));
|
||||
EditorGUILayout.PropertyField(_localizationProperty, new GUIContent("Localization", "Localization configuration for the various messages displayed by Quantum Console."));
|
||||
|
||||
EditorGUILayout.BeginHorizontal();
|
||||
EditorGUILayout.PropertyField(_supportedStateProperty, new GUIContent("Enabled", "On which build/editor states should the console be enabled on"));
|
||||
ShowSceneViewToggle();
|
||||
EditorGUILayout.EndHorizontal();
|
||||
EditorGUILayout.PropertyField(_activateOnStartupProperty, new GUIContent("Activate on Startup", "If the Quantum Console should be shown and activated on startup."));
|
||||
if (!_activateOnStartupProperty.boolValue)
|
||||
{
|
||||
EditorGUILayout.PropertyField(_initialiseOnStartupProperty, new GUIContent("Initialise on Startup", "If the Quantum Console should be initialised on startup in the background."));
|
||||
}
|
||||
|
||||
EditorGUILayout.PropertyField(_focusOnActivateProperty, new GUIContent(
|
||||
"Focus on Activate", "If the input field should automatically be focused when Quantum Console is activated.")
|
||||
);
|
||||
|
||||
EditorGUILayout.PropertyField(_closeOnSubmitProperty, new GUIContent("Close on Submit", "If the Quantum Console should be hidden and closed when a command is submitted and invoked."));
|
||||
EditorGUILayout.PropertyField(_singletonModeProperty, new GUIContent("Singleton", "Forces the console into singleton mode. " +
|
||||
"This means the console will be made scene persistent and will not be destroyed when new scenes are loaded. " +
|
||||
"Additionally, only one instance of the console will be allowed to exist, and it will be accessible via QuantumConsole.Instance"));
|
||||
EditorGUILayout.PropertyField(_verboseErrorsProperty, new GUIContent("Verbose Errors", "If errors caused by the Quantum Console Processor or commands should be logged in verbose mode."));
|
||||
EditorGUILayout.PropertyField(_autoScrollProperty, new GUIContent("Autoscroll", "Determine if and when the console should autoscroll."));
|
||||
EditorGUILayout.Space();
|
||||
|
||||
EditorGUILayout.LabelField(new GUIContent("Debug Interception", "All settings relating to the interception of Unity's Debug class."), EditorStyles.boldLabel);
|
||||
EditorGUILayout.PropertyField(_interceptDebugProperty, new GUIContent("Intercept Debug Messages", "If the Quantum Console should intercept and display messages from the Unity Debug logging."));
|
||||
if (_interceptDebugProperty.boolValue)
|
||||
{
|
||||
EditorGUILayout.PropertyField(_interceptInactiveProperty, new GUIContent("Intercept Whilst Inactive", "If the Quantum Console should continue to intercept messages whilst inactive."));
|
||||
EditorGUILayout.PropertyField(_prependTimestampsProperty, new GUIContent("Enable Timestamps", "If the timestamp of the log message should be prepended."));
|
||||
EditorGUILayout.PropertyField(_loggingLevelProperty, new GUIContent("Logging Level", "The minimum log severity required to intercept and display the log."));
|
||||
EditorGUILayout.PropertyField(_verboseLoggingProperty, new GUIContent("Verbose Logging", "The minimum log severity required to use verbose logging."));
|
||||
EditorGUILayout.PropertyField(_openOnLogLevelProperty, new GUIContent("Open Console", "The minimum log severity required to open the console."));
|
||||
}
|
||||
EditorGUILayout.Space();
|
||||
|
||||
EditorGUILayout.LabelField(new GUIContent("Async Settings", "All settings related to async commands."), EditorStyles.boldLabel);
|
||||
EditorGUILayout.PropertyField(_showCurrentJobsProperty, new GUIContent("Show Current Jobs", "Shows a popup counter with the currently executing async commands."));
|
||||
EditorGUILayout.PropertyField(_blockOnAsyncProperty, new GUIContent("Block on Execute", "Blocks the Quantum Console from being used until the current async command has finished."));
|
||||
EditorGUILayout.Space();
|
||||
|
||||
EditorGUILayout.LabelField(new GUIContent("Autocomplete Settings", "Settings relating to autocomplete and suggestions in the console using tab."), EditorStyles.boldLabel);
|
||||
EditorGUILayout.PropertyField(_enableAutocompleteProperty, new GUIContent("Enable Autocomplete", "If the suggestion and autocomplete system should be enabled."));
|
||||
if (_enableAutocompleteProperty.boolValue)
|
||||
{
|
||||
EditorGUILayout.PropertyField(_fuzzyProperty, new GUIContent("Use Fuzzy Search", "If fuzzy search is disabled, then your current search must match the beginning of the suggestion to be suggested (foo*). If fuzzy search is enabled, it can be anywhere within the suggestion to be suggested (*foo*)."));
|
||||
EditorGUILayout.PropertyField(_caseSensitiveProperty, new GUIContent("Case Sensitive", "If the search should be case sensitive or not."));
|
||||
EditorGUILayout.PropertyField(_collapseSuggestionOverloadsProperty, new GUIContent("Collapse Overloads",
|
||||
"If multiple overloads of the same suggestion should be collapsed into a single suggestion with optional elements where possible." +
|
||||
"\nFor example, the following" +
|
||||
"\ncommand arg0" +
|
||||
"\ncommand arg0 arg1" +
|
||||
"\nWill become" +
|
||||
"\ncommand arg0 [arg1]"));
|
||||
|
||||
EditorGUILayout.PropertyField(_usePopupProperty, new GUIContent("Show Popup Display", "If enabled, a popup display will be shown containing potential auto completions as you type."));
|
||||
if (_usePopupProperty.boolValue)
|
||||
{
|
||||
EditorGUILayout.PropertyField(_maxSuggestionProperty, new GUIContent("Max Suggestion Count", "The maximum number of suggestions to display in the popup. Set to -1 for unlimited."));
|
||||
EditorGUILayout.PropertyField(_popupOrderProperty, new GUIContent("Suggestion Popup Order", "The sort direction used when displaying suggestions to the popup display."));
|
||||
}
|
||||
}
|
||||
EditorGUILayout.Space();
|
||||
|
||||
EditorGUILayout.LabelField(new GUIContent("Command History", "Settings relating to storing previous commands so that they can be easily accessed with the arrow keys."), EditorStyles.boldLabel);
|
||||
EditorGUILayout.PropertyField(_commandHistoryProperty, new GUIContent("Store Previous Commands", "If previous commands should be stored, allowing them to be accessed with the arrow keys."));
|
||||
if (_commandHistoryProperty.boolValue)
|
||||
{
|
||||
EditorGUILayout.PropertyField(_commandHistoryDuplicatesProperty, new GUIContent("Allow Duplicates", "Store commands into the history even if they have already appeared."));
|
||||
if (_commandHistoryDuplicatesProperty.boolValue) { EditorGUILayout.PropertyField(_commandHistoryAdjacentDuplicatesProperty, new GUIContent("Allow Adjacent Duplicates", "Store commands in the history even if they are adjacent duplicates (i.e same command multiple times in a row).")); }
|
||||
_commandHistorySizeProperty.intValue = Mathf.Max(-1, EditorGUILayout.IntField(new GUIContent("Max Size", "The maximum size of the command history buffer; exceeding this size will cause the oldest commands to be removed to make space. Set to -1 for unlimited."), _commandHistorySizeProperty.intValue));
|
||||
}
|
||||
EditorGUILayout.Space();
|
||||
|
||||
EditorGUILayout.LabelField(new GUIContent("Advanced Settings", "Advanced settings such as buffer sizes."), EditorStyles.boldLabel);
|
||||
EditorGUILayout.PropertyField(_maxStoredLogsProperty, new GUIContent("Maximum Stored Logs", "Maximum number of logtraces to store before discarding old logs. Set to -1 for unlimited."));
|
||||
EditorGUILayout.PropertyField(_maxLogSizeProperty, new GUIContent("Maximum Log Size", "Logs exceeding this size will be discarded and an error will be shown. Set to -1 for no maximum size on a single log."));
|
||||
EditorGUILayout.PropertyField(_showInitLogsProperty, new GUIContent("Show Initialization Logs", "Whether the initialization logs should be shown or not."));
|
||||
EditorGUILayout.Space();
|
||||
|
||||
EditorGUILayout.LabelField(new GUIContent("References", "All the references needed by the Quantum Console"), EditorStyles.boldLabel);
|
||||
EditorGUILayout.PropertyField(_containerProperty, new GUIContent("Container Rect", "The top level container rect-transform containing all of the Quantum Console UI elements."));
|
||||
EditorGUILayout.PropertyField(_scrollRectProperty, new GUIContent("Scroll Rect", "(Optional) The scroll rect of the console text, required for auto scrolling."));
|
||||
EditorGUILayout.PropertyField(_popupProperty, new GUIContent("Suggestion Popup Display", "Top level transform for the suggestion popup display."));
|
||||
EditorGUILayout.PropertyField(_jobCounterRectProperty, new GUIContent("Job Counter Display", "Top level transform for the job counter display."));
|
||||
|
||||
EditorGUILayout.PropertyField(_inputProperty, new GUIContent("Console Input Field", "The input field used for interfacing with the Quantum Console."));
|
||||
EditorGUILayout.PropertyField(_inputPlaceholderProperty, new GUIContent("Console Input Placeholder", "The placeholder text component for when the input field is not in use."));
|
||||
EditorGUILayout.PropertyField(_popupTextProperty, new GUIContent("Suggestion Popup Text", "Text display for the suggestion popup display."));
|
||||
EditorGUILayout.PropertyField(_logProperty, new GUIContent("Console Log Display", "The text display used as the log output by the Quantum Console."));
|
||||
EditorGUILayout.PropertyField(_suggestionProperty, new GUIContent("Command Suggestion Display", "(optional) If assigned, the Quantum Console will show the paramater signature for suggested commands here."));
|
||||
EditorGUILayout.PropertyField(_jobCounterTextProperty, new GUIContent("Job Counter Text", "Text display for the job counter display."));
|
||||
|
||||
EditorGUILayout.PropertyField(_panelsProperty, new GUIContent("UI Panels", "All panels in the UI to control with the Quantum Theme."), true);
|
||||
|
||||
serializedObject.ApplyModifiedProperties();
|
||||
}
|
||||
|
||||
private void ShowSceneViewToggle()
|
||||
{
|
||||
RectTransform consoleContainer = (RectTransform)_containerProperty.objectReferenceValue;
|
||||
bool containerFound = consoleContainer;
|
||||
bool containerHidden = containerFound ? consoleContainer.gameObject.activeSelf : false;
|
||||
|
||||
GUI.enabled = containerFound;
|
||||
GUIContent message = new GUIContent(containerFound ? containerHidden ? "Hide Console" : "Show Console" : "Console Missing");
|
||||
if (QGUILayout.ButtonAuto(message, EditorStyles.miniButton)) { consoleContainer.gameObject.SetActive(!consoleContainer.gameObject.activeSelf); }
|
||||
GUI.enabled = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
+12
@@ -0,0 +1,12 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 183567afdaef7164f803d9188375d34b
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences:
|
||||
- banner: {fileID: 2800000, guid: 0a00d33b88ebe3f4eb5dfb0d2a1c0726, type: 3}
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
+86
@@ -0,0 +1,86 @@
|
||||
using UnityEditor;
|
||||
using UnityEngine;
|
||||
|
||||
namespace QFSW.QC.Editor
|
||||
{
|
||||
[CustomEditor(typeof(QuantumKeyConfig))]
|
||||
public class QuantumKeyConfigInspector : QCInspectorBase
|
||||
{
|
||||
private QuantumKeyConfig _keyConfigInstance;
|
||||
|
||||
private SerializedProperty _submitCommandKeyProperty;
|
||||
private SerializedProperty _hideConsoleKeyProperty;
|
||||
private SerializedProperty _showConsoleKeyProperty;
|
||||
private SerializedProperty _toggleConsoleVisibilityKeyProperty;
|
||||
|
||||
private SerializedProperty _zoomInKeyProperty;
|
||||
private SerializedProperty _zoomOutKeyProperty;
|
||||
private SerializedProperty _dragConsoleKeyProperty;
|
||||
|
||||
private SerializedProperty _selectNextSuggestionKeyProperty;
|
||||
private SerializedProperty _selectPreviousSuggestionKeyProperty;
|
||||
|
||||
private SerializedProperty _nextCommandKeyProperty;
|
||||
private SerializedProperty _previousCommandKeyProperty;
|
||||
|
||||
private SerializedProperty _cancelActionsKeyProperty;
|
||||
|
||||
protected override void OnEnable()
|
||||
{
|
||||
base.OnEnable();
|
||||
|
||||
_keyConfigInstance = (QuantumKeyConfig)target;
|
||||
|
||||
_submitCommandKeyProperty = serializedObject.FindProperty("SubmitCommandKey");
|
||||
_hideConsoleKeyProperty = serializedObject.FindProperty("HideConsoleKey");
|
||||
_showConsoleKeyProperty = serializedObject.FindProperty("ShowConsoleKey");
|
||||
_toggleConsoleVisibilityKeyProperty = serializedObject.FindProperty("ToggleConsoleVisibilityKey");
|
||||
|
||||
_zoomInKeyProperty = serializedObject.FindProperty("ZoomInKey");
|
||||
_zoomOutKeyProperty = serializedObject.FindProperty("ZoomOutKey");
|
||||
_dragConsoleKeyProperty = serializedObject.FindProperty("DragConsoleKey");
|
||||
|
||||
_selectNextSuggestionKeyProperty = serializedObject.FindProperty("SelectNextSuggestionKey");
|
||||
_selectPreviousSuggestionKeyProperty = serializedObject.FindProperty("SelectPreviousSuggestionKey");
|
||||
|
||||
_nextCommandKeyProperty = serializedObject.FindProperty("NextCommandKey");
|
||||
_previousCommandKeyProperty = serializedObject.FindProperty("PreviousCommandKey");
|
||||
|
||||
_cancelActionsKeyProperty = serializedObject.FindProperty("CancelActionsKey");
|
||||
}
|
||||
|
||||
public override void OnInspectorGUI()
|
||||
{
|
||||
serializedObject.Update();
|
||||
EditorHelpers.DrawHeader(Banner);
|
||||
|
||||
EditorGUILayout.LabelField(new GUIContent("General"), EditorStyles.boldLabel);
|
||||
EditorGUILayout.PropertyField(_submitCommandKeyProperty, new GUIContent("Submit Command", "The key to submit and invoke the current console input."));
|
||||
EditorGUILayout.PropertyField(_showConsoleKeyProperty, new GUIContent("Show Console", "The key used to show and activate the console."));
|
||||
EditorGUILayout.PropertyField(_hideConsoleKeyProperty, new GUIContent("Hide Console", "The key used to hide and deactivate the console."));
|
||||
EditorGUILayout.PropertyField(_toggleConsoleVisibilityKeyProperty, new GUIContent("Toggle Console", "The key used to toggle the active and visibility state of the console."));
|
||||
EditorGUILayout.Space();
|
||||
|
||||
EditorGUILayout.LabelField(new GUIContent("UI"), EditorStyles.boldLabel);
|
||||
EditorGUILayout.PropertyField(_zoomInKeyProperty, new GUIContent("Zoom In", "Zooms in the console scaling."));
|
||||
EditorGUILayout.PropertyField(_zoomOutKeyProperty, new GUIContent("Zoom Out", "Zooms out the console scaling."));
|
||||
EditorGUILayout.PropertyField(_dragConsoleKeyProperty, new GUIContent("Drag Console", "Drags the console window with the cursor."));
|
||||
EditorGUILayout.Space();
|
||||
|
||||
EditorGUILayout.LabelField(new GUIContent("Autocomplete"), EditorStyles.boldLabel);
|
||||
EditorGUILayout.PropertyField(_selectNextSuggestionKeyProperty, new GUIContent("Select Next Suggestion", "The key to show and select the next autocomplete suggestion."));
|
||||
EditorGUILayout.PropertyField(_selectPreviousSuggestionKeyProperty, new GUIContent("Select Previous Suggestion", "The key to show and select the previous autocomplete suggestion."));
|
||||
EditorGUILayout.Space();
|
||||
|
||||
EditorGUILayout.LabelField(new GUIContent("Command History"), EditorStyles.boldLabel);
|
||||
EditorGUILayout.PropertyField(_nextCommandKeyProperty, new GUIContent("Select Next Command", "The key to be used to select the next command from the console history."));
|
||||
EditorGUILayout.PropertyField(_previousCommandKeyProperty, new GUIContent("Select Previous Command", "The key to be used to select the previous command from the console history."));
|
||||
EditorGUILayout.Space();
|
||||
|
||||
EditorGUILayout.LabelField(new GUIContent("Actions"), EditorStyles.boldLabel);
|
||||
EditorGUILayout.PropertyField(_cancelActionsKeyProperty, new GUIContent("Cancel Actions", "Cancels any actions currently executing."));
|
||||
|
||||
serializedObject.ApplyModifiedProperties();
|
||||
}
|
||||
}
|
||||
}
|
||||
+11
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 37cda8ee039ccf9499ee9ed64f06664a
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
+71
@@ -0,0 +1,71 @@
|
||||
using UnityEditor;
|
||||
using UnityEngine;
|
||||
|
||||
namespace QFSW.QC.Editor
|
||||
{
|
||||
[CustomEditor(typeof(QuantumLocalization), true)]
|
||||
public class QuantumLocalizationInspector : QCInspectorBase
|
||||
{
|
||||
private QuantumLocalization _localizationInstance;
|
||||
|
||||
private SerializedProperty _loadingProperty;
|
||||
private SerializedProperty _executingAsyncCommandProperty;
|
||||
private SerializedProperty _enterCommandProperty;
|
||||
|
||||
private SerializedProperty _commandErrorProperty;
|
||||
private SerializedProperty _consoleErrorProperty;
|
||||
private SerializedProperty _maxLogSizeExceededProperty;
|
||||
|
||||
private SerializedProperty _initializationProgressProperty;
|
||||
private SerializedProperty _initializationCompleteProperty;
|
||||
|
||||
protected override void OnEnable()
|
||||
{
|
||||
base.OnEnable();
|
||||
|
||||
_localizationInstance = (QuantumLocalization)target;
|
||||
|
||||
_loadingProperty = serializedObject.FindProperty("Loading");
|
||||
_executingAsyncCommandProperty = serializedObject.FindProperty("ExecutingAsyncCommand");
|
||||
_enterCommandProperty = serializedObject.FindProperty("EnterCommand");
|
||||
|
||||
_commandErrorProperty = serializedObject.FindProperty("CommandError");
|
||||
_consoleErrorProperty = serializedObject.FindProperty("ConsoleError");
|
||||
_maxLogSizeExceededProperty = serializedObject.FindProperty("MaxLogSizeExceeded");
|
||||
|
||||
_initializationProgressProperty = serializedObject.FindProperty("InitializationProgress");
|
||||
_initializationCompleteProperty = serializedObject.FindProperty("InitializationComplete");
|
||||
}
|
||||
|
||||
public override void OnInspectorGUI()
|
||||
{
|
||||
serializedObject.Update();
|
||||
EditorHelpers.DrawHeader(Banner);
|
||||
|
||||
EditorGUILayout.LabelField(new GUIContent("Prompts", "Prompts to display in the input field."), EditorStyles.boldLabel);
|
||||
EditorGUILayout.PropertyField(_loadingProperty, new GUIContent("Loading", "Prompt during table generation."));
|
||||
EditorGUILayout.PropertyField(_executingAsyncCommandProperty, new GUIContent("Executing Async Command", "Prompt during blocking async command execution."));
|
||||
EditorGUILayout.PropertyField(_enterCommandProperty, new GUIContent("Enter Command", "Prompt when the console is ready for a command to be entered."));
|
||||
EditorGUILayout.Space();
|
||||
|
||||
EditorGUILayout.LabelField(new GUIContent("Errors", "Messages and labels around errors."), EditorStyles.boldLabel);
|
||||
EditorGUILayout.PropertyField(_commandErrorProperty, new GUIContent("Command Error", "The label to prefix command errors with."));
|
||||
EditorGUILayout.PropertyField(_consoleErrorProperty, new GUIContent("Console Error", "The label to prefix console errors with."));
|
||||
EditorGUILayout.PropertyField(_maxLogSizeExceededProperty, new GUIContent("Max Log Size Exceeded Color",
|
||||
"The error message for the max log size being exceeded." +
|
||||
"\n{0} = Log size" +
|
||||
"\n{0} = Max log size"));
|
||||
EditorGUILayout.Space();
|
||||
|
||||
EditorGUILayout.LabelField(new GUIContent("Initialization", "Localization around the initialization updates of Quantum Console."), EditorStyles.boldLabel);
|
||||
EditorGUILayout.PropertyField(_initializationProgressProperty, new GUIContent("Initialization Progress",
|
||||
"The initialization progress message." +
|
||||
"\n{0} = Loaded command count"));
|
||||
EditorGUILayout.PropertyField(_initializationCompleteProperty, new GUIContent("Initialization Complete",
|
||||
"The initialization completion message."));
|
||||
EditorGUILayout.Space();
|
||||
|
||||
serializedObject.ApplyModifiedProperties();
|
||||
}
|
||||
}
|
||||
}
|
||||
+11
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 355b72951d691d34198ebba18a22283f
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,243 @@
|
||||
using QFSW.QC.Utilities;
|
||||
using System;
|
||||
using System.Collections;
|
||||
using UnityEditor;
|
||||
using UnityEditorInternal;
|
||||
using UnityEngine;
|
||||
|
||||
namespace QFSW.QC.Editor
|
||||
{
|
||||
[CustomEditor(typeof(QuantumTheme), true)]
|
||||
public class QuantumThemeInspector : QCInspectorBase
|
||||
{
|
||||
private QuantumTheme _themeInstance;
|
||||
|
||||
private SerializedProperty _fontProperty;
|
||||
private SerializedProperty _panelMaterialProperty;
|
||||
private SerializedProperty _panelColorProperty;
|
||||
|
||||
private SerializedProperty _errorColorProperty;
|
||||
private SerializedProperty _warningColorProperty;
|
||||
private SerializedProperty _successColorProperty;
|
||||
private SerializedProperty _selectedSuggestionColorProperty;
|
||||
private SerializedProperty _suggestionColorProperty;
|
||||
private SerializedProperty _commandLogColorProperty;
|
||||
private SerializedProperty _defaultValueColorProperty;
|
||||
|
||||
private SerializedProperty _timestampFormatProperty;
|
||||
private SerializedProperty _commandLogFormatProperty;
|
||||
|
||||
private ReorderableList _typeFormattersListDisplay;
|
||||
private SerializedProperty _typeFormattersProperty;
|
||||
|
||||
private ReorderableList _collectionFormattersListDisplay;
|
||||
private SerializedProperty _collectionFormattersProperty;
|
||||
|
||||
private GUIStyle _centeredMiniLabel;
|
||||
private GUIStyle _centeredLabel;
|
||||
private GUIStyle _centeredTextField;
|
||||
private bool _initialisedStyles;
|
||||
|
||||
protected override void OnEnable()
|
||||
{
|
||||
base.OnEnable();
|
||||
|
||||
_themeInstance = (QuantumTheme)target;
|
||||
|
||||
_fontProperty = serializedObject.FindProperty("Font");
|
||||
_panelMaterialProperty = serializedObject.FindProperty("PanelMaterial");
|
||||
_panelColorProperty = serializedObject.FindProperty("PanelColor");
|
||||
|
||||
_defaultValueColorProperty = serializedObject.FindProperty("DefaultReturnValueColor");
|
||||
_errorColorProperty = serializedObject.FindProperty("ErrorColor");
|
||||
_warningColorProperty = serializedObject.FindProperty("WarningColor");
|
||||
_successColorProperty = serializedObject.FindProperty("SuccessColor");
|
||||
_selectedSuggestionColorProperty = serializedObject.FindProperty("SelectedSuggestionColor");
|
||||
_suggestionColorProperty = serializedObject.FindProperty("SuggestionColor");
|
||||
_commandLogColorProperty = serializedObject.FindProperty("CommandLogColor");
|
||||
|
||||
_timestampFormatProperty = serializedObject.FindProperty("TimestampFormat");
|
||||
_commandLogFormatProperty = serializedObject.FindProperty("CommandLogFormat");
|
||||
|
||||
_typeFormattersProperty = serializedObject.FindProperty("TypeFormatters");
|
||||
_typeFormattersListDisplay = new ReorderableList(serializedObject, _typeFormattersProperty, true, true, true, true);
|
||||
_typeFormattersListDisplay.onAddCallback = AppendNewTypeFormatter;
|
||||
_typeFormattersListDisplay.drawElementCallback = DrawTypeFormatterInspector;
|
||||
_typeFormattersListDisplay.drawHeaderCallback = DrawTypeFormatterListHeader;
|
||||
|
||||
_collectionFormattersProperty = serializedObject.FindProperty("CollectionFormatters");
|
||||
_collectionFormattersListDisplay = new ReorderableList(serializedObject, _collectionFormattersProperty, true, true, true, true);
|
||||
_collectionFormattersListDisplay.onAddCallback = AppendNewCollectionFormatter;
|
||||
_collectionFormattersListDisplay.drawElementCallback = DrawCollectionFormatterInspector;
|
||||
_collectionFormattersListDisplay.drawHeaderCallback = DrawCollectionFormatterListHeader;
|
||||
}
|
||||
|
||||
private void CreateStyles()
|
||||
{
|
||||
if (!_initialisedStyles)
|
||||
{
|
||||
_initialisedStyles = true;
|
||||
|
||||
_centeredMiniLabel = new GUIStyle(EditorStyles.centeredGreyMiniLabel);
|
||||
_centeredMiniLabel.normal.textColor = EditorGUIUtility.isProSkin ? new Color(0.7f, 0.7f, 0.7f, 1) : new Color(0.3f, 0.3f, 0.3f, 1);
|
||||
|
||||
_centeredLabel = new GUIStyle(EditorStyles.label);
|
||||
_centeredLabel.alignment = TextAnchor.MiddleCenter;
|
||||
_centeredLabel.richText = true;
|
||||
|
||||
_centeredTextField = new GUIStyle(EditorStyles.textField);
|
||||
_centeredTextField.alignment = TextAnchor.MiddleCenter;
|
||||
}
|
||||
}
|
||||
|
||||
public override void OnInspectorGUI()
|
||||
{
|
||||
CreateStyles();
|
||||
serializedObject.Update();
|
||||
EditorHelpers.DrawHeader(Banner);
|
||||
|
||||
EditorGUILayout.LabelField(new GUIContent("UI", "Theme customisations for the Quantum Console UI."), EditorStyles.boldLabel);
|
||||
EditorGUILayout.PropertyField(_fontProperty, new GUIContent("Font", "The font to be used throughout the Quantum Console."));
|
||||
|
||||
EditorGUILayout.PropertyField(_panelMaterialProperty, new GUIContent("Panel Material", "The material to use in the UI panels. Leave null for default."));
|
||||
EditorGUILayout.PropertyField(_panelColorProperty, new GUIContent("Panel Color", "The color to use in the UI panels."));
|
||||
EditorGUILayout.Space();
|
||||
|
||||
EditorGUILayout.LabelField(new GUIContent("Colors", "Color customisation for various aspects of the Quantum Console."), EditorStyles.boldLabel);
|
||||
EditorGUILayout.PropertyField(_errorColorProperty, new GUIContent("Error Color", "The color to use when formatting errors in the console log."));
|
||||
EditorGUILayout.PropertyField(_warningColorProperty, new GUIContent("Warning Color", "The color to use when formatting warnings in the console log."));
|
||||
EditorGUILayout.PropertyField(_successColorProperty, new GUIContent("Success Color", "The color to use when formatting successful void commands."));
|
||||
EditorGUILayout.PropertyField(_selectedSuggestionColorProperty, new GUIContent("Selected Suggestion Color", "The color to use for the selected suggestion from the suggestion popup display."));
|
||||
EditorGUILayout.PropertyField(_suggestionColorProperty, new GUIContent("Suggestion Signature Color", "The color to use when displaying the paramater signature for suggested commands."));
|
||||
EditorGUILayout.PropertyField(_commandLogColorProperty, new GUIContent("Command Log Color", "The color to use when displaying logged commands in the console log."));
|
||||
EditorGUILayout.Space();
|
||||
|
||||
EditorGUILayout.LabelField(new GUIContent("Formatting", "Control various formatting within Quantum Console."), EditorStyles.boldLabel);
|
||||
EditorGUILayout.PropertyField(_timestampFormatProperty, new GUIContent("Timestamp Format",
|
||||
"The format to use when generating timestamps." +
|
||||
"\n{0} = Hour" +
|
||||
"\n{1} = Minute" +
|
||||
"\n{2} = Second"));
|
||||
EditorGUILayout.PropertyField(_commandLogFormatProperty, new GUIContent("Command Log Format",
|
||||
"The format to use when generating command logs." +
|
||||
"\n{0} = The invoked command"));
|
||||
EditorGUILayout.Space();
|
||||
|
||||
EditorGUILayout.LabelField(new GUIContent("Return Value Formatting", "Formatting options for the return serialization"), EditorStyles.boldLabel);
|
||||
EditorGUILayout.PropertyField(_defaultValueColorProperty, new GUIContent("Default Color", "The default color for return values"));
|
||||
_typeFormattersListDisplay.DoLayoutList();
|
||||
_collectionFormattersListDisplay.DoLayoutList();
|
||||
|
||||
serializedObject.ApplyModifiedProperties();
|
||||
}
|
||||
|
||||
private void DrawTypeFormatterInspector(Rect drawRect, int index, bool isActive, bool isFocused)
|
||||
{
|
||||
float nameWidth = 150f;
|
||||
drawRect.y += 2;
|
||||
|
||||
SerializedProperty currentTypeFormatter = _typeFormattersListDisplay.serializedProperty.GetArrayElementAtIndex(index);
|
||||
SerializedProperty colorProperty = currentTypeFormatter.FindPropertyRelative("Color");
|
||||
|
||||
string typeName = _themeInstance.TypeFormatters[index].Type.GetDisplayName();
|
||||
Rect labelRect = new Rect(drawRect.x, drawRect.y, nameWidth, EditorGUIUtility.singleLineHeight);
|
||||
Rect colorRect = new Rect(drawRect.x + nameWidth, drawRect.y, drawRect.width - nameWidth, EditorGUIUtility.singleLineHeight);
|
||||
EditorGUI.LabelField(labelRect, typeName);
|
||||
EditorGUI.PropertyField(colorRect, colorProperty, new GUIContent());
|
||||
}
|
||||
|
||||
private void DrawTypeFormatterListHeader(Rect drawRect)
|
||||
{
|
||||
EditorGUI.LabelField(new Rect(drawRect.x, drawRect.y, 150, drawRect.height), new GUIContent("Type Formatters", "The different colors that should be used for formatting different type returns."));
|
||||
EditorGUI.LabelField(new Rect((drawRect.x + drawRect.width) / 2 - 40, drawRect.y, 80, drawRect.height), _typeFormattersProperty.arraySize.ToString() + (_typeFormattersProperty.arraySize == 1 ? " Formatter" : " Formatters"), _centeredMiniLabel);
|
||||
}
|
||||
|
||||
private void AppendNewTypeFormatter(ReorderableList listTarget)
|
||||
{
|
||||
Action<string> SubmitCallback = (string data) =>
|
||||
{
|
||||
Type type = QuantumParser.ParseType(data);
|
||||
if (type == null) { throw new ArgumentException($"No type of name '{data}' could be found. Are you missing a namespace?"); }
|
||||
|
||||
Undo.RecordObject(_themeInstance, "Added a new Type Formatter");
|
||||
_themeInstance.TypeFormatters.Add(new TypeColorFormatter(type));
|
||||
EditorUtility.SetDirty(_themeInstance);
|
||||
};
|
||||
|
||||
PopupWindow.Show(new Rect(5, 5, 0, 0), new DataEntryPopup("Type Name", "Create Type Formatter", SubmitCallback));
|
||||
}
|
||||
|
||||
private void DrawCollectionFormatterInspector(Rect drawRect, int index, bool isActive, bool isFocused)
|
||||
{
|
||||
float itemWidth = 40f;
|
||||
float dataWidth = 35f;
|
||||
float padding = 5f;
|
||||
float endPadding = 10f;
|
||||
float nameWidth = drawRect.width - (6 * itemWidth + 3 * dataWidth + 5 * padding + endPadding);
|
||||
drawRect.y += 2;
|
||||
|
||||
SerializedProperty currentCollectionFormatter = _collectionFormattersListDisplay.serializedProperty.GetArrayElementAtIndex(index);
|
||||
SerializedProperty seperatorProperty = currentCollectionFormatter.FindPropertyRelative("SeperatorString");
|
||||
SerializedProperty leftScoperProperty = currentCollectionFormatter.FindPropertyRelative("LeftScoper");
|
||||
SerializedProperty rightScoperProperty = currentCollectionFormatter.FindPropertyRelative("RightScoper");
|
||||
|
||||
string typeName = _themeInstance.CollectionFormatters[index].Type.GetDisplayName();
|
||||
Rect rect = new Rect(drawRect.x, drawRect.y, nameWidth, EditorGUIUtility.singleLineHeight);
|
||||
EditorGUI.LabelField(rect, typeName);
|
||||
rect.x += nameWidth + padding;
|
||||
|
||||
Action<SerializedProperty, float> DrawTextField = (SerializedProperty prop, float width) =>
|
||||
{
|
||||
rect.width = width;
|
||||
prop.stringValue = EditorGUI.TextField(rect, new GUIContent(), prop.stringValue, _centeredTextField);
|
||||
rect.x += width + padding;
|
||||
};
|
||||
|
||||
Action<string, float> DrawLabelField = (string text, float width) =>
|
||||
{
|
||||
rect.width = width;
|
||||
EditorGUI.LabelField(rect, text, _centeredLabel);
|
||||
rect.x += width + padding;
|
||||
};
|
||||
|
||||
string highlightCol = EditorGUIUtility.isProSkin ? "#1fe035" : "#005209";
|
||||
string itemCol = EditorGUIUtility.isProSkin ? "#ff8280" : "#6A0301";
|
||||
string example = $"<b><color={highlightCol}>{leftScoperProperty.stringValue}</color></b>" +
|
||||
$"<color={itemCol}>item1</color><b><color={highlightCol}>{seperatorProperty.stringValue}</color></b>" +
|
||||
$"<color={itemCol}>item2</color><b><color={highlightCol}>{rightScoperProperty.stringValue}</color></b>";
|
||||
|
||||
DrawTextField(leftScoperProperty, dataWidth);
|
||||
DrawLabelField("item1", itemWidth);
|
||||
DrawTextField(seperatorProperty, dataWidth);
|
||||
DrawLabelField("item2", itemWidth);
|
||||
DrawTextField(rightScoperProperty, dataWidth);
|
||||
DrawLabelField("<b>=></b>", itemWidth * 1.5f);
|
||||
DrawLabelField(example, itemWidth * 2.5f);
|
||||
}
|
||||
|
||||
private void DrawCollectionFormatterListHeader(Rect drawRect)
|
||||
{
|
||||
EditorGUI.LabelField(new Rect(drawRect.x, drawRect.y, 150, drawRect.height), new GUIContent("Collection Formatters", "The different strings that should be used for seperating and enclosing collections when serialized."));
|
||||
EditorGUI.LabelField(new Rect((drawRect.x + drawRect.width) / 2 - 40, drawRect.y, 80, drawRect.height), _collectionFormattersProperty.arraySize.ToString() + (_collectionFormattersProperty.arraySize == 1 ? " Formatter" : " Formatters"), _centeredMiniLabel);
|
||||
}
|
||||
|
||||
private void AppendNewCollectionFormatter(ReorderableList listTarget)
|
||||
{
|
||||
Action<string> SubmitCallback = (string data) =>
|
||||
{
|
||||
Type type = QuantumParser.ParseType(data);
|
||||
if (type == null) { throw new ArgumentException($"No type of name '{data}' could be found. Are you missing a namespace?"); }
|
||||
if (!typeof(IEnumerable).IsAssignableFrom(type))
|
||||
{
|
||||
throw new ArgumentException("Collection type must implement IEnumerator");
|
||||
}
|
||||
|
||||
Undo.RecordObject(_themeInstance, "Added a new Collection Formatter");
|
||||
_themeInstance.CollectionFormatters.Add(new CollectionFormatter(type));
|
||||
EditorUtility.SetDirty(_themeInstance);
|
||||
};
|
||||
|
||||
PopupWindow.Show(new Rect(5, 5, 0, 0), new DataEntryPopup("Collection Type Name", "Create Collection Formatter", SubmitCallback));
|
||||
}
|
||||
}
|
||||
}
|
||||
+12
@@ -0,0 +1,12 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 3c958f403b85740698edbcc10c951bce
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences:
|
||||
- banner: {fileID: 2800000, guid: 0a00d33b88ebe3f4eb5dfb0d2a1c0726, type: 3}
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 248ef14759720fa4a800416d09dc3b23
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,23 @@
|
||||
using UnityEditor;
|
||||
using UnityEngine;
|
||||
|
||||
namespace QFSW.QC.Editor.Tools
|
||||
{
|
||||
public static class PrefabUtil
|
||||
{
|
||||
public static void RecordPrefabInstancePropertyModificationsFullyRecursive(GameObject objRoot)
|
||||
{
|
||||
PrefabUtility.RecordPrefabInstancePropertyModifications(objRoot);
|
||||
foreach (Component comp in objRoot.GetComponents<Component>())
|
||||
{
|
||||
PrefabUtility.RecordPrefabInstancePropertyModifications(comp);
|
||||
}
|
||||
|
||||
for (int i = 0; i < objRoot.transform.childCount; i++)
|
||||
{
|
||||
Transform child = objRoot.transform.GetChild(i);
|
||||
RecordPrefabInstancePropertyModificationsFullyRecursive(child.gameObject);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 8efd6ec275d0caa46920e3c03f6e3925
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
+14
@@ -0,0 +1,14 @@
|
||||
{
|
||||
"name": "QFSW.QC.Editor.Tools",
|
||||
"references": [],
|
||||
"optionalUnityReferences": [],
|
||||
"includePlatforms": [
|
||||
"Editor"
|
||||
],
|
||||
"excludePlatforms": [],
|
||||
"allowUnsafeCode": false,
|
||||
"overrideReferences": false,
|
||||
"precompiledReferences": [],
|
||||
"autoReferenced": true,
|
||||
"defineConstraints": []
|
||||
}
|
||||
+7
@@ -0,0 +1,7 @@
|
||||
fileFormatVersion: 2
|
||||
guid: a02547252a8685b458cb58325927f320
|
||||
AssemblyDefinitionImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,79 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text.RegularExpressions;
|
||||
using UnityEditor;
|
||||
|
||||
namespace QFSW.QC.Editor.Tools
|
||||
{
|
||||
public static class SymbolEditor
|
||||
{
|
||||
public static IEnumerable<T> AsEnumerable<T>(this T val)
|
||||
{
|
||||
yield return val;
|
||||
}
|
||||
|
||||
private static IEnumerable<BuildTargetGroup> GetPresentBuildTargetGroups()
|
||||
{
|
||||
foreach (BuildTarget target in (BuildTarget[])Enum.GetValues(typeof(BuildTarget)))
|
||||
{
|
||||
BuildTargetGroup group = BuildPipeline.GetBuildTargetGroup(target);
|
||||
if (BuildPipeline.IsBuildTargetSupported(group, target))
|
||||
{
|
||||
yield return group;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static void AddSymbol(string symbol)
|
||||
{
|
||||
AddSymbols(symbol.AsEnumerable());
|
||||
}
|
||||
|
||||
public static void AddSymbols(IEnumerable<string> symbols)
|
||||
{
|
||||
AddSymbols(GetPresentBuildTargetGroups(), symbols);
|
||||
}
|
||||
|
||||
public static void AddSymbols(IEnumerable<BuildTargetGroup> groups, IEnumerable<string> symbols)
|
||||
{
|
||||
foreach (BuildTargetGroup group in groups)
|
||||
{
|
||||
string currentSymbols = PlayerSettings.GetScriptingDefineSymbolsForGroup(group);
|
||||
foreach (string symbol in symbols)
|
||||
{
|
||||
if (!currentSymbols.Contains(symbol))
|
||||
{
|
||||
currentSymbols = $"{currentSymbols};{symbol}";
|
||||
}
|
||||
}
|
||||
|
||||
PlayerSettings.SetScriptingDefineSymbolsForGroup(group, currentSymbols);
|
||||
}
|
||||
}
|
||||
|
||||
public static void RemoveSymbol(string symbol)
|
||||
{
|
||||
RemoveSymbols(symbol.AsEnumerable());
|
||||
}
|
||||
|
||||
public static void RemoveSymbols(IEnumerable<string> symbols)
|
||||
{
|
||||
RemoveSymbols(GetPresentBuildTargetGroups(), symbols);
|
||||
}
|
||||
|
||||
public static void RemoveSymbols(IEnumerable<BuildTargetGroup> groups, IEnumerable<string> symbols)
|
||||
{
|
||||
foreach (BuildTargetGroup group in groups)
|
||||
{
|
||||
string currentSymbols = PlayerSettings.GetScriptingDefineSymbolsForGroup(group);
|
||||
foreach (string symbol in symbols)
|
||||
{
|
||||
currentSymbols = Regex.Replace(currentSymbols, symbol, string.Empty);
|
||||
}
|
||||
|
||||
currentSymbols = string.Join(";", currentSymbols.Split(new char[] { ';' }, StringSplitOptions.RemoveEmptyEntries));
|
||||
PlayerSettings.SetScriptingDefineSymbolsForGroup(group, currentSymbols);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 1078e30699e62674ca299f95eb835efc
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
Reference in New Issue
Block a user