Authored Unity primitive/object-model shim, VFX layer (control-flow-preserving, InstantVfx never invokes its action -- headless suppression), god-object stubs (GameMgr/EffectMgr/UIManager with faithfully-extracted nested enums), View/UI/Touch tree, LitJson+BetterList+Tuple copied, third-party stubs. Discovered Roslyn header-error masking: fixing class-header type errors unmasks body references, so the true copy closure is ~2570 files (was 782 under masking). Errors: masked-25720 -> 268; our shim files compile clean. Remaining: ~50 residual shim/external types, 24 NGUI UI-base overrides, static-type fixes, plus likely 1-2 more unmask waves.
147 lines
3.3 KiB
C#
147 lines
3.3 KiB
C#
using System.Collections.Generic;
|
|
using UnityEngine;
|
|
|
|
[AddComponentMenu("NGUI/Internal/Debug")]
|
|
public class NGUIDebug : MonoBehaviour
|
|
{
|
|
private static bool mRayDebug = false;
|
|
|
|
private static List<string> mLines = new List<string>();
|
|
|
|
private static NGUIDebug mInstance = null;
|
|
|
|
public static bool debugRaycast
|
|
{
|
|
get
|
|
{
|
|
return mRayDebug;
|
|
}
|
|
set
|
|
{
|
|
mRayDebug = value;
|
|
if (value && Application.isPlaying)
|
|
{
|
|
CreateInstance();
|
|
}
|
|
}
|
|
}
|
|
|
|
public static void CreateInstance()
|
|
{
|
|
if (mInstance == null)
|
|
{
|
|
GameObject obj = new GameObject("_NGUI Debug");
|
|
mInstance = obj.AddComponent<NGUIDebug>();
|
|
Object.DontDestroyOnLoad(obj);
|
|
}
|
|
}
|
|
|
|
private static void LogString(string text)
|
|
{
|
|
if (Application.isPlaying)
|
|
{
|
|
if (mLines.Count > 20)
|
|
{
|
|
mLines.RemoveAt(0);
|
|
}
|
|
mLines.Add(text);
|
|
CreateInstance();
|
|
}
|
|
}
|
|
|
|
public static void Log(params object[] objs)
|
|
{
|
|
string text = "";
|
|
for (int i = 0; i < objs.Length; i++)
|
|
{
|
|
text = ((i != 0) ? (text + ", " + objs[i].ToString()) : (text + objs[i].ToString()));
|
|
}
|
|
LogString(text);
|
|
}
|
|
|
|
public static void Clear()
|
|
{
|
|
mLines.Clear();
|
|
}
|
|
|
|
public static void DrawBounds(Bounds b)
|
|
{
|
|
_ = b.center;
|
|
_ = b.center - b.extents;
|
|
_ = b.center + b.extents;
|
|
}
|
|
|
|
private void OnGUI()
|
|
{
|
|
Rect position = new Rect(5f, 5f, 1000f, 22f);
|
|
if (mRayDebug)
|
|
{
|
|
string text = "Scheme: " + UICamera.currentScheme;
|
|
GUI.color = Color.black;
|
|
GUI.Label(position, text);
|
|
position.y -= 1f;
|
|
position.x -= 1f;
|
|
GUI.color = Color.white;
|
|
GUI.Label(position, text);
|
|
position.y += 18f;
|
|
position.x += 1f;
|
|
text = "Hover: " + NGUITools.GetHierarchy(UICamera.hoveredObject).Replace("\"", "");
|
|
GUI.color = Color.black;
|
|
GUI.Label(position, text);
|
|
position.y -= 1f;
|
|
position.x -= 1f;
|
|
GUI.color = Color.white;
|
|
GUI.Label(position, text);
|
|
position.y += 18f;
|
|
position.x += 1f;
|
|
text = "Selection: " + NGUITools.GetHierarchy(UICamera.selectedObject).Replace("\"", "");
|
|
GUI.color = Color.black;
|
|
GUI.Label(position, text);
|
|
position.y -= 1f;
|
|
position.x -= 1f;
|
|
GUI.color = Color.white;
|
|
GUI.Label(position, text);
|
|
position.y += 18f;
|
|
position.x += 1f;
|
|
text = "Controller: " + NGUITools.GetHierarchy(UICamera.controllerNavigationObject).Replace("\"", "");
|
|
GUI.color = Color.black;
|
|
GUI.Label(position, text);
|
|
position.y -= 1f;
|
|
position.x -= 1f;
|
|
GUI.color = Color.white;
|
|
GUI.Label(position, text);
|
|
position.y += 18f;
|
|
position.x += 1f;
|
|
text = "Active events: " + UICamera.CountInputSources();
|
|
if (UICamera.disableController)
|
|
{
|
|
text += ", disabled controller";
|
|
}
|
|
if (UICamera.inputHasFocus)
|
|
{
|
|
text += ", input focus";
|
|
}
|
|
GUI.color = Color.black;
|
|
GUI.Label(position, text);
|
|
position.y -= 1f;
|
|
position.x -= 1f;
|
|
GUI.color = Color.white;
|
|
GUI.Label(position, text);
|
|
position.y += 18f;
|
|
position.x += 1f;
|
|
}
|
|
int i = 0;
|
|
for (int count = mLines.Count; i < count; i++)
|
|
{
|
|
GUI.color = Color.black;
|
|
GUI.Label(position, mLines[i]);
|
|
position.y -= 1f;
|
|
position.x -= 1f;
|
|
GUI.color = Color.white;
|
|
GUI.Label(position, mLines[i]);
|
|
position.y += 18f;
|
|
position.x += 1f;
|
|
}
|
|
}
|
|
}
|