From b63cf341fb362d333e9edd6614dc4c75529d99a4 Mon Sep 17 00:00:00 2001 From: VladV Date: Fri, 30 Jun 2023 15:44:11 +0400 Subject: [PATCH] Tri inspector (#2) Replace drawers with Tri Inspector --- Editor/Adapters.meta | 3 - Editor/Adapters/FloatFormatAdapterEditor.cs | 29 ----- .../Adapters/FloatFormatAdapterEditor.cs.meta | 3 - Editor/Adapters/TextLocalizeAdapterEditor.cs | 26 ----- .../TextLocalizeAdapterEditor.cs.meta | 3 - Editor/Applicators.meta | 3 - .../FormattedTMPTextApplicatorEditor.cs | 57 ---------- .../FormattedTMPTextApplicatorEditor.cs.meta | 3 - .../LocalizedTMPTextApplicatorEditor.cs | 57 ---------- .../LocalizedTMPTextApplicatorEditor.cs.meta | 3 - Editor/CodeWriter.ViewBinding.Editor.asmdef | 7 +- Editor/Odin.meta | 11 +- .../CodeWriter.ViewBinding.Editor.Odin.asmdef | 21 ++++ ...Writer.ViewBinding.Editor.Odin.asmdef.meta | 7 ++ Editor/Odin/OdinViewEntryValidator.cs | 20 ++-- Editor/Odin/OdinViewEntryValidator.cs.meta | 4 +- Editor/SingleResultAdapterBaseEditor.cs | 54 ---------- Editor/SingleResultAdapterBaseEditor.cs.meta | 3 - Editor/Styles.cs | 2 + Editor/ViewContextCollectionValidator.cs | 95 +++++++++++++++++ Editor/ViewContextCollectionValidator.cs.meta | 3 + Editor/ViewContextGUI.cs | 100 ------------------ Editor/ViewContextGUI.cs.meta | 3 - Editor/ViewEntryDrawerBase.cs | 21 +++- Editor/ViewEntryValidator.cs | 19 ++++ Editor/ViewEntryValidator.cs.meta | 3 + README.md | 2 + .../Adapters/BoolToFormattedStringAdapter.cs | 28 ++--- .../Adapters/BoolToStringAdapter.cs | 1 + .../Adapters/FloatFormatAdapter.cs | 15 +++ .../Adapters/TextLocalizeAdapter.cs | 13 ++- Runtime/Applicators/Assembly.cs | 3 + Runtime/Applicators/Assembly.cs.meta | 3 + .../CodeWriter.ViewBinding.Applicators.asmdef | 5 +- .../Applicators/ComponentApplicatorBase.cs | 5 +- .../UI/FormattedTMPTextApplicator.cs | 29 +++-- .../UI/LocalizedTMPTextApplicator.cs | 11 +- Runtime/Assembly.cs | 5 +- Runtime/Binders/UI/ButtonClickBinder.cs | 7 +- Runtime/Binders/UI/InputFieldEndEditBinder.cs | 7 +- .../Binders/UI/InputFieldTextChangedBinder.cs | 7 +- .../Binders/UI/SliderValueChangedBinder.cs | 7 +- .../Binders/UI/ToggleValueChangedBinder.cs | 7 +- Runtime/CodeWriter.ViewBinding.asmdef | 6 +- Runtime/SingleResultAdapterBase.cs | 5 +- Runtime/ViewBindingBehaviour.cs | 2 + Runtime/ViewContextCollectionAttribute.cs | 9 ++ .../ViewContextCollectionAttribute.cs.meta | 3 + Runtime/ViewEntry.cs | 4 +- package.json | 3 +- 50 files changed, 325 insertions(+), 422 deletions(-) delete mode 100644 Editor/Adapters.meta delete mode 100644 Editor/Adapters/FloatFormatAdapterEditor.cs delete mode 100644 Editor/Adapters/FloatFormatAdapterEditor.cs.meta delete mode 100644 Editor/Adapters/TextLocalizeAdapterEditor.cs delete mode 100644 Editor/Adapters/TextLocalizeAdapterEditor.cs.meta delete mode 100644 Editor/Applicators.meta delete mode 100644 Editor/Applicators/FormattedTMPTextApplicatorEditor.cs delete mode 100644 Editor/Applicators/FormattedTMPTextApplicatorEditor.cs.meta delete mode 100644 Editor/Applicators/LocalizedTMPTextApplicatorEditor.cs delete mode 100644 Editor/Applicators/LocalizedTMPTextApplicatorEditor.cs.meta create mode 100644 Editor/Odin/CodeWriter.ViewBinding.Editor.Odin.asmdef create mode 100644 Editor/Odin/CodeWriter.ViewBinding.Editor.Odin.asmdef.meta delete mode 100644 Editor/SingleResultAdapterBaseEditor.cs delete mode 100644 Editor/SingleResultAdapterBaseEditor.cs.meta create mode 100644 Editor/ViewContextCollectionValidator.cs create mode 100644 Editor/ViewContextCollectionValidator.cs.meta delete mode 100644 Editor/ViewContextGUI.cs delete mode 100644 Editor/ViewContextGUI.cs.meta create mode 100644 Editor/ViewEntryValidator.cs create mode 100644 Editor/ViewEntryValidator.cs.meta create mode 100644 Runtime/Applicators/Assembly.cs create mode 100644 Runtime/Applicators/Assembly.cs.meta create mode 100644 Runtime/ViewContextCollectionAttribute.cs create mode 100644 Runtime/ViewContextCollectionAttribute.cs.meta diff --git a/Editor/Adapters.meta b/Editor/Adapters.meta deleted file mode 100644 index 62983a7..0000000 --- a/Editor/Adapters.meta +++ /dev/null @@ -1,3 +0,0 @@ -fileFormatVersion: 2 -guid: 782b189b987347f98c8f91db93b9180e -timeCreated: 1649173350 \ No newline at end of file diff --git a/Editor/Adapters/FloatFormatAdapterEditor.cs b/Editor/Adapters/FloatFormatAdapterEditor.cs deleted file mode 100644 index 72edb25..0000000 --- a/Editor/Adapters/FloatFormatAdapterEditor.cs +++ /dev/null @@ -1,29 +0,0 @@ -using CodeWriter.ViewBinding.Applicators.Adapters; -using UnityEditor; - -namespace CodeWriter.ViewBinding.Editor.Adapters -{ - [CustomEditor(typeof(FloatFormatAdapter))] - public class FloatFormatAdapterEditor : SingleResultAdapterBaseEditor - { - private SerializedProperty _precisionProp; - private SerializedProperty _fixedPrecisionProp; - - public override void OnEnable() - { - base.OnEnable(); - - var resultProp = serializedObject.FindProperty("result"); - _precisionProp = resultProp.FindPropertyRelative("precision"); - _fixedPrecisionProp = resultProp.FindPropertyRelative("fixedPrecision"); - } - - protected override void DoGUI() - { - base.DoGUI(); - - EditorGUILayout.IntSlider(_precisionProp, 0, 10); - EditorGUILayout.PropertyField(_fixedPrecisionProp); - } - } -} \ No newline at end of file diff --git a/Editor/Adapters/FloatFormatAdapterEditor.cs.meta b/Editor/Adapters/FloatFormatAdapterEditor.cs.meta deleted file mode 100644 index 2beb599..0000000 --- a/Editor/Adapters/FloatFormatAdapterEditor.cs.meta +++ /dev/null @@ -1,3 +0,0 @@ -fileFormatVersion: 2 -guid: 23b3361323574566a631a7bc9c794c98 -timeCreated: 1649173363 \ No newline at end of file diff --git a/Editor/Adapters/TextLocalizeAdapterEditor.cs b/Editor/Adapters/TextLocalizeAdapterEditor.cs deleted file mode 100644 index b190635..0000000 --- a/Editor/Adapters/TextLocalizeAdapterEditor.cs +++ /dev/null @@ -1,26 +0,0 @@ -using CodeWriter.ViewBinding.Applicators.Adapters; -using UnityEditor; - -namespace CodeWriter.ViewBinding.Editor.Adapters -{ - [CustomEditor(typeof(TextLocalizeAdapter))] - public class TextLocalizeAdapterEditor : SingleResultAdapterBaseEditor - { - private SerializedProperty _extraContextsProp; - - public override void OnEnable() - { - base.OnEnable(); - - var resultProp = serializedObject.FindProperty("result"); - _extraContextsProp = resultProp.FindPropertyRelative("extraContexts"); - } - - protected override void DoGUI() - { - ViewContextGUI.DrawContextField(serializedObject, null, _extraContextsProp); - - base.DoGUI(); - } - } -} \ No newline at end of file diff --git a/Editor/Adapters/TextLocalizeAdapterEditor.cs.meta b/Editor/Adapters/TextLocalizeAdapterEditor.cs.meta deleted file mode 100644 index 5162e92..0000000 --- a/Editor/Adapters/TextLocalizeAdapterEditor.cs.meta +++ /dev/null @@ -1,3 +0,0 @@ -fileFormatVersion: 2 -guid: 28fa6ce350184cf098fa451c8cf371e2 -timeCreated: 1649400673 \ No newline at end of file diff --git a/Editor/Applicators.meta b/Editor/Applicators.meta deleted file mode 100644 index 83f0691..0000000 --- a/Editor/Applicators.meta +++ /dev/null @@ -1,3 +0,0 @@ -fileFormatVersion: 2 -guid: cddcbd5644a64e848c159446d09459e0 -timeCreated: 1660206320 \ No newline at end of file diff --git a/Editor/Applicators/FormattedTMPTextApplicatorEditor.cs b/Editor/Applicators/FormattedTMPTextApplicatorEditor.cs deleted file mode 100644 index 042c0bc..0000000 --- a/Editor/Applicators/FormattedTMPTextApplicatorEditor.cs +++ /dev/null @@ -1,57 +0,0 @@ -using CodeWriter.ViewBinding.Applicators.UI; -using UnityEditor; -using UnityEngine; - -namespace CodeWriter.ViewBinding.Editor.Applicators -{ - [CustomEditor(typeof(FormattedTMPTextApplicator))] - public class FormattedTMPTextApplicatorEditor : UnityEditor.Editor - { - private const string TargetPropName = "target"; - private const string FormatPropName = "format"; - private const string ExtraContextsPropName = "extraContexts"; - - private static readonly string[] ExcludedProperties = - { - "m_Script", - TargetPropName, - FormatPropName, - ExtraContextsPropName - }; - - private SerializedProperty _formatProp; - private SerializedProperty _extraContextsProp; - - private void OnEnable() - { - _formatProp = serializedObject.FindProperty(FormatPropName); - _extraContextsProp = serializedObject.FindProperty(ExtraContextsPropName); - } - - public override void OnInspectorGUI() - { - serializedObject.Update(); - - ViewContextGUI.DrawContextField(serializedObject, null, _extraContextsProp); - - DrawPropertiesExcluding(serializedObject, ExcludedProperties); - - GUILayout.Space(10); - - EditorGUI.BeginChangeCheck(); - - EditorGUILayout.PropertyField(_formatProp); - - if (EditorGUI.EndChangeCheck()) - { - if (target is FormattedTMPTextApplicator applicator) - { - serializedObject.ApplyModifiedProperties(); - applicator.Apply(); - } - } - - serializedObject.ApplyModifiedProperties(); - } - } -} \ No newline at end of file diff --git a/Editor/Applicators/FormattedTMPTextApplicatorEditor.cs.meta b/Editor/Applicators/FormattedTMPTextApplicatorEditor.cs.meta deleted file mode 100644 index 8c67c8a..0000000 --- a/Editor/Applicators/FormattedTMPTextApplicatorEditor.cs.meta +++ /dev/null @@ -1,3 +0,0 @@ -fileFormatVersion: 2 -guid: 92d7a6140de146be833f39c6451c806d -timeCreated: 1660206324 \ No newline at end of file diff --git a/Editor/Applicators/LocalizedTMPTextApplicatorEditor.cs b/Editor/Applicators/LocalizedTMPTextApplicatorEditor.cs deleted file mode 100644 index adbfd2e..0000000 --- a/Editor/Applicators/LocalizedTMPTextApplicatorEditor.cs +++ /dev/null @@ -1,57 +0,0 @@ -using CodeWriter.ViewBinding.Applicators.UI; -using UnityEditor; -using UnityEngine; - -namespace CodeWriter.ViewBinding.Editor.Applicators -{ - [CustomEditor(typeof(LocalizedTMPTextApplicator))] - public class LocalizedTMPTextApplicatorEditor : UnityEditor.Editor - { - private const string TargetPropName = "target"; - private const string FormatPropName = "format"; - private const string ExtraContextsPropName = "extraContexts"; - - private static readonly string[] ExcludedProperties = - { - "m_Script", - TargetPropName, - FormatPropName, - ExtraContextsPropName - }; - - private SerializedProperty _formatProp; - private SerializedProperty _extraContextsProp; - - private void OnEnable() - { - _formatProp = serializedObject.FindProperty(FormatPropName); - _extraContextsProp = serializedObject.FindProperty(ExtraContextsPropName); - } - - public override void OnInspectorGUI() - { - serializedObject.Update(); - - ViewContextGUI.DrawContextField(serializedObject, null, _extraContextsProp); - - DrawPropertiesExcluding(serializedObject, ExcludedProperties); - - GUILayout.Space(10); - - EditorGUI.BeginChangeCheck(); - - EditorGUILayout.PropertyField(_formatProp); - - if (EditorGUI.EndChangeCheck()) - { - if (target is LocalizedTMPTextApplicator applicator) - { - serializedObject.ApplyModifiedProperties(); - applicator.Apply(); - } - } - - serializedObject.ApplyModifiedProperties(); - } - } -} \ No newline at end of file diff --git a/Editor/Applicators/LocalizedTMPTextApplicatorEditor.cs.meta b/Editor/Applicators/LocalizedTMPTextApplicatorEditor.cs.meta deleted file mode 100644 index 3b06d30..0000000 --- a/Editor/Applicators/LocalizedTMPTextApplicatorEditor.cs.meta +++ /dev/null @@ -1,3 +0,0 @@ -fileFormatVersion: 2 -guid: 2082769bdc1f415dba7d9af374527b3d -timeCreated: 1665468809 \ No newline at end of file diff --git a/Editor/CodeWriter.ViewBinding.Editor.asmdef b/Editor/CodeWriter.ViewBinding.Editor.asmdef index 236810e..8b79993 100644 --- a/Editor/CodeWriter.ViewBinding.Editor.asmdef +++ b/Editor/CodeWriter.ViewBinding.Editor.asmdef @@ -1,15 +1,18 @@ { "name": "CodeWriter.ViewBinding.Editor", + "rootNamespace": "", "references": [ "CodeWriter.ViewBinding", - "CodeWriter.ViewBinding.Applicators" + "CodeWriter.ViewBinding.Applicators", + "TriInspector", + "TriInspector.Editor" ], "includePlatforms": [ "Editor" ], "excludePlatforms": [], "allowUnsafeCode": false, - "overrideReferences": false, + "overrideReferences": true, "precompiledReferences": [], "autoReferenced": true, "defineConstraints": [], diff --git a/Editor/Odin.meta b/Editor/Odin.meta index 3883b33..64bb87b 100644 --- a/Editor/Odin.meta +++ b/Editor/Odin.meta @@ -1,3 +1,8 @@ -fileFormatVersion: 2 -guid: dbe6ba3a6150467fb1d681f229f3759c -timeCreated: 1622444039 \ No newline at end of file +fileFormatVersion: 2 +guid: 12a686176079418abfd1c38b79ae35b1 +folderAsset: yes +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Editor/Odin/CodeWriter.ViewBinding.Editor.Odin.asmdef b/Editor/Odin/CodeWriter.ViewBinding.Editor.Odin.asmdef new file mode 100644 index 0000000..f697529 --- /dev/null +++ b/Editor/Odin/CodeWriter.ViewBinding.Editor.Odin.asmdef @@ -0,0 +1,21 @@ +{ + "name": "CodeWriter.ViewBinding.Editor.Odin", + "rootNamespace": "", + "references": [ + "CodeWriter.ViewBinding", + "TriInspector.Editor.Integrations.Odin" + ], + "includePlatforms": [ + "Editor" + ], + "excludePlatforms": [], + "allowUnsafeCode": false, + "overrideReferences": false, + "precompiledReferences": [], + "autoReferenced": true, + "defineConstraints": [ + "ODIN_INSPECTOR" + ], + "versionDefines": [], + "noEngineReferences": false +} \ No newline at end of file diff --git a/Editor/Odin/CodeWriter.ViewBinding.Editor.Odin.asmdef.meta b/Editor/Odin/CodeWriter.ViewBinding.Editor.Odin.asmdef.meta new file mode 100644 index 0000000..7881e2f --- /dev/null +++ b/Editor/Odin/CodeWriter.ViewBinding.Editor.Odin.asmdef.meta @@ -0,0 +1,7 @@ +fileFormatVersion: 2 +guid: 6657f6e0408f9314a81ef2908b95d74f +AssemblyDefinitionImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Editor/Odin/OdinViewEntryValidator.cs b/Editor/Odin/OdinViewEntryValidator.cs index 4491204..dbe58f5 100644 --- a/Editor/Odin/OdinViewEntryValidator.cs +++ b/Editor/Odin/OdinViewEntryValidator.cs @@ -1,7 +1,7 @@ -#if ODIN_INSPECTOR - -using CodeWriter.ViewBinding.Editor.Odin; +using CodeWriter.ViewBinding.Editor.Odin; +using Sirenix.OdinInspector.Editor; using Sirenix.OdinInspector.Editor.Validation; +using TriInspector.Editor.Integrations.Odin; [assembly: RegisterValidator(typeof(OdinViewEntryValidator<>))] @@ -11,6 +11,16 @@ public class OdinViewEntryValidator : ValueValidator where TViewEntry : ViewEntry { #if ODIN_INSPECTOR_3_1 + public override bool CanValidateProperty(InspectorProperty property) + { + if (TriOdinUtility.IsDrawnByTri(property.Tree.TargetType)) + { + return false; + } + + return base.CanValidateProperty(property); + } + protected override void Validate(ValidationResult result) { ValidateInternal(ValueEntry.SmartValue, result); @@ -34,6 +44,4 @@ private void ValidateInternal(TViewEntry value, ValidationResult result) result.ResultType = ValidationResultType.Error; } } -} - -#endif \ No newline at end of file +} \ No newline at end of file diff --git a/Editor/Odin/OdinViewEntryValidator.cs.meta b/Editor/Odin/OdinViewEntryValidator.cs.meta index 792bee7..a37a3c3 100644 --- a/Editor/Odin/OdinViewEntryValidator.cs.meta +++ b/Editor/Odin/OdinViewEntryValidator.cs.meta @@ -1,3 +1,3 @@ fileFormatVersion: 2 -guid: 0228c77e0266403b89ed7b3d0ea46c3d -timeCreated: 1622444050 \ No newline at end of file +guid: 3dfa09b0a06b47a89e7b5eae5b482dc4 +timeCreated: 1686934413 \ No newline at end of file diff --git a/Editor/SingleResultAdapterBaseEditor.cs b/Editor/SingleResultAdapterBaseEditor.cs deleted file mode 100644 index 3f47fc2..0000000 --- a/Editor/SingleResultAdapterBaseEditor.cs +++ /dev/null @@ -1,54 +0,0 @@ -using UnityEditor; -using UnityEngine; - -namespace CodeWriter.ViewBinding.Editor -{ - [CustomEditor(typeof(SingleResultAdapterBase), true)] - public class SingleResultAdapterBaseEditor : UnityEditor.Editor - { - private const string ResultFieldName = "result"; - private const string ExtraContextsFieldName = "extraContexts"; - - private static readonly GUIContent AliasContent = new GUIContent("Alias"); - - private static readonly string[] ExcludedProps = - { - "m_Script", - ResultFieldName, - ExtraContextsFieldName, - }; - - private SerializedProperty _resultProp; - private SerializedProperty _resultNameProp; - private SerializedProperty _extraContextsProp; - - public virtual void OnEnable() - { - _resultProp = serializedObject.FindProperty(ResultFieldName); - _resultNameProp = _resultProp.FindPropertyRelative("name"); - _extraContextsProp = serializedObject.FindProperty(ExtraContextsFieldName); - } - - public sealed override void OnInspectorGUI() - { - serializedObject.Update(); - - if (_extraContextsProp != null) - { - ViewContextGUI.DrawContextField(serializedObject, null, _extraContextsProp); - GUILayout.Space(10); - } - - DoGUI(); - - serializedObject.ApplyModifiedProperties(); - } - - protected virtual void DoGUI() - { - EditorGUILayout.PropertyField(_resultNameProp, AliasContent); - - DrawPropertiesExcluding(serializedObject, ExcludedProps); - } - } -} \ No newline at end of file diff --git a/Editor/SingleResultAdapterBaseEditor.cs.meta b/Editor/SingleResultAdapterBaseEditor.cs.meta deleted file mode 100644 index 05ac10f..0000000 --- a/Editor/SingleResultAdapterBaseEditor.cs.meta +++ /dev/null @@ -1,3 +0,0 @@ -fileFormatVersion: 2 -guid: d08e88a292c044839016461aa3b151ba -timeCreated: 1648657650 \ No newline at end of file diff --git a/Editor/Styles.cs b/Editor/Styles.cs index 8d6a3cf..c0f0122 100644 --- a/Editor/Styles.cs +++ b/Editor/Styles.cs @@ -5,6 +5,8 @@ namespace CodeWriter.ViewBinding.Editor { internal static class Styles { + public static readonly GUIContent NoneContent = GUIContent.none; + public static readonly GUIStyle RedBoldLabel; static Styles() diff --git a/Editor/ViewContextCollectionValidator.cs b/Editor/ViewContextCollectionValidator.cs new file mode 100644 index 0000000..4248d75 --- /dev/null +++ b/Editor/ViewContextCollectionValidator.cs @@ -0,0 +1,95 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Reflection; +using CodeWriter.ViewBinding.Editor; +using TriInspector; +using UnityEngine; + +[assembly: RegisterTriAttributeValidator(typeof(ViewContextCollectionValidator))] + +namespace CodeWriter.ViewBinding.Editor +{ + public class ViewContextCollectionValidator : TriAttributeValidator + { + private static readonly List TempContexts = new List(); + private static readonly List TempSelfValues = new List(); + + public override TriExtensionInitializationResult Initialize(TriPropertyDefinition propertyDefinition) + { + if (propertyDefinition.FieldType != typeof(ViewContextBase[]) && + propertyDefinition.FieldType != typeof(List)) + { + return "[ExtraViewContextCollection] can be used only on List"; + } + + return base.Initialize(propertyDefinition); + } + + public override TriValidationResult Validate(TriProperty property) + { + var mb = property.PropertyTree.RootProperty.Value as MonoBehaviour; + + if (mb == null) + { + return TriValidationResult.Warning("TargetObject is not MonoBehaviour"); + } + + FillContext(mb, TempContexts); + + if (TempContexts.SequenceEqual(property.Value as IList ?? Array.Empty())) + { + return TriValidationResult.Valid; + } + + return CreateFix(mb, property); + } + + private TriValidationResult CreateFix(MonoBehaviour mb, TriProperty property) + { + return TriValidationResult.Info("Contexts is out of sync").WithFix(() => + { + FillContext(mb, TempContexts); + + var convertedContexts = property.FieldType == typeof(ViewContextBase[]) + ? (object) TempContexts.ToArray() + : TempContexts.ToList(); + + if (!property.TryGetMemberInfo(out var mi)) + { + return; + } + + switch (mi) + { + case FieldInfo fi: + fi.SetValue(property.Parent.Value, convertedContexts); + break; + + case PropertyInfo pi: + pi.SetValue(property.Parent.Value, convertedContexts); + break; + } + }, "Fill Contexts"); + } + + private static void FillContext(MonoBehaviour mb, List contexts) + { + contexts.Clear(); + mb.GetComponentsInParent(true, contexts); + contexts.RemoveAll(it => it == null || it == mb); + + if (mb is ViewContextBase targetViewContext) + { + mb.GetComponents(TempSelfValues); + + contexts.RemoveAll(it => + { + var selfIndex = TempSelfValues.IndexOf(targetViewContext); + var otherIndex = TempSelfValues.IndexOf(it); + return selfIndex < otherIndex; + }); + } + } + } +} \ No newline at end of file diff --git a/Editor/ViewContextCollectionValidator.cs.meta b/Editor/ViewContextCollectionValidator.cs.meta new file mode 100644 index 0000000..fec6e80 --- /dev/null +++ b/Editor/ViewContextCollectionValidator.cs.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: 8378e21bf06740e9af4d60ca048f9c2e +timeCreated: 1686924032 \ No newline at end of file diff --git a/Editor/ViewContextGUI.cs b/Editor/ViewContextGUI.cs deleted file mode 100644 index 805c3bd..0000000 --- a/Editor/ViewContextGUI.cs +++ /dev/null @@ -1,100 +0,0 @@ -using System; -using System.Collections.Generic; -using JetBrains.Annotations; -using UnityEditor; -using UnityEngine; - -namespace CodeWriter.ViewBinding.Editor -{ - public static class ViewContextGUI - { - private static readonly GUIContent ContextContent = new GUIContent("Context"); - - public static void DrawContextField( - SerializedObject serializedObject, - [CanBeNull] SerializedProperty primaryContextProp = null, - [CanBeNull] SerializedProperty extraContextsProp = null) - { - GUILayout.BeginHorizontal(); - - EditorGUILayout.PrefixLabel(ContextContent); - - GUILayout.BeginVertical(); - EditorGUI.BeginDisabledGroup(true); - - if (primaryContextProp != null) - { - EditorGUILayout.PropertyField(primaryContextProp); - } - - if (extraContextsProp != null) - { - for (var i = 0; i < extraContextsProp.arraySize; i++) - { - EditorGUILayout.PropertyField(extraContextsProp.GetArrayElementAtIndex(i), GUIContent.none); - } - - if (extraContextsProp.arraySize == 0) - { - GUILayout.Label("None", EditorStyles.objectField); - } - } - - EditorGUI.EndDisabledGroup(); - GUILayout.EndVertical(); - - if (GUILayout.Button("Fill Context", GUILayout.Width(100))) - { - FillContext(serializedObject, primaryContextProp, extraContextsProp); - } - - GUILayout.EndHorizontal(); - } - - private static void FillContext( - SerializedObject serializedObject, - [CanBeNull] SerializedProperty primaryContextProp, - [CanBeNull] SerializedProperty extraContextsProp) - { - if (serializedObject.targetObject is MonoBehaviour mb) - { - ViewContext primaryContext = null; - - if (primaryContextProp != null) - { - primaryContext = mb.GetComponentInParent(); - primaryContextProp.objectReferenceValue = primaryContext; - } - - if (extraContextsProp != null) - { - var allValues = mb.GetComponentsInParent(); - - var extraContexts = new List(); - extraContexts.AddRange(allValues); - extraContexts.RemoveAll(it => it == null || it == mb || it == primaryContext); - - if (mb is ViewContextBase targetViewContext) - { - var selfValues = mb.GetComponents(); - - extraContexts.RemoveAll(it => - { - var selfIndex = Array.IndexOf(selfValues, targetViewContext); - var otherIndex = Array.IndexOf(selfValues, it); - return selfIndex < otherIndex; - }); - } - - extraContextsProp.arraySize = extraContexts.Count; - for (var i = 0; i < extraContexts.Count; i++) - { - extraContextsProp.GetArrayElementAtIndex(i).objectReferenceValue = extraContexts[i]; - } - } - - serializedObject.ApplyModifiedProperties(); - } - } - } -} \ No newline at end of file diff --git a/Editor/ViewContextGUI.cs.meta b/Editor/ViewContextGUI.cs.meta deleted file mode 100644 index 3579eb7..0000000 --- a/Editor/ViewContextGUI.cs.meta +++ /dev/null @@ -1,3 +0,0 @@ -fileFormatVersion: 2 -guid: c73b32406e434d87a3c51ef2005a8b10 -timeCreated: 1660204712 \ No newline at end of file diff --git a/Editor/ViewEntryDrawerBase.cs b/Editor/ViewEntryDrawerBase.cs index 2e87ced..cb79192 100644 --- a/Editor/ViewEntryDrawerBase.cs +++ b/Editor/ViewEntryDrawerBase.cs @@ -8,6 +8,8 @@ namespace CodeWriter.ViewBinding.Editor internal abstract class ViewEntryDrawerBase : PropertyDrawer where TEntry : ViewEntry { + private static readonly List dirtyTargetObjects = new List(); + private const string NameFieldName = "name"; private const string ContextFieldName = "context"; @@ -22,13 +24,20 @@ public override void OnGUI(Rect position, SerializedProperty property, GUIConten position = EditorGUI.PrefixLabel(position, label); - var disabled = Application.isPlaying || - (EditorUtility.IsPersistent(property.serializedObject.targetObject)); + var targetObject = property.serializedObject.targetObject; + + var disabled = Application.isPlaying || (EditorUtility.IsPersistent(targetObject)); using (new EditorGUI.DisabledScope(disabled)) { DrawContent(position, property); } + if (dirtyTargetObjects.Contains(targetObject)) + { + dirtyTargetObjects.Remove(targetObject); + GUI.changed = true; + } + EditorGUI.EndProperty(); } @@ -37,6 +46,12 @@ private void DrawContent(Rect position, SerializedProperty property) var nameProp = property.FindPropertyRelative(NameFieldName); var contextProp = property.FindPropertyRelative(ContextFieldName); + if (property.serializedObject.targetObject == contextProp.objectReferenceValue) + { + EditorGUI.PropertyField(position, nameProp, Styles.NoneContent); + return; + } + if (GUI.Button(position, nameProp.stringValue, EditorStyles.popup)) { ShowEntryDropDown(position, property, nameProp, contextProp); @@ -73,6 +88,8 @@ private void ShowEntryDropDown(Rect position, SerializedProperty selfProp, Seria nameProp.stringValue = matchedEntry.Name; contextProp.objectReferenceValue = matchedContext; nameProp.serializedObject.ApplyModifiedProperties(); + + dirtyTargetObjects.Add(mb); }); } } diff --git a/Editor/ViewEntryValidator.cs b/Editor/ViewEntryValidator.cs new file mode 100644 index 0000000..da6b0df --- /dev/null +++ b/Editor/ViewEntryValidator.cs @@ -0,0 +1,19 @@ +using CodeWriter.ViewBinding.Editor; +using TriInspector; + +[assembly: RegisterTriValueValidator(typeof(ViewEntryValidator))] + +namespace CodeWriter.ViewBinding.Editor +{ + public class ViewEntryValidator : TriValueValidator + { + public override TriValidationResult Validate(TriValue propertyValue) + { + var message = propertyValue.SmartValue.GetErrorMessage(); + + return message == null + ? TriValidationResult.Valid + : TriValidationResult.Error(message); + } + } +} \ No newline at end of file diff --git a/Editor/ViewEntryValidator.cs.meta b/Editor/ViewEntryValidator.cs.meta new file mode 100644 index 0000000..747ea60 --- /dev/null +++ b/Editor/ViewEntryValidator.cs.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: 314c449570aa471b974ee178c59ba2a6 +timeCreated: 1686821253 \ No newline at end of file diff --git a/README.md b/README.md index 7f4534a..346ead5 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,8 @@ # View Binding [![Github license](https://img.shields.io/github/license/codewriter-packages/View-Binding.svg?style=flat-square)](#) [![Unity 2020.1](https://img.shields.io/badge/Unity-2020.1+-2296F3.svg?style=flat-square)](#) ![GitHub package.json version](https://img.shields.io/github/package-json/v/codewriter-packages/View-Binding?style=flat-square) [![openupm](https://img.shields.io/npm/v/com.codewriter.view-binding?label=openupm®istry_uri=https://package.openupm.com)](https://openupm.com/packages/com.codewriter.view-binding/) _View binding library for unity_ +#### NOTE: To use View Binding library you need to install [Tri Inspector](https://github.com/codewriter-packages/Tri-Inspector) - Free and open-source library that improves unity inspector. + ## How to use? #### 1. Setup ViewContext diff --git a/Runtime/Applicators/Adapters/BoolToFormattedStringAdapter.cs b/Runtime/Applicators/Adapters/BoolToFormattedStringAdapter.cs index 1a9361d..1c2cde5 100644 --- a/Runtime/Applicators/Adapters/BoolToFormattedStringAdapter.cs +++ b/Runtime/Applicators/Adapters/BoolToFormattedStringAdapter.cs @@ -1,10 +1,12 @@ using System; +using TriInspector; +using UnityEngine; -namespace CodeWriter.ViewBinding.Applicators.Adapters { - using UnityEngine; - +namespace CodeWriter.ViewBinding.Applicators.Adapters +{ [AddComponentMenu("View Binding/Adapters/[Binding] Bool To Formatted String Adapter")] - public class BoolToFormattedStringAdapter : SingleResultAdapterBase { + public class BoolToFormattedStringAdapter : SingleResultAdapterBase + { [Space] [SerializeField] private ViewVariableBool source; @@ -15,22 +17,22 @@ public class BoolToFormattedStringAdapter : SingleResultAdapterBase(); - protected override string Adapt() { + protected override string Adapt() + { var textBuilder = new ValueTextBuilder(ValueTextBuilder.DefaultCapacity); - try { - if (source.Value) { - textBuilder.AppendFormat(trueFormat, extraContexts); - } - else { - textBuilder.AppendFormat(falseFormat, extraContexts); - } + try + { + textBuilder.AppendFormat(source.Value ? trueFormat : falseFormat, extraContexts); return new string(textBuilder.RawCharArray, 0, textBuilder.Length); } - finally { + finally + { textBuilder.Dispose(); } } diff --git a/Runtime/Applicators/Adapters/BoolToStringAdapter.cs b/Runtime/Applicators/Adapters/BoolToStringAdapter.cs index 2114f87..7465ac4 100644 --- a/Runtime/Applicators/Adapters/BoolToStringAdapter.cs +++ b/Runtime/Applicators/Adapters/BoolToStringAdapter.cs @@ -1,3 +1,4 @@ +using TriInspector; using UnityEngine; namespace CodeWriter.ViewBinding.Applicators.Adapters diff --git a/Runtime/Applicators/Adapters/FloatFormatAdapter.cs b/Runtime/Applicators/Adapters/FloatFormatAdapter.cs index 21d7965..4484f9a 100644 --- a/Runtime/Applicators/Adapters/FloatFormatAdapter.cs +++ b/Runtime/Applicators/Adapters/FloatFormatAdapter.cs @@ -1,4 +1,5 @@ using System; +using TriInspector; using UnityEngine; namespace CodeWriter.ViewBinding.Applicators.Adapters @@ -10,6 +11,20 @@ public class FloatFormatAdapter : SingleResultAdapterBase result.precision; + set => result.precision = value; + } + + [ShowInInspector] + public bool FixedPrecision + { + get => result.fixedPrecision; + set => result.fixedPrecision = value; + } + [Serializable] public class ViewVariableFloatFormatted : ViewVariable { diff --git a/Runtime/Applicators/Adapters/TextLocalizeAdapter.cs b/Runtime/Applicators/Adapters/TextLocalizeAdapter.cs index 757d403..d21ec22 100644 --- a/Runtime/Applicators/Adapters/TextLocalizeAdapter.cs +++ b/Runtime/Applicators/Adapters/TextLocalizeAdapter.cs @@ -1,4 +1,5 @@ using System; +using TriInspector; using UnityEngine; using UnityEngine.Scripting; @@ -8,9 +9,19 @@ namespace CodeWriter.ViewBinding.Applicators.Adapters public class TextLocalizeAdapter : SingleResultAdapterBase { [Space] + [Required] [SerializeField] private string format = ""; + [Required] + [ShowInInspector] + [ViewContextCollection] + public ViewContextBase[] ExtraContexts + { + get => result.extraContexts; + set => result.extraContexts = value; + } + protected override string Adapt() { return format; @@ -20,7 +31,7 @@ protected override string Adapt() public class ViewVariableStringLocalized : ViewVariable { [SerializeField] - private ViewContextBase[] extraContexts = null; + internal ViewContextBase[] extraContexts = null; [Preserve] public ViewVariableStringLocalized() diff --git a/Runtime/Applicators/Assembly.cs b/Runtime/Applicators/Assembly.cs new file mode 100644 index 0000000..68bd556 --- /dev/null +++ b/Runtime/Applicators/Assembly.cs @@ -0,0 +1,3 @@ +using TriInspector; + +[assembly: DrawWithTriInspector] \ No newline at end of file diff --git a/Runtime/Applicators/Assembly.cs.meta b/Runtime/Applicators/Assembly.cs.meta new file mode 100644 index 0000000..9ae83c2 --- /dev/null +++ b/Runtime/Applicators/Assembly.cs.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: b2d167bc40f34a94b68aec4185a6186f +timeCreated: 1686820189 \ No newline at end of file diff --git a/Runtime/Applicators/CodeWriter.ViewBinding.Applicators.asmdef b/Runtime/Applicators/CodeWriter.ViewBinding.Applicators.asmdef index 2509f57..c02fc67 100644 --- a/Runtime/Applicators/CodeWriter.ViewBinding.Applicators.asmdef +++ b/Runtime/Applicators/CodeWriter.ViewBinding.Applicators.asmdef @@ -5,12 +5,13 @@ "CodeWriter.ViewBinding", "UniMob", "UniMob.UI", - "Unity.TextMeshPro" + "Unity.TextMeshPro", + "TriInspector" ], "includePlatforms": [], "excludePlatforms": [], "allowUnsafeCode": false, - "overrideReferences": false, + "overrideReferences": true, "precompiledReferences": [], "autoReferenced": false, "defineConstraints": [], diff --git a/Runtime/Applicators/ComponentApplicatorBase.cs b/Runtime/Applicators/ComponentApplicatorBase.cs index d1e429c..9b33bb0 100644 --- a/Runtime/Applicators/ComponentApplicatorBase.cs +++ b/Runtime/Applicators/ComponentApplicatorBase.cs @@ -1,3 +1,4 @@ +using TriInspector; using UnityEngine; namespace CodeWriter.ViewBinding.Applicators @@ -6,9 +7,7 @@ public abstract class ComponentApplicatorBase : ApplicatorBa where TTarget : Component where TVariable : ViewVariable { -#if ODIN_INSPECTOR - [Sirenix.OdinInspector.Required] -#endif + [Required] [SerializeField] private TTarget target; diff --git a/Runtime/Applicators/UI/FormattedTMPTextApplicator.cs b/Runtime/Applicators/UI/FormattedTMPTextApplicator.cs index 617561e..ac2f4f4 100644 --- a/Runtime/Applicators/UI/FormattedTMPTextApplicator.cs +++ b/Runtime/Applicators/UI/FormattedTMPTextApplicator.cs @@ -1,35 +1,43 @@ using System; +using TriInspector; using UnityEngine; -namespace CodeWriter.ViewBinding.Applicators.UI { +namespace CodeWriter.ViewBinding.Applicators.UI +{ using TMPro; [DisallowMultipleComponent] [RequireComponent(typeof(TMP_Text))] [AddComponentMenu("View Binding/UI/[Binding] Formatted TMP Text Applicator")] - public sealed class FormattedTMPTextApplicator : ApplicatorBase { + public sealed class FormattedTMPTextApplicator : ApplicatorBase + { + [Required] [SerializeField] -#if ODIN_INSPECTOR - [Sirenix.OdinInspector.Required] -#endif private TMP_Text target; + [Required] [SerializeField] + [OnValueChanged(nameof(Apply))] private string format; + [Required] [SerializeField] + [ViewContextCollection] private ViewContextBase[] extraContexts = Array.Empty(); - protected override void Apply() { + protected override void Apply() + { var textBuilder = new ValueTextBuilder(ValueTextBuilder.DefaultCapacity); - try { + try + { textBuilder.AppendFormat(format, extraContexts); target.SetText(textBuilder.RawCharArray, 0, textBuilder.Length); } - finally { + finally + { textBuilder.Dispose(); } - + #if UNITY_EDITOR if (!Application.isPlaying) { @@ -49,7 +57,8 @@ protected override void OnValidate() } } - protected override void Reset() { + protected override void Reset() + { base.Reset(); target = GetComponent(); diff --git a/Runtime/Applicators/UI/LocalizedTMPTextApplicator.cs b/Runtime/Applicators/UI/LocalizedTMPTextApplicator.cs index fe85c7f..6ce216c 100644 --- a/Runtime/Applicators/UI/LocalizedTMPTextApplicator.cs +++ b/Runtime/Applicators/UI/LocalizedTMPTextApplicator.cs @@ -1,4 +1,5 @@ using System; +using TriInspector; namespace CodeWriter.ViewBinding { @@ -10,16 +11,18 @@ namespace CodeWriter.ViewBinding [AddComponentMenu("View Binding/UI/[Binding] Localized TMP Text Applicator")] public class LocalizedTMPTextApplicator : ApplicatorBase { + [Required] [SerializeField] -#if ODIN_INSPECTOR - [Sirenix.OdinInspector.Required] -#endif private TMP_Text target; + [Required] [SerializeField] + [OnValueChanged(nameof(Apply))] private string format; + [Required] [SerializeField] + [ViewContextCollection] private ViewContextBase[] extraContexts = Array.Empty(); protected override void Apply() @@ -38,7 +41,7 @@ protected override void Apply() localizedTextBuilder.Dispose(); textBuilder.Dispose(); } - + #if UNITY_EDITOR if (!Application.isPlaying) { diff --git a/Runtime/Assembly.cs b/Runtime/Assembly.cs index 77cf8bf..c84dbd3 100644 --- a/Runtime/Assembly.cs +++ b/Runtime/Assembly.cs @@ -1,3 +1,6 @@ using System.Runtime.CompilerServices; +using TriInspector; -[assembly: InternalsVisibleTo("CodeWriter.ViewBinding.Editor")] \ No newline at end of file +[assembly: InternalsVisibleTo("CodeWriter.ViewBinding.Editor")] +[assembly: InternalsVisibleTo("CodeWriter.ViewBinding.Editor.Odin")] +[assembly: DrawWithTriInspector] \ No newline at end of file diff --git a/Runtime/Binders/UI/ButtonClickBinder.cs b/Runtime/Binders/UI/ButtonClickBinder.cs index a22c1cb..821209e 100644 --- a/Runtime/Binders/UI/ButtonClickBinder.cs +++ b/Runtime/Binders/UI/ButtonClickBinder.cs @@ -1,3 +1,4 @@ +using TriInspector; using UniMob; using UnityEngine; using UnityEngine.UI; @@ -8,10 +9,8 @@ namespace CodeWriter.ViewBinding.Binders.UI [RequireComponent(typeof(Button))] public class ButtonClickBinder : ViewBindingBehaviour { -#if ODIN_INSPECTOR - [Sirenix.OdinInspector.Required] -#endif - [SerializeField, HideInInspector] + [Required] + [SerializeField] private Button button; [SerializeField] diff --git a/Runtime/Binders/UI/InputFieldEndEditBinder.cs b/Runtime/Binders/UI/InputFieldEndEditBinder.cs index df2702b..8a84c46 100644 --- a/Runtime/Binders/UI/InputFieldEndEditBinder.cs +++ b/Runtime/Binders/UI/InputFieldEndEditBinder.cs @@ -1,3 +1,4 @@ +using TriInspector; using UniMob; using UnityEngine; using UnityEngine.UI; @@ -8,10 +9,8 @@ namespace CodeWriter.ViewBinding.Binders.UI [RequireComponent(typeof(InputField))] public class InputFieldEndEditBinder : ViewBindingBehaviour { -#if ODIN_INSPECTOR - [Sirenix.OdinInspector.Required] -#endif - [SerializeField, HideInInspector] + [Required] + [SerializeField] private InputField inputField; [SerializeField] diff --git a/Runtime/Binders/UI/InputFieldTextChangedBinder.cs b/Runtime/Binders/UI/InputFieldTextChangedBinder.cs index 6ee5590..43f2cba 100644 --- a/Runtime/Binders/UI/InputFieldTextChangedBinder.cs +++ b/Runtime/Binders/UI/InputFieldTextChangedBinder.cs @@ -1,3 +1,4 @@ +using TriInspector; using UniMob; using UnityEngine; using UnityEngine.UI; @@ -8,10 +9,8 @@ namespace CodeWriter.ViewBinding.Binders.UI [RequireComponent(typeof(InputField))] public class InputFieldTextChangedBinder : ViewBindingBehaviour { -#if ODIN_INSPECTOR - [Sirenix.OdinInspector.Required] -#endif - [SerializeField, HideInInspector] + [Required] + [SerializeField] private InputField inputField; [SerializeField] diff --git a/Runtime/Binders/UI/SliderValueChangedBinder.cs b/Runtime/Binders/UI/SliderValueChangedBinder.cs index 2596fe2..227982f 100644 --- a/Runtime/Binders/UI/SliderValueChangedBinder.cs +++ b/Runtime/Binders/UI/SliderValueChangedBinder.cs @@ -1,3 +1,4 @@ +using TriInspector; using UniMob; using UnityEngine; using UnityEngine.UI; @@ -8,10 +9,8 @@ namespace CodeWriter.ViewBinding.Binders.UI [RequireComponent(typeof(Slider))] public class SliderValueChangedBinder : ViewBindingBehaviour { -#if ODIN_INSPECTOR - [Sirenix.OdinInspector.Required] -#endif - [SerializeField, HideInInspector] + [Required] + [SerializeField] private Slider slider; [SerializeField] diff --git a/Runtime/Binders/UI/ToggleValueChangedBinder.cs b/Runtime/Binders/UI/ToggleValueChangedBinder.cs index c741d87..8c4791b 100644 --- a/Runtime/Binders/UI/ToggleValueChangedBinder.cs +++ b/Runtime/Binders/UI/ToggleValueChangedBinder.cs @@ -1,3 +1,4 @@ +using TriInspector; using UniMob; using UnityEngine; using UnityEngine.UI; @@ -8,10 +9,8 @@ namespace CodeWriter.ViewBinding.Binders.UI [RequireComponent(typeof(Toggle))] public class ToggleValueChangedBinder : ViewBindingBehaviour { -#if ODIN_INSPECTOR - [Sirenix.OdinInspector.Required] -#endif - [SerializeField, HideInInspector] + [Required] + [SerializeField] private Toggle toggle; [SerializeField] diff --git a/Runtime/CodeWriter.ViewBinding.asmdef b/Runtime/CodeWriter.ViewBinding.asmdef index c2d5edf..5702430 100644 --- a/Runtime/CodeWriter.ViewBinding.asmdef +++ b/Runtime/CodeWriter.ViewBinding.asmdef @@ -1,13 +1,15 @@ { "name": "CodeWriter.ViewBinding", + "rootNamespace": "", "references": [ "UniMob", - "UniMob.UI" + "UniMob.UI", + "TriInspector" ], "includePlatforms": [], "excludePlatforms": [], "allowUnsafeCode": false, - "overrideReferences": false, + "overrideReferences": true, "precompiledReferences": [], "autoReferenced": true, "defineConstraints": [], diff --git a/Runtime/SingleResultAdapterBase.cs b/Runtime/SingleResultAdapterBase.cs index a6f7ebe..52229a9 100644 --- a/Runtime/SingleResultAdapterBase.cs +++ b/Runtime/SingleResultAdapterBase.cs @@ -1,3 +1,4 @@ +using TriInspector; using UniMob; using UnityEngine; using UnityEngine.Scripting; @@ -13,7 +14,9 @@ public abstract class SingleResultAdapterBase : Single where TResultVariable : ViewVariable, new() { [SerializeField] - private TResultVariable result; + [LabelText("Alias")] + [PropertyOrder(-1)] + protected TResultVariable result; [Preserve] public SingleResultAdapterBase() diff --git a/Runtime/ViewBindingBehaviour.cs b/Runtime/ViewBindingBehaviour.cs index 1b1cbc6..48cf0fa 100644 --- a/Runtime/ViewBindingBehaviour.cs +++ b/Runtime/ViewBindingBehaviour.cs @@ -1,8 +1,10 @@ +using TriInspector; using UniMob; using UnityEngine; namespace CodeWriter.ViewBinding { + [HideMonoScript] public abstract class ViewBindingBehaviour : MonoBehaviour { public static void Setup(ViewBindingBehaviour viewBindingBehaviour, Lifetime lifetime) diff --git a/Runtime/ViewContextCollectionAttribute.cs b/Runtime/ViewContextCollectionAttribute.cs new file mode 100644 index 0000000..715c21d --- /dev/null +++ b/Runtime/ViewContextCollectionAttribute.cs @@ -0,0 +1,9 @@ +using System; + +namespace CodeWriter.ViewBinding +{ + [AttributeUsage(AttributeTargets.Field | AttributeTargets.Property)] + public class ViewContextCollectionAttribute : Attribute + { + } +} \ No newline at end of file diff --git a/Runtime/ViewContextCollectionAttribute.cs.meta b/Runtime/ViewContextCollectionAttribute.cs.meta new file mode 100644 index 0000000..2e733db --- /dev/null +++ b/Runtime/ViewContextCollectionAttribute.cs.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: b1fb4cebd6ae4668976d073005746ee9 +timeCreated: 1686923862 \ No newline at end of file diff --git a/Runtime/ViewEntry.cs b/Runtime/ViewEntry.cs index 5b85731..f1dc06f 100644 --- a/Runtime/ViewEntry.cs +++ b/Runtime/ViewEntry.cs @@ -34,12 +34,12 @@ internal virtual string GetErrorMessage() { if (context == null) { - return "Context is null"; + return "Context is missing"; } if (string.IsNullOrWhiteSpace(name)) { - return "Name is none"; + return "Name is required"; } return null; diff --git a/package.json b/package.json index 4356c9b..f1dc470 100644 --- a/package.json +++ b/package.json @@ -8,6 +8,7 @@ "author": "CodeWriter (https://github.com/orgs/codewriter-packages)", "homepage": "https://github.com/codewriter-packages/View-Binding#readme", "dependencies": { - "com.codewriter.unimob": "2.2.0" + "com.codewriter.unimob": "2.2.0", + "com.codewriter.triinspector": "1.12.0" } }