Skip to content

Commit

Permalink
Right clicking a log will now open it in external script editor (Edit…
Browse files Browse the repository at this point in the history
…or only)
  • Loading branch information
yasirkula committed May 4, 2018
1 parent 6766d19 commit 5e27e14
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 14 deletions.
13 changes: 1 addition & 12 deletions Assets/Plugins/IngameDebugConsole/Prefabs/DebugLogItem.prefab
Original file line number Diff line number Diff line change
Expand Up @@ -229,18 +229,7 @@ MonoBehaviour:
m_TargetGraphic: {fileID: 11459012}
m_OnClick:
m_PersistentCalls:
m_Calls:
- m_Target: {fileID: 11408050}
m_MethodName: Clicked
m_Mode: 1
m_Arguments:
m_ObjectArgument: {fileID: 0}
m_ObjectArgumentAssemblyTypeName: UnityEngine.Object, UnityEngine
m_IntArgument: 0
m_FloatArgument: 0
m_StringArgument:
m_BoolArgument: 0
m_CallState: 2
m_Calls: []
m_TypeName: UnityEngine.UI.Button+ButtonClickedEvent, UnityEngine.UI, Version=1.0.0.0,
Culture=neutral, PublicKeyToken=null
--- !u!114 &11459012
Expand Down
26 changes: 24 additions & 2 deletions Assets/Plugins/IngameDebugConsole/Scripts/DebugLogItem.cs
Original file line number Diff line number Diff line change
@@ -1,10 +1,15 @@
using UnityEngine;
using UnityEngine.UI;
using UnityEngine.EventSystems;
#if UNITY_EDITOR
using UnityEditor;
using System.Text.RegularExpressions;
#endif

// A UI element to show information about a debug entry
namespace IngameDebugConsole
{
public class DebugLogItem : MonoBehaviour
public class DebugLogItem : MonoBehaviour, IPointerClickHandler
{
// Cached components
[SerializeField]
Expand Down Expand Up @@ -76,9 +81,26 @@ public void HideCount()
}

// This log item is clicked, show the debug entry's stack trace
public void Clicked()
public void OnPointerClick( PointerEventData eventData )
{
#if UNITY_EDITOR
if( eventData.button == PointerEventData.InputButton.Right )
{
Match regex = Regex.Match( logEntry.stackTrace, @"\(at .*\.cs:[0-9]+\)$", RegexOptions.Multiline );
if( regex.Success )
{
string line = logEntry.stackTrace.Substring( regex.Index + 4, regex.Length - 5 );
int lineSeparator = line.IndexOf( ':' );
MonoScript script = AssetDatabase.LoadAssetAtPath<MonoScript>( line.Substring( 0, lineSeparator ) );
if( script != null )
AssetDatabase.OpenAsset( script, int.Parse( line.Substring( lineSeparator + 1 ) ) );
}
}
else
manager.OnLogItemClicked( this );
#else
manager.OnLogItemClicked( this );
#endif
}

public float CalculateExpandedHeight( string content )
Expand Down
Binary file modified IngameDebugConsole.unitypackage
Binary file not shown.
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@ Simply import **IngameDebugConsole.unitypackage** to your project and place **In
- **Receive Logcat Logs In Android**: if enabled, on Android platform, logcat entries of the application will also be logged to the console with the prefix "*LOGCAT:*". This may come in handy especially if you want to access the native logs of your Android plugins (like *Admob*)
- **Logcat Arguments**: on Android, if Logcat logs are enabled, native logs will be filtered using these arguments. If left blank, all native logs of the application will be logged to the console. If you want to, for example, see Admob's logs only, you can enter **-s Ads** here

While testing on Unity editor, right clicking a log entry will open the corresponding line in external script editor, similar to double clicking a log in Unity Console.

## COMMAND CONSOLE

### Executing Commands
Expand Down

0 comments on commit 5e27e14

Please sign in to comment.