cull(engine-cleanup): pass-9 cascade round 1 after UIPanel stub
This commit is contained in:
@@ -211,131 +211,6 @@ public static class NGUITools
|
||||
return 0;
|
||||
}
|
||||
|
||||
public static UIPanel CreateUI(Transform trans, bool advanced3D, int layer)
|
||||
{
|
||||
UIRoot uIRoot = ((trans != null) ? FindInParents<UIRoot>(trans.gameObject) : null);
|
||||
if (uIRoot == null && UIRoot.list.Count > 0)
|
||||
{
|
||||
foreach (UIRoot item in UIRoot.list)
|
||||
{
|
||||
if (item.gameObject.layer == layer)
|
||||
{
|
||||
uIRoot = item;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (uIRoot == null)
|
||||
{
|
||||
int i = 0;
|
||||
for (int count = UIPanel.list.Count; i < count; i++)
|
||||
{
|
||||
UIPanel uIPanel = UIPanel.list[i];
|
||||
GameObject gameObject = uIPanel.gameObject;
|
||||
if (gameObject.hideFlags == HideFlags.None && gameObject.layer == layer)
|
||||
{
|
||||
trans.parent = uIPanel.transform;
|
||||
trans.localScale = Vector3.one;
|
||||
return uIPanel;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (uIRoot != null)
|
||||
{
|
||||
UICamera componentInChildren = uIRoot.GetComponentInChildren<UICamera>();
|
||||
if (componentInChildren != null && componentInChildren.GetComponent<Camera>().orthographic == advanced3D)
|
||||
{
|
||||
trans = null;
|
||||
uIRoot = null;
|
||||
}
|
||||
}
|
||||
if (uIRoot == null)
|
||||
{
|
||||
GameObject gameObject2 = AddChild(null, undo: false);
|
||||
uIRoot = gameObject2.AddComponent<UIRoot>();
|
||||
if (layer == -1)
|
||||
{
|
||||
layer = LayerMask.NameToLayer("UI");
|
||||
}
|
||||
if (layer == -1)
|
||||
{
|
||||
layer = LayerMask.NameToLayer("2D UI");
|
||||
}
|
||||
gameObject2.layer = layer;
|
||||
if (advanced3D)
|
||||
{
|
||||
gameObject2.name = "UI Root (3D)";
|
||||
uIRoot.scalingStyle = UIRoot.Scaling.Constrained;
|
||||
}
|
||||
else
|
||||
{
|
||||
gameObject2.name = "UI Root";
|
||||
uIRoot.scalingStyle = UIRoot.Scaling.Flexible;
|
||||
}
|
||||
}
|
||||
UIPanel uIPanel2 = uIRoot.GetComponentInChildren<UIPanel>();
|
||||
if (uIPanel2 == null)
|
||||
{
|
||||
Camera[] array = FindActive<Camera>();
|
||||
float num = -1f;
|
||||
bool flag = false;
|
||||
int num2 = 1 << uIRoot.gameObject.layer;
|
||||
foreach (Camera camera in array)
|
||||
{
|
||||
if (camera.clearFlags == CameraClearFlags.Color || camera.clearFlags == CameraClearFlags.Skybox)
|
||||
{
|
||||
flag = true;
|
||||
}
|
||||
num = Mathf.Max(num, camera.depth);
|
||||
camera.cullingMask &= ~num2;
|
||||
}
|
||||
Camera camera2 = AddChild<Camera>(uIRoot.gameObject, undo: false);
|
||||
camera2.gameObject.AddComponent<UICamera>();
|
||||
camera2.clearFlags = (flag ? CameraClearFlags.Depth : CameraClearFlags.Color);
|
||||
camera2.backgroundColor = Color.grey;
|
||||
camera2.cullingMask = num2;
|
||||
camera2.depth = num + 1f;
|
||||
if (advanced3D)
|
||||
{
|
||||
camera2.nearClipPlane = 0.1f;
|
||||
camera2.farClipPlane = 4f;
|
||||
camera2.transform.localPosition = new Vector3(0f, 0f, -700f);
|
||||
}
|
||||
else
|
||||
{
|
||||
camera2.orthographic = true;
|
||||
camera2.orthographicSize = 1f;
|
||||
camera2.nearClipPlane = -10f;
|
||||
camera2.farClipPlane = 10f;
|
||||
}
|
||||
AudioListener[] array2 = FindActive<AudioListener>();
|
||||
if (array2 == null || array2.Length == 0)
|
||||
{
|
||||
camera2.gameObject.AddComponent<AudioListener>();
|
||||
}
|
||||
uIPanel2 = uIRoot.gameObject.AddComponent<UIPanel>();
|
||||
}
|
||||
if (trans != null)
|
||||
{
|
||||
while (trans.parent != null)
|
||||
{
|
||||
trans = trans.parent;
|
||||
}
|
||||
if (IsChild(trans, uIPanel2.transform))
|
||||
{
|
||||
uIPanel2 = trans.gameObject.AddComponent<UIPanel>();
|
||||
}
|
||||
else
|
||||
{
|
||||
trans.parent = uIPanel2.transform;
|
||||
trans.localScale = Vector3.one;
|
||||
trans.localPosition = Vector3.zero;
|
||||
SetChildLayer(uIPanel2.cachedTransform, uIPanel2.cachedGameObject.layer);
|
||||
}
|
||||
}
|
||||
return uIPanel2;
|
||||
}
|
||||
|
||||
public static void SetChildLayer(Transform t, int layer)
|
||||
{
|
||||
for (int i = 0; i < t.childCount; i++)
|
||||
@@ -657,11 +532,6 @@ public static class NGUITools
|
||||
return val;
|
||||
}
|
||||
|
||||
public static Vector3[] GetSides(this Camera cam, float depth)
|
||||
{
|
||||
return cam.GetSides(depth, null);
|
||||
}
|
||||
|
||||
public static Vector3[] GetSides(this Camera cam, Transform relativeTo)
|
||||
{
|
||||
return cam.GetSides(Mathf.Lerp(cam.nearClipPlane, cam.farClipPlane, 0.5f), relativeTo);
|
||||
@@ -722,11 +592,6 @@ public static class NGUITools
|
||||
return mSides;
|
||||
}
|
||||
|
||||
public static Vector3[] GetWorldCorners(this Camera cam, float depth)
|
||||
{
|
||||
return cam.GetWorldCorners(depth, null);
|
||||
}
|
||||
|
||||
public static Vector3[] GetWorldCorners(this Camera cam, float depth, Transform relativeTo)
|
||||
{
|
||||
if (cam.orthographic)
|
||||
|
||||
Reference in New Issue
Block a user