mirror of
https://github.com/GTA-ASM/SanAndreasUnity
synced 2024-11-22 12:03:04 +00:00
console subscribes to log event before any other script executes
This commit is contained in:
parent
04153d6cc0
commit
2c4521200d
4 changed files with 58 additions and 6 deletions
|
@ -518,6 +518,7 @@ GameObject:
|
|||
- component: {fileID: 114473132252556806}
|
||||
- component: {fileID: 821925318372548346}
|
||||
- component: {fileID: 5292052593724244546}
|
||||
- component: {fileID: 4052078131376788595}
|
||||
m_Layer: 0
|
||||
m_Name: UI
|
||||
m_TagString: UI
|
||||
|
@ -591,6 +592,18 @@ MonoBehaviour:
|
|||
m_changeFontSizeInEditor: 0
|
||||
m_scrollbarSizeMultiplierOnMobile: 2
|
||||
m_changeScrollbarSizeInEditor: 0
|
||||
--- !u!114 &4052078131376788595
|
||||
MonoBehaviour:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 1611271869868126}
|
||||
m_Enabled: 1
|
||||
m_EditorHideFlags: 0
|
||||
m_Script: {fileID: 11500000, guid: d95990750fbd4b9478e6b04bb976af8b, type: 3}
|
||||
m_Name:
|
||||
m_EditorClassIdentifier:
|
||||
--- !u!1 &1627404700688260
|
||||
GameObject:
|
||||
m_ObjectHideFlags: 0
|
||||
|
|
|
@ -69,6 +69,24 @@ namespace SanAndreasUnity.UI
|
|||
this.useScrollView = false;
|
||||
}
|
||||
|
||||
internal static void OnEventSubscriberAwake()
|
||||
{
|
||||
var console = FindObjectOfType<Console>();
|
||||
|
||||
if (null == console)
|
||||
{
|
||||
Debug.LogError("Failed to find console object");
|
||||
return;
|
||||
}
|
||||
|
||||
console.OnEventSubscriberAwakeNonStatic();
|
||||
}
|
||||
|
||||
void OnEventSubscriberAwakeNonStatic()
|
||||
{
|
||||
Application.logMessageReceivedThreaded += HandleLogThreaded;
|
||||
}
|
||||
|
||||
|
||||
#region MonoBehaviour Messages
|
||||
|
||||
|
@ -78,12 +96,6 @@ namespace SanAndreasUnity.UI
|
|||
base.OnDisable();
|
||||
}
|
||||
|
||||
protected override void OnEnable()
|
||||
{
|
||||
base.OnEnable();
|
||||
Application.logMessageReceivedThreaded += HandleLogThreaded;
|
||||
}
|
||||
|
||||
void Start ()
|
||||
{
|
||||
|
||||
|
|
16
Assets/Scripts/UI/ConsoleLogEventSubscriber.cs
Normal file
16
Assets/Scripts/UI/ConsoleLogEventSubscriber.cs
Normal file
|
@ -0,0 +1,16 @@
|
|||
using UnityEngine;
|
||||
|
||||
namespace SanAndreasUnity.UI
|
||||
{
|
||||
/// <summary>
|
||||
/// This script should have lowest possible script execution order so that the <see cref="Console"/> is subscribed to
|
||||
/// log events before any other script executes.
|
||||
/// </summary>
|
||||
public class ConsoleLogEventSubscriber : MonoBehaviour
|
||||
{
|
||||
void Awake()
|
||||
{
|
||||
Console.OnEventSubscriberAwake();
|
||||
}
|
||||
}
|
||||
}
|
11
Assets/Scripts/UI/ConsoleLogEventSubscriber.cs.meta
Normal file
11
Assets/Scripts/UI/ConsoleLogEventSubscriber.cs.meta
Normal file
|
@ -0,0 +1,11 @@
|
|||
fileFormatVersion: 2
|
||||
guid: d95990750fbd4b9478e6b04bb976af8b
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: -32000
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
Loading…
Reference in a new issue