public static ShaderError[] GetShaderErrors(Shader s) { Type shaderErrorType = Type.GetType("UnityEditor.ShaderError, UnityEditor"); var errorList = (System.Collections.IList)Type.InvokeMember("GetShaderErrors", BindingFlags.Static | BindingFlags.NonPublic | BindingFlags.InvokeMethod, null, null, new object[] { s }); FieldInfo messageField = shaderErrorType.GetField("message", BindingFlags.Public | BindingFlags.Instance); FieldInfo messageDetailsField = shaderErrorType.GetField("messageDetails", BindingFlags.Public | BindingFlags.Instance); FieldInfo platformField = shaderErrorType.GetField("platform", BindingFlags.Public | BindingFlags.Instance); FieldInfo fileField = shaderErrorType.GetField("file", BindingFlags.Public | BindingFlags.Instance); FieldInfo lineField = shaderErrorType.GetField("line", BindingFlags.Public | BindingFlags.Instance); FieldInfo warningField = shaderErrorType.GetField("warning", BindingFlags.Public | BindingFlags.Instance); ShaderError[] errors = new ShaderError[errorList.Count]; for (int i = 0; i < errorList.Count; i++) { errors[i].message = ( string )messageField.GetValue(errorList[i]); errors[i].messageDetails = ( string )messageDetailsField.GetValue(errorList[i]); errors[i].platform = ( string )platformField.GetValue(errorList[i]); errors[i].file = ( string )fileField.GetValue(errorList[i]); errors[i].line = ( int )lineField.GetValue(errorList[i]); errors[i].warning = ( int )warningField.GetValue(errorList[i]); } return(errors); }
internal static void ShaderErrorListUI(UnityEngine.Object shader, ShaderError[] errors, ref Vector2 scrollPosition) { // ISSUE: object of a compiler-generated type is created // ISSUE: variable of a compiler-generated type ShaderInspector.\u003CShaderErrorListUI\u003Ec__AnonStorey9A listUiCAnonStorey9A = new ShaderInspector.\u003CShaderErrorListUI\u003Ec__AnonStorey9A(); // ISSUE: reference to a compiler-generated field listUiCAnonStorey9A.errors = errors; // ISSUE: reference to a compiler-generated field int length = listUiCAnonStorey9A.errors.Length; GUILayout.Space(5f); GUILayout.Label(string.Format("Errors ({0}):", (object) length), EditorStyles.boldLabel, new GUILayoutOption[0]); int controlId = GUIUtility.GetControlID(ShaderInspector.kErrorViewHash, FocusType.Native); float minHeight = Mathf.Min((float) ((double) length * 20.0 + 40.0), 150f); scrollPosition = GUILayout.BeginScrollView(scrollPosition, GUISkin.current.box, GUILayout.MinHeight(minHeight)); EditorGUIUtility.SetIconSize(new Vector2(16f, 16f)); float height = ShaderInspector.Styles.messageStyle.CalcHeight(EditorGUIUtility.TempContent((Texture) ShaderInspector.Styles.errorIcon), 100f); Event current = Event.current; for (int index = 0; index < length; ++index) { Rect controlRect = EditorGUILayout.GetControlRect(false, height, new GUILayoutOption[0]); // ISSUE: reference to a compiler-generated field string message = listUiCAnonStorey9A.errors[index].message; // ISSUE: reference to a compiler-generated field string platform = listUiCAnonStorey9A.errors[index].platform; // ISSUE: reference to a compiler-generated field bool flag = listUiCAnonStorey9A.errors[index].warning != 0; // ISSUE: reference to a compiler-generated field string pathNameComponent = FileUtil.GetLastPathNameComponent(listUiCAnonStorey9A.errors[index].file); // ISSUE: reference to a compiler-generated field int line = listUiCAnonStorey9A.errors[index].line; if (current.type == EventType.MouseDown && current.button == 0 && controlRect.Contains(current.mousePosition)) { GUIUtility.keyboardControl = controlId; if (current.clickCount == 2) { // ISSUE: reference to a compiler-generated field string file = listUiCAnonStorey9A.errors[index].file; UnityEngine.Object target = !string.IsNullOrEmpty(file) ? AssetDatabase.LoadMainAssetAtPath(file) : (UnityEngine.Object) null; if ((object) target == null) target = shader; int lineNumber = line; AssetDatabase.OpenAsset(target, lineNumber); GUIUtility.ExitGUI(); } current.Use(); } if (current.type == EventType.ContextClick && controlRect.Contains(current.mousePosition)) { // ISSUE: object of a compiler-generated type is created // ISSUE: variable of a compiler-generated type ShaderInspector.\u003CShaderErrorListUI\u003Ec__AnonStorey9B listUiCAnonStorey9B = new ShaderInspector.\u003CShaderErrorListUI\u003Ec__AnonStorey9B(); // ISSUE: reference to a compiler-generated field listUiCAnonStorey9B.\u003C\u003Ef__ref\u0024154 = listUiCAnonStorey9A; current.Use(); GenericMenu genericMenu = new GenericMenu(); // ISSUE: reference to a compiler-generated field listUiCAnonStorey9B.errorIndex = index; // ISSUE: reference to a compiler-generated method genericMenu.AddItem(new GUIContent("Copy error text"), false, new GenericMenu.MenuFunction(listUiCAnonStorey9B.\u003C\u003Em__1B2)); genericMenu.ShowAsContext(); } if (current.type == EventType.Repaint && (index & 1) == 0) ShaderInspector.Styles.evenBackground.Draw(controlRect, false, false, false, false); Rect position1 = controlRect; position1.xMin = position1.xMax; if (line > 0) { GUIContent content = !string.IsNullOrEmpty(pathNameComponent) ? EditorGUIUtility.TempContent(pathNameComponent + ":" + line.ToString((IFormatProvider) CultureInfo.InvariantCulture)) : EditorGUIUtility.TempContent(line.ToString((IFormatProvider) CultureInfo.InvariantCulture)); Vector2 vector2 = EditorStyles.miniLabel.CalcSize(content); position1.xMin -= vector2.x; GUI.Label(position1, content, EditorStyles.miniLabel); position1.xMin -= 2f; if ((double) position1.width < 30.0) position1.xMin = position1.xMax - 30f; } Rect position2 = position1; position2.width = 0.0f; if (platform.Length > 0) { GUIContent content = EditorGUIUtility.TempContent(platform); Vector2 vector2 = EditorStyles.miniLabel.CalcSize(content); position2.xMin -= vector2.x; Color contentColor = GUI.contentColor; GUI.contentColor = new Color(1f, 1f, 1f, 0.5f); GUI.Label(position2, content, EditorStyles.miniLabel); GUI.contentColor = contentColor; position2.xMin -= 2f; } Rect position3 = controlRect; position3.xMax = position2.xMin; GUI.Label(position3, EditorGUIUtility.TempContent(message, !flag ? (Texture) ShaderInspector.Styles.errorIcon : (Texture) ShaderInspector.Styles.warningIcon), ShaderInspector.Styles.messageStyle); } EditorGUIUtility.SetIconSize(Vector2.zero); GUILayout.EndScrollView(); }