Пример #1
0
        public void SearchProperty(SearchJob job, SearchItem item, SerializedProperty prop)
        {
            bool onlyVisible               = !AnimationUtil.isAnimationObject(prop.serializedObject.targetObject);
            bool isScene                   = job.assetData.assetScope == AssetScope.Scenes;
            SerializedProperty iterator    = prop.Copy();
            SerializedProperty endProperty = null;

            if (depth == 0)
            {
            }
            else
            {
                endProperty = iterator.GetEndProperty();
            }

            // if(endProperty != null)
            // {
            //   Debug.Log("[SearchItemGlobal] STARTING on "+iterator.propertyPath + " ENDING on "+endProperty.propertyPath);
            // }

            while (Next(iterator, onlyVisible))
            {
                if (ignorePropertyOfType(iterator))
                {
                    continue;
                }
                if (endProperty != null && SerializedProperty.EqualContents(iterator, endProperty))
                {
                    return;
                }


                // Its possible that we may have sub-objects that are serialized
                // scriptable objects within a scene. These aren't scriptable objects
                // on disk, and so we need to create a SerializedObject representation
                // and go a bit deeper.
                if (isScene)
                {
                    if (iterator.propertyType == SerializedPropertyType.ObjectReference && iterator.objectReferenceValue is ScriptableObject)
                    {
                        string path = AssetDatabase.GetAssetPath(iterator.objectReferenceValue.GetInstanceID());
                        if (path == "")
                        {
                            // Debug.Log("[SearchItemGlobal] found scriptable object serialized within a scene."+iterator.propertyPath);
                            SerializedObject so = new SerializedObject(iterator.objectReferenceValue);
                            recursiveDepth++;
                            if (recursiveDepth < 100)
                            {
                                string          internalID         = job.assetData.assetPath + so.targetObject.GetInstanceID();
                                SearchAssetData internalObjectData = null;
                                if (!job.searchAssetsData.TryGetValue(internalID, out internalObjectData))
                                {
                                    // Debug.Log("Searching:"+ iterator.propertyPath + " " +so.targetObject.GetInstanceID());
                                    job.addInternalAsset(job.assetData.assetPath, so.targetObject.GetInstanceID());
                                    SearchProperty(job, item, so.GetIterator());
                                }
                                // else{
                                //   Debug.Log("Already searched this internal object:"+so.targetObject.GetInstanceID());
                                // }
                            }
                            else
                            {
                                // hit recursive depth!
                                Debug.Log("[Search & Replace] Recursive depth hit!");
                            }
                            recursiveDepth--;
                        }
                    }
                }
                searchPropertyInternal(job, item, prop, iterator);
            }

            if (typeHidesName(prop.serializedObject.targetObject))
            {
                SerializedProperty nameProp = prop.serializedObject.FindProperty("m_Name");
                searchPropertyInternal(job, item, prop, nameProp);
            }
        }