コード例 #1
0
ファイル: CSSelectionTools.cs プロジェクト: Pinkpanterus/DPND
        private static bool RevealAndSelectGameObjectInScene(string path, string transformPath, long objectId, long componentId)
        {
            Scene targetScene;

            if (!string.IsNullOrEmpty(path))
            {
                var openResult = OpenSceneForReveal(path);
                if (!openResult.success)
                {
                    return(false);
                }

                targetScene = openResult.scene;
            }
            else
            {
                targetScene = CSSceneTools.GetUntitledScene();
            }

            if (!targetScene.IsValid())
            {
                Debug.LogError(Maintainer.ConstructError("Target scene is not valid or not found! Scene path: " + path + ", looked for ObjectID " + objectId + "!"));
                return(false);
            }

            var target = CSObjectTools.FindGameObjectInScene(targetScene, objectId, transformPath);

            if (target == null)
            {
                Debug.LogError(Maintainer.ConstructError("Couldn't find target Game Object " + transformPath + " at " + path + " with ObjectID " + objectId + "!"));
                return(false);
            }

            // workaround for a bug when Unity doesn't expand hierarchy in scene
            EditorApplication.delayCall += () =>
            {
                EditorGUIUtility.PingObject(target);
            };

            CSObjectTools.SelectGameObject(target, true);

            var enclosingAssetInstanceId = CSAssetTools.GetMainAssetInstanceID(path);

            EditorApplication.delayCall += () =>
            {
                EditorGUIUtility.PingObject(enclosingAssetInstanceId);
            };

            if (componentId != -1)
            {
                return(TryFoldAllComponentsExceptId(componentId));
            }

            return(true);
        }
コード例 #2
0
        public static bool RevealAndSelectFileAsset(string assetPath)
        {
            var instanceId = CSAssetTools.GetMainAssetInstanceID(assetPath);

            if (AssetDatabase.Contains(instanceId))
            {
                Selection.activeInstanceID = instanceId;
                return(true);
            }

            return(false);
        }
コード例 #3
0
        private static bool RevealAndSelectGameObjectInScene(string enclosingAssetPath, string transformPath, long objectId, long componentId)
        {
            var openResult = OpenSceneForReveal(enclosingAssetPath);

            if (!openResult.success)
            {
                return(false);
            }

            var target = CSObjectTools.FindGameObjectInScene(openResult.scene, objectId, transformPath);

            if (target == null)
            {
                Debug.LogError(Maintainer.ConstructError("Couldn't find target Game Object " + transformPath + " at " + enclosingAssetPath + " with ObjectID " + objectId + "!"));
                return(false);
            }

            // workaround for a bug when Unity doesn't expand hierarchy in scene
            EditorApplication.delayCall += () =>
            {
                EditorGUIUtility.PingObject(target);
            };

            CSObjectTools.SelectGameObject(target, true);

            var enclosingAssetInstanceId = CSAssetTools.GetMainAssetInstanceID(enclosingAssetPath);

            EditorApplication.delayCall += () =>
            {
                EditorGUIUtility.PingObject(enclosingAssetInstanceId);
            };

            if (componentId != -1)
            {
                return(TryFoldAllComponentsExceptId(componentId));
            }

            return(true);
        }