示例#1
0
        public override SearchAssetData Clone()
        {
            SceneViewSearchAssetData assetData = new SceneViewSearchAssetData(assetPath);

            return(assetData);
        }
        public static List <SearchAssetData> GetAssets(SearchScopeData scope)
        {
            List <SearchAssetData> retVal = new List <SearchAssetData>();

            if (scope.projectScope == ProjectScope.EntireProject)
            {
                //If the asset scope is set and has this value OR the scope is not set at all (everything)
                HashSet <string>     suffixes      = scope.GetSuffixesForScope();
                string[]             allAssets     = AssetDatabase.GetAllAssetPaths();
                IEnumerable <string> filteredPaths = allAssets.Where(asset => asset.StartsWith("Assets/")).Where(asset => suffixes.Contains(Path.GetExtension(asset).ToLowerInvariant()));

                foreach (string asset in filteredPaths)
                {
                    AddAsset(asset, retVal);
                }
            }
            else if (scope.projectScope == ProjectScope.SceneView)
            {
                SceneViewSearchAssetData sceneView = new SceneViewSearchAssetData(SceneUtil.GuidPathForActiveScene());
                retVal.Add(sceneView);
            }
            else if (scope.projectScope == ProjectScope.SpecificLocation)
            {
                string[]         allAssets = null;
                HashSet <string> suffixes  = scope.GetSuffixesForScope();
                addObjectsInLocation(scope.scopeObj, ref allAssets, suffixes, retVal);
            }
            else if (scope.projectScope == ProjectScope.CurrentSelection)
            {
                string[] allAssets = null;
                SceneObjectSearchAssetData sceneObject = null;
                foreach (UnityEngine.Object obj in Selection.objects)
                {
                    HashSet <string> suffixes = scope.GetSuffixesForScope(SearchScope.allAssets);
                    ObjectID         objID    = new ObjectID(obj);
                    objID.Clear();
                    if (objID.isSceneObject)
                    {
                        GameObject go = (GameObject)obj;
                        if (sceneObject == null)
                        {
                            sceneObject = new SceneObjectSearchAssetData(go.scene.path);
                            retVal.Add(sceneObject);
                        }
                        sceneObject.AddObject(go);
                    }
                    else if (objID.isPrefabStageObject)
                    {
                        if (sceneObject == null)
                        {
                            sceneObject = new SceneObjectSearchAssetData(SceneUtil.GuidPathForActiveScene());
                            retVal.Add(sceneObject);
                        }
                        sceneObject.AddObject((GameObject)obj);
                    }
                    else
                    {
                        //Ignore asset scope for current selection.
                        addObjectsInLocation(objID, ref allAssets, suffixes, retVal);
                    }
                }
            }
            return(retVal);
        }