You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
41 lines
1012 B
41 lines
1012 B
using UnityEngine; |
|
using UnityEngine.UI; |
|
|
|
namespace FFmpeg.Demo |
|
{ |
|
/// <summary> |
|
/// This class role is to avoid overcome of vertex limit |
|
/// on Output Text component if text is too big. |
|
/// </summary> |
|
public class Console : MonoBehaviour |
|
{ |
|
static Console self; |
|
public Text output; |
|
public Scrollbar vertical; |
|
const int UNITY_VERTS_LIMIT = 65000; |
|
const int CHAR_MIN = 2048, CHAR_MAX = UNITY_VERTS_LIMIT / 4 - 1; |
|
[Range(CHAR_MIN, CHAR_MAX)] |
|
public int outputCharLimit = |
|
|
|
#if UNITY_ANDROID && !UNITY_EDITOR |
|
CHAR_MAX / 5; |
|
#else |
|
CHAR_MAX; |
|
#endif |
|
|
|
void Awake() |
|
{ |
|
self = this; |
|
} |
|
|
|
public static void Print(string msg) |
|
{ |
|
if(msg.Length > self.outputCharLimit) |
|
{ |
|
msg = msg.Remove(0, msg.Length - self.outputCharLimit); |
|
} |
|
self.output.text = msg; |
|
self.vertical.value = 0; |
|
} |
|
} |
|
} |