示例#1
0
        public override void SearchGameObject(SearchJob job, GameObject go)
        {
            job.assetData.searchExecuted = true;
            // Debug.Log("[SearchItemInstances] GO:"+go.name);
            PrefabType goType = PrefabUtility.GetPrefabType(go);

            if (goType == PrefabType.PrefabInstance)
            {
#if UNITY_2018_2 || UNITY_2018_3 || UNITY_2018_4
                UnityEngine.Object goPrefabObj = PrefabUtility.GetCorrespondingObjectFromSource(go);
#else
                UnityEngine.Object goPrefabObj = PrefabUtility.GetPrefabParent(go);
#endif
                GameObject root           = PrefabUtility.FindPrefabRoot(go);
                bool       isRootOfPrefab = root == go;
                if (isRootOfPrefab && goPrefabObj == objID.obj)
                {
                    //Instance found!
                    // Debug.Log("[SearchItemInstances] instance found!"+go.name);
                    SearchResult result = new SearchResult();
                    result.strRep      = "";
                    result.pathInfo    = PathInfo.GetPathInfo(go, job);
                    result.actionTaken = SearchAction.InstanceFound;
                    job.MatchFound(result, this);
                    replaceItem.ReplaceInstance(job, go, result);
                }
            }
        }
示例#2
0
        public override void SearchGameObject(SearchJob job, GameObject go)
        {
            job.assetData.searchExecuted = true;
            PrefabTypes goType = PrefabUtil.GetPrefabType(go);

            if (goType == PrefabTypes.PrefabInstance || goType == PrefabTypes.NestedPrefabInstance || goType == PrefabTypes.PrefabVariantInstance)
            {
                GameObject goPrefabObj = null;
#if UNITY_2018_3_OR_NEWER
                if (goType == PrefabTypes.PrefabInstance || goType == PrefabTypes.NestedPrefabInstance)
                {
                    // nested prefabs or normal instances means we should search for the *original* source.
                    // prefab variant instances will show up here as nestedprefab instances
                    // if the variants are in variants. :P
                    goPrefabObj = PrefabUtility.GetCorrespondingObjectFromOriginalSource(go);
                }
                else
                {
                    // PrefabVariantInstance means we need the corresponding source.
                    goPrefabObj = PrefabUtility.GetCorrespondingObjectFromSource(go);
                }
                GameObject root = go;
#else
                goPrefabObj = (GameObject)PrefabUtility.GetPrefabParent(go);
                GameObject root = PrefabUtility.FindPrefabRoot(go);
#endif
                bool isRootOfPrefab = root == go;
                if (isRootOfPrefab && goPrefabObj == objID.obj)
                {
                    //Instance found!
                    // Debug.Log("[SearchItemInstances] instance found!"+go.name);
                    SearchResult result = new SearchResult();
                    result.strRep      = "";
                    result.pathInfo    = PathInfo.GetPathInfo(go, job.assetData);
                    result.actionTaken = SearchAction.InstanceFound;
                    job.MatchFound(result, this);
                    replaceItem.ReplaceInstance(job, this, go, result);
                }
            }
        }