First commit for private source control. Older commits available on Github.
This commit is contained in:
@@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 77b8ccff4f0c60943b9a54ce8d698d7f
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,21 @@
|
||||
using System;
|
||||
using UnityEditor;
|
||||
|
||||
namespace AYellowpaper.SerializedCollections.Editor.Search
|
||||
{
|
||||
public class EnumMatcher : Matcher
|
||||
{
|
||||
public override bool IsMatch(SerializedProperty property)
|
||||
{
|
||||
if (property.propertyType == SerializedPropertyType.Enum && SCEditorUtility.TryGetTypeFromProperty(property, out var type))
|
||||
{
|
||||
foreach (var text in SCEnumUtility.GetEnumCache(type).GetNamesForValue(property.enumValueFlag))
|
||||
{
|
||||
if (text.Contains(SearchString, StringComparison.OrdinalIgnoreCase))
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
fileFormatVersion: 2
|
||||
guid: f2cf86e71fb0ff04f96ac71dd9961962
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
AssetOrigin:
|
||||
serializedVersion: 1
|
||||
productId: 243052
|
||||
packageName: Serialized Dictionary
|
||||
packageVersion: 1.0.13
|
||||
assetPath: Assets/Plugins/SerializedCollections/Editor/Scripts/Search/Matchers/EnumMatcher.cs
|
||||
uploadId: 632226
|
||||
@@ -0,0 +1,20 @@
|
||||
using UnityEditor;
|
||||
|
||||
namespace AYellowpaper.SerializedCollections.Editor.Search
|
||||
{
|
||||
public abstract class Matcher
|
||||
{
|
||||
public string SearchString { get; private set; }
|
||||
|
||||
public void Prepare(string searchString)
|
||||
{
|
||||
SearchString = ProcessSearchString(searchString);
|
||||
}
|
||||
|
||||
public virtual string ProcessSearchString(string searchString)
|
||||
{
|
||||
return searchString;
|
||||
}
|
||||
public abstract bool IsMatch(SerializedProperty property);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 218ea85e2d8480a498e8647aad524c8d
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
AssetOrigin:
|
||||
serializedVersion: 1
|
||||
productId: 243052
|
||||
packageName: Serialized Dictionary
|
||||
packageVersion: 1.0.13
|
||||
assetPath: Assets/Plugins/SerializedCollections/Editor/Scripts/Search/Matchers/Matcher.cs
|
||||
uploadId: 632226
|
||||
@@ -0,0 +1,30 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
namespace AYellowpaper.SerializedCollections.Editor.Search
|
||||
{
|
||||
public static class Matchers
|
||||
{
|
||||
public static IEnumerable<Matcher> RegisteredMatchers => _registeredMatchers;
|
||||
|
||||
private static List<Matcher> _registeredMatchers = new List<Matcher>();
|
||||
|
||||
static Matchers()
|
||||
{
|
||||
_registeredMatchers.Add(new NumericMatcher());
|
||||
_registeredMatchers.Add(new StringMatcher());
|
||||
_registeredMatchers.Add(new EnumMatcher());
|
||||
}
|
||||
|
||||
public static void AddMatcher(Matcher matcher)
|
||||
{
|
||||
_registeredMatchers.Add(matcher);
|
||||
}
|
||||
|
||||
public static bool RemoveMatcher(Matcher matcher)
|
||||
{
|
||||
return _registeredMatchers.Remove(matcher);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 94535827bd107e549baa23442df58bef
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
AssetOrigin:
|
||||
serializedVersion: 1
|
||||
productId: 243052
|
||||
packageName: Serialized Dictionary
|
||||
packageVersion: 1.0.13
|
||||
assetPath: Assets/Plugins/SerializedCollections/Editor/Scripts/Search/Matchers/Matchers.cs
|
||||
uploadId: 632226
|
||||
@@ -0,0 +1,109 @@
|
||||
using System.Globalization;
|
||||
using UnityEditor;
|
||||
using UnityEngine;
|
||||
|
||||
namespace AYellowpaper.SerializedCollections.Editor.Search
|
||||
{
|
||||
public class NumericMatcher : Matcher
|
||||
{
|
||||
public override string ProcessSearchString(string searchString)
|
||||
{
|
||||
return searchString.Replace(',', '.');
|
||||
}
|
||||
|
||||
public override bool IsMatch(SerializedProperty property)
|
||||
{
|
||||
if (property.propertyType == SerializedPropertyType.Float)
|
||||
{
|
||||
return IsFloatMatch(property.floatValue);
|
||||
}
|
||||
else if (property.propertyType == SerializedPropertyType.Integer)
|
||||
{
|
||||
return IsIntMatch(property.intValue);
|
||||
}
|
||||
else if (property.propertyType == SerializedPropertyType.Quaternion)
|
||||
{
|
||||
var quat = property.quaternionValue;
|
||||
return IsFloatMatch(quat.x) || IsFloatMatch(quat.y) || IsFloatMatch(quat.z) || IsFloatMatch(quat.w);
|
||||
}
|
||||
else if (property.propertyType == SerializedPropertyType.Bounds)
|
||||
{
|
||||
var bounds = property.boundsValue;
|
||||
return IsVector3Match(bounds.center) || IsVector3Match(bounds.size);
|
||||
}
|
||||
else if (property.propertyType == SerializedPropertyType.BoundsInt)
|
||||
{
|
||||
var bounds = property.boundsIntValue;
|
||||
return IsVector3Match(bounds.center) || IsVector3IntMatch(bounds.size);
|
||||
}
|
||||
else if (property.propertyType == SerializedPropertyType.Rect)
|
||||
{
|
||||
var rect = property.rectValue;
|
||||
return IsVector2Match(rect.size) || IsVector2Match(rect.position);
|
||||
}
|
||||
else if (property.propertyType == SerializedPropertyType.RectInt)
|
||||
{
|
||||
var rect = property.rectIntValue;
|
||||
return IsVector2IntMatch(rect.size) || IsVector2IntMatch(rect.position);
|
||||
}
|
||||
else if (property.propertyType == SerializedPropertyType.Vector2)
|
||||
{
|
||||
return IsVector2Match(property.vector2Value);
|
||||
}
|
||||
else if (property.propertyType == SerializedPropertyType.Vector2Int)
|
||||
{
|
||||
return IsVector2IntMatch(property.vector2IntValue);
|
||||
}
|
||||
else if (property.propertyType == SerializedPropertyType.Vector3)
|
||||
{
|
||||
return IsVector3Match(property.vector3Value);
|
||||
}
|
||||
else if (property.propertyType == SerializedPropertyType.Vector3Int)
|
||||
{
|
||||
return IsVector3IntMatch(property.vector3IntValue);
|
||||
}
|
||||
else if (property.propertyType == SerializedPropertyType.Vector4)
|
||||
{
|
||||
return IsVector4Match(property.vector4Value);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
private bool IsFloatMatch(float val)
|
||||
{
|
||||
var str = val.ToString(CultureInfo.InvariantCulture);
|
||||
return str.Contains(SearchString, System.StringComparison.OrdinalIgnoreCase);
|
||||
}
|
||||
|
||||
private bool IsIntMatch(int val)
|
||||
{
|
||||
var str = val.ToString(CultureInfo.InvariantCulture);
|
||||
return str.Contains(SearchString, System.StringComparison.OrdinalIgnoreCase);
|
||||
}
|
||||
|
||||
private bool IsVector2Match(Vector2 vector)
|
||||
{
|
||||
return IsFloatMatch(vector.x) || IsFloatMatch(vector.y);
|
||||
}
|
||||
|
||||
private bool IsVector2IntMatch(Vector2Int vector)
|
||||
{
|
||||
return IsIntMatch(vector.x) || IsIntMatch(vector.y);
|
||||
}
|
||||
|
||||
private bool IsVector3Match(Vector3 vector)
|
||||
{
|
||||
return IsFloatMatch(vector.x) || IsFloatMatch(vector.y) || IsFloatMatch(vector.z);
|
||||
}
|
||||
|
||||
private bool IsVector3IntMatch(Vector3Int vector)
|
||||
{
|
||||
return IsIntMatch(vector.x) || IsIntMatch(vector.y) || IsIntMatch(vector.z);
|
||||
}
|
||||
|
||||
private bool IsVector4Match(Vector4 vector)
|
||||
{
|
||||
return IsFloatMatch(vector.x) || IsFloatMatch(vector.y) || IsFloatMatch(vector.z) || IsFloatMatch(vector.w);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
fileFormatVersion: 2
|
||||
guid: cc3ee6ec420212140bd3a86688d548de
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
AssetOrigin:
|
||||
serializedVersion: 1
|
||||
productId: 243052
|
||||
packageName: Serialized Dictionary
|
||||
packageVersion: 1.0.13
|
||||
assetPath: Assets/Plugins/SerializedCollections/Editor/Scripts/Search/Matchers/NumericMatcher.cs
|
||||
uploadId: 632226
|
||||
@@ -0,0 +1,15 @@
|
||||
using System.Globalization;
|
||||
using UnityEditor;
|
||||
|
||||
namespace AYellowpaper.SerializedCollections.Editor.Search
|
||||
{
|
||||
public class StringMatcher : Matcher
|
||||
{
|
||||
public override bool IsMatch(SerializedProperty property)
|
||||
{
|
||||
if ((property.propertyType is SerializedPropertyType.String or SerializedPropertyType.Character) && property.stringValue.Contains(SearchString, System.StringComparison.OrdinalIgnoreCase))
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
fileFormatVersion: 2
|
||||
guid: be8bbc3471f8ad04b8da6366285443c6
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
AssetOrigin:
|
||||
serializedVersion: 1
|
||||
productId: 243052
|
||||
packageName: Serialized Dictionary
|
||||
packageVersion: 1.0.13
|
||||
assetPath: Assets/Plugins/SerializedCollections/Editor/Scripts/Search/Matchers/StringMatcher.cs
|
||||
uploadId: 632226
|
||||
@@ -0,0 +1,22 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEditor;
|
||||
using UnityEngine;
|
||||
|
||||
namespace AYellowpaper.SerializedCollections.Editor.Search
|
||||
{
|
||||
public class PropertySearchResult
|
||||
{
|
||||
public SerializedProperty Property;
|
||||
|
||||
public PropertySearchResult(SerializedProperty property)
|
||||
{
|
||||
Property = property;
|
||||
}
|
||||
|
||||
public override string ToString()
|
||||
{
|
||||
return $"Found match in in {Property.propertyPath}";
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 33b4e4c67054c4d488fa66ff14bd3120
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
AssetOrigin:
|
||||
serializedVersion: 1
|
||||
productId: 243052
|
||||
packageName: Serialized Dictionary
|
||||
packageVersion: 1.0.13
|
||||
assetPath: Assets/Plugins/SerializedCollections/Editor/Scripts/Search/PropertySearchResult.cs
|
||||
uploadId: 632226
|
||||
@@ -0,0 +1,66 @@
|
||||
using System.Collections.Generic;
|
||||
using UnityEditor;
|
||||
|
||||
namespace AYellowpaper.SerializedCollections.Editor.Search
|
||||
{
|
||||
public class SearchQuery
|
||||
{
|
||||
public string SearchString
|
||||
{
|
||||
get => _text;
|
||||
set
|
||||
{
|
||||
if (_text == value)
|
||||
return;
|
||||
|
||||
_text = value;
|
||||
foreach (var matcher in _matchers)
|
||||
matcher.Prepare(_text);
|
||||
}
|
||||
}
|
||||
|
||||
private IEnumerable<Matcher> _matchers;
|
||||
private string _text;
|
||||
|
||||
public SearchQuery(IEnumerable<Matcher> matchers)
|
||||
{
|
||||
_matchers = matchers;
|
||||
}
|
||||
|
||||
public List<PropertySearchResult> ApplyToProperty(SerializedProperty property)
|
||||
{
|
||||
TryGetMatchingProperties(property.Copy(), out var properties);
|
||||
return properties;
|
||||
}
|
||||
|
||||
public IEnumerable<SearchResultEntry> ApplyToArrayProperty(SerializedProperty property)
|
||||
{
|
||||
int arrayCount = property.arraySize;
|
||||
for (int i = 0; i < arrayCount; i++)
|
||||
{
|
||||
var prop = property.GetArrayElementAtIndex(i);
|
||||
if (TryGetMatchingProperties(prop.Copy(), out var properties))
|
||||
yield return new SearchResultEntry(i, prop, properties);
|
||||
}
|
||||
}
|
||||
|
||||
private bool TryGetMatchingProperties(SerializedProperty property, out List<PropertySearchResult> matchingProperties)
|
||||
{
|
||||
matchingProperties = null;
|
||||
foreach (var child in SCEditorUtility.GetChildren(property, true))
|
||||
{
|
||||
foreach (var matcher in _matchers)
|
||||
{
|
||||
if (matcher.IsMatch(child))
|
||||
{
|
||||
if (matchingProperties == null)
|
||||
matchingProperties = new();
|
||||
matchingProperties.Add(new PropertySearchResult(child.Copy()));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return matchingProperties != null;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
fileFormatVersion: 2
|
||||
guid: c87dd0caf3c44ed4e82896aa40bf1b96
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
AssetOrigin:
|
||||
serializedVersion: 1
|
||||
productId: 243052
|
||||
packageName: Serialized Dictionary
|
||||
packageVersion: 1.0.13
|
||||
assetPath: Assets/Plugins/SerializedCollections/Editor/Scripts/Search/SearchQuery.cs
|
||||
uploadId: 632226
|
||||
@@ -0,0 +1,31 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
using UnityEditor;
|
||||
using UnityEngine;
|
||||
|
||||
namespace AYellowpaper.SerializedCollections.Editor.Search
|
||||
{
|
||||
public class SearchResultEntry
|
||||
{
|
||||
public readonly int Index;
|
||||
public readonly SerializedProperty Property;
|
||||
public readonly IEnumerable<PropertySearchResult> MatchingResults;
|
||||
|
||||
public SearchResultEntry(int index, SerializedProperty property, IEnumerable<PropertySearchResult> matchingResults)
|
||||
{
|
||||
Index = index;
|
||||
Property = property;
|
||||
MatchingResults = matchingResults;
|
||||
}
|
||||
|
||||
public override string ToString()
|
||||
{
|
||||
StringBuilder sb = new StringBuilder();
|
||||
sb.AppendLine($"{Index}: {Property.propertyPath}");
|
||||
foreach (var matchingResult in MatchingResults)
|
||||
sb.AppendLine(matchingResult.ToString());
|
||||
return sb.ToString();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
fileFormatVersion: 2
|
||||
guid: d8455216ad2701d49b6dfec7f98ca88b
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
AssetOrigin:
|
||||
serializedVersion: 1
|
||||
productId: 243052
|
||||
packageName: Serialized Dictionary
|
||||
packageVersion: 1.0.13
|
||||
assetPath: Assets/Plugins/SerializedCollections/Editor/Scripts/Search/SearchResultEntry.cs
|
||||
uploadId: 632226
|
||||
Reference in New Issue
Block a user