Library/PackageCache/com.unity.quicksearch@1.6.0-preview.8/Editor/Indexing/ObjectIndexer.cs
/// <summary>
/// Index all the properties of an object.
/// </summary>
/// <param name="id">Object id.</param>
/// <param name="obj">Object to index.</param>
/// <param name="documentIndex">Document where the indexed object was found.</param>
/// <param name="dependencies">Index dependencies.</param>
Index all the properties of an object.
Index all the properties of an object .
protected void IndexObject(string id, Object obj, int documentIndex, bool dependencies = false)
        {
            using (var so = new SerializedObject(obj))
            {
                var p = so.GetIterator();
                var next = p.Next(true);
                while (next)
                {
                    bool saveKeyword = true;
                    var fieldName = p.displayName.Replace("m_", "").Replace(" ", "").ToLowerInvariant();
                    var scc = SearchUtils.SplitCamelCase(fieldName);
                    var fcc = scc.Length > 1 && fieldName.Length > 10 ? scc.Aggregate("", (current, s) => current + s[0]) : fieldName;
                    object fieldValue = GetPropertyValue(p, ref saveKeyword);
                    if (k_FieldNamesNoKeywords.Contains(fieldName))
                        saveKeyword = false;
                    if (fieldValue != null)
                    {
                        var sfv = fieldValue as string;
                        if (sfv != null)
                        {
                            if (sfv != "")
                                IndexProperty(id, fcc, sfv.Replace(" ", "").ToLowerInvariant(), documentIndex, saveKeyword);
                            else
                                IndexWord(id, $"@{fcc}", documentIndex);
                        }
                        else if (fieldValue is double)
                        {
                            var nfv = (double)fieldValue;
                            IndexNumber(id, fcc.ToLowerInvariant(), nfv, documentIndex);
                        }
                        IndexDebugMatch(id, fcc, fieldValue.ToString());
                    }
                    if (dependencies)
                        AddReference(id, p, documentIndex);
                    next = p.Next(p.hasVisibleChildren);
                }
            }
        }
protected void IndexObject ( string id , Object obj , int documentIndex , bool dependencies = false ) { using ( var so = new SerializedObject ( obj ) ) { var p = so . GetIterator ( ) ; var next = p . Next ( true ) ; while ( next ) { bool saveKeyword = true ; var fieldName = p . displayName . Replace ( " " , " " ) . Replace ( " " , " " ) . ToLowerInvariant ( ) ; var scc = SearchUtils . SplitCamelCase ( fieldName ) ; var fcc = scc . Length > 1 && fieldName . Length > 10 ? scc . Aggregate ( " " , ( current , s ) => current + s [ 0 ] ) : fieldName ; object fieldValue = GetPropertyValue ( p , ref saveKeyword ) ; if ( k_FieldNamesNoKeywords . Contains ( fieldName ) ) saveKeyword = false ; if ( fieldValue != null ) { var sfv = fieldValue as string ; if ( sfv != null ) { if ( sfv != " " ) IndexProperty ( id , fcc , sfv . Replace ( " " , " " ) . ToLowerInvariant ( ) , documentIndex , saveKeyword ) ; else IndexWord ( id , $" @ { fcc } " , documentIndex ) ; } else if ( fieldValue is double ) { var nfv = ( double ) fieldValue ; IndexNumber ( id , fcc . ToLowerInvariant ( ) , nfv , documentIndex ) ; } IndexDebugMatch ( id , fcc , fieldValue . ToString ( ) ) ; } if ( dependencies ) AddReference ( id , p , documentIndex ) ; next = p . Next ( p . hasVisibleChildren ) ; } } }
Index all the properties of an object.
Index all the properties of an object .
// Some property names are not worth indexing and take to much spaces.
id
string
None
obj
Object
Object to index.
Object to index .
documentIndex
int
Document where the indexed object was found.
Document where the indexed object was found .
dependencies
bool
None