public static bool JumpToSource(string filePath, int lineNumber)
        {
            var validFilePath = UnityDebugViewerEditorUtility.ConvertToSystemFilePath(filePath);

            if (File.Exists(validFilePath))
            {
                if (InternalEditorUtility.OpenFileAtLineExternal(validFilePath, lineNumber))
                {
                    return(true);
                }
            }

            return(false);
        }
Ejemplo n.º 2
0
        public LogStackData(Match match)
        {
            if (match == null)
            {
                SetDefaultValue();
                return;
            }

            this.sourceContent = String.Empty;

            this.className  = match.Result("${className}");
            this.methodName = match.Result("${methodName}");


            this.filePath = UnityDebugViewerEditorUtility.ConvertToSystemFilePath(match.Result("${filePath}"));
            string lineNumberStr = match.Result("${lineNumber}");
            int    lineNumber;

            this.lineNumber = int.TryParse(lineNumberStr, out lineNumber) ? lineNumber : -1;


            if (this.filePath.Equals("${filePath}") || this.lineNumber == -1)
            {
                this.fullStackMessage = string.Format("{0}:{1}", this.className, this.methodName);
            }
            else
            {
                if (this.className.Equals("${className}") || this.methodName.Equals("${methodName}"))
                {
                    if (this.className.Equals("${className}"))
                    {
                        this.className = "UnknowClass";
                    }

                    if (this.methodName.Equals("${methodName}"))
                    {
                        this.methodName = "UnknowMethod()";
                    }
                }

                if (this.methodName.Contains("(") == false)
                {
                    this.methodName += "()";
                }

                this.fullStackMessage = string.Format("{0}:{1} (at {2}:{3})", this.className, this.methodName, this.filePath, this.lineNumber);
            }
        }
        public static string GetAdbPath()
        {
            if (!String.IsNullOrEmpty(adbPath))
            {
                return(adbPath);
            }

#if UNITY_2019_1_OR_NEWER
            ADB adb = ADB.GetInstance();
            if (abd != null)
            {
                adbPath = adb.GetADBPath();
            }
#else
            string androidSdkRoot = EditorPrefs.GetString("AndroidSdkRoot");
            if (!string.IsNullOrEmpty(androidSdkRoot))
            {
                adbPath = Path.Combine(androidSdkRoot, Path.Combine("platform-tools", "adb"));
            }
#endif

            if (string.IsNullOrEmpty(adbPath))
            {
                MonoScript ms       = MonoScript.FromScriptableObject(UnityDebugViewerADBUtility.GetADBInstance());
                string     filePath = AssetDatabase.GetAssetPath(ms);
                filePath = UnityDebugViewerEditorUtility.ConvertToSystemFilePath(filePath);

                string currentScriptDirectory = Path.GetDirectoryName(filePath);
                string parentDirectory        = Directory.GetParent(currentScriptDirectory).FullName;
                parentDirectory = Directory.GetParent(parentDirectory).FullName;

                string defaultAdbPath = UnityDebugViewerEditorUtility.ConvertToSystemFilePath(UnityDebugViewerADBUtility.DEFAULT_ADB_PATH);

                adbPath = Path.Combine(Path.Combine(parentDirectory, defaultAdbPath), "adb");
            }

            return(adbPath);
        }