First commit for private source control. Older commits available on Github.
This commit is contained in:
@@ -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
|
||||
Reference in New Issue
Block a user