Esempio n. 1
0
 protected override void filterAssetPaths(string[] allAssets)
 {
     base.filterAssetPaths(allAssets);
     if (job.scope.projectScope == ProjectScope.CurrentScene)
     {
         // Let's add it!
         // Debug.Log("[SceneSubJob] Adding:"+SceneUtil.GuidPathForActiveScene());
         addItems(new string[] { SceneUtil.GuidPathForActiveScene() });
     }
 }
Esempio n. 2
0
        void parseIfSceneObject()
        {
            if (obj != null)
            {
                // Debug.Log("[ObjectID] guid: " + guid + " for  " + obj);
                if (guid == "")
                {
                    GameObject go = null;
                    if (obj is Component)
                    {
                        Component c = (Component)obj;
                        go = c.gameObject;
                    }
                    else
                    {
                        go = (GameObject)obj;
                    }
                    isSceneObject = go.scene.path.EndsWith(".unity");
                    if (isSceneObject)
                    {
                        guid = go.scene.path;
                    }
                    else
                    {
                        guid = AssetDatabase.AssetPathToGUID(go.scene.path);
#if UNITY_2018_3_OR_NEWER
                        PrefabStage stage = PrefabStageUtility.GetPrefabStage(go);
                        if (stage != null)
                        {
                            isPrefabStageObject = true;
                        }
#endif
                    }
                    localPath = PathData.ToPathData(obj);
                }
                else
                if (guid == SceneUtil.GuidPathForActiveScene())
                {
                    isSceneObject = true;
                    localPath     = PathData.ToPathData(obj);
                }
                else
                {
                    isSceneObject = false;
                    localPath     = null;
                }
            }
            else
            {
                isSceneObject = false;
                localPath     = null;
            }
        }
Esempio n. 3
0
        /*
         * Called upon deserialization to initialize the object.
         */
        void GetObject()
        {
            if (obj == null)
            {
                //At this point we don't know if this is a scene object,
                bool guidIsScene = guid == SceneUtil.GuidPathForActiveScene();
                if (guidIsScene)
                {
                    // Debug.Log("[ObjectID] looking in scene:"+guid);
                    obj = searchForObjectInScene();
                }
                else
                {
                    // Debug.Log("[ObjectID] not a scene object");
                }
                UnityEngine.Object o = null;
                // attempt to retrieve the object.
                assetPath = AssetDatabase.GUIDToAssetPath(guid);
                // Debug.Log("[ObjectID] looking at : "+assetPath);
                if (assetPath == "Resources/unity_builtin_extra")
                {
                    // Debug.Log("[ObjectID] internal resource;"+guid+" : " + localID);
                    o = EditorUtility.InstanceIDToObject((int)localID);
                    // Debug.Log("[ObjectID] we found internally:"+o);
                }
                else
                {
                    o = AssetDatabase.LoadAssetAtPath(assetPath, typeof(UnityEngine.Object));
                }
                //search for local object.
                if (o == null)
                {
                    return; //aka 'null'
                }
                obj = searchForLocalObject(o);
                if (obj == null)
                {
                    // Check our monoscript cache.
                    // Debug.Log("[ObjectID] couldn't find object....checking monoscript cache");
                    obj = MonoScriptCache.getScript(localID);
                }

                // Debug.Log("[ObjectID] obj:"+obj);
                if (obj == null)
                {
                    localID = 0;
                    guid    = "";
                    // wipe it.
                }
                setRequiresImporter();
            }
        }
Esempio n. 4
0
        /**
         * This functions to select active items within the scene and project.
         * It cannot select items when the scene is closed and reopened, since
         * the instanceIDs go away forEVER.
         */
        public void SelectAll()
        {
            HashSet <int> selections        = new HashSet <int>();
            string        openScenePath     = SceneUtil.GuidPathForActiveScene();
            int           unSelectableItems = 0;

            foreach (SearchResultGroup srg in results)
            {
                foreach (SearchResult sr in srg.results)
                {
                    if (sr.pathInfo.objID.isSceneObject)
                    {
                        if (sr.pathInfo.objID.guid == openScenePath)
                        {
                            Debug.Log("[SearchResultSet] searching in scene:" + sr.pathInfo.FullPath());
                            UnityEngine.Object obj = sr.pathInfo.objID.searchForObjectInScene();
                            if (obj != null)
                            {
                                selections.Add(obj.GetInstanceID());
                            }
                        }
                        else
                        {
                            unSelectableItems++;
                        }
                    }
                    else
                    {
                        selections.Add(sr.pathInfo.gameObjectID);
                    }
                }
            }
            if (unSelectableItems > 0)
            {
                Debug.LogWarning("[Search & Replace] " + unSelectableItems + " items were not selected because they are not within the active scene, have been moved, or deleted.");
            }

            int[] selectionsArray = new int[selections.Count];
            selections.CopyTo(selectionsArray);
            Selection.instanceIDs = selectionsArray;
        }
Esempio n. 5
0
 void parseIfSceneObject()
 {
     if (obj != null)
     {
         if (guid == "" || guid == SceneUtil.GuidPathForActiveScene())
         {
             isSceneObject = true;
             guid          = SceneUtil.GuidPathForActiveScene();
             // Debug.Log("[ObjectID] Setting to scene object:"+guid);
             localPath = PathData.ToPathData(obj);
         }
         else
         {
             isSceneObject = false;
             localPath     = null;
         }
     }
     else
     {
         isSceneObject = false;
         localPath     = null;
     }
 }
        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);
        }