/// <summary> /// Applied before LateUpdatePart2 runs. /// </summary> internal static bool Prefix(NameDisplayScreen __instance) { var camera = Camera.main; if (camera == null || camera.orthographicSize < __instance.HideDistance) { var entries = __instance.entries; int n = entries.Count; for (int i = 0; i < n; i++) { var go = entries[i].bars_go; if (go != null) { var colliders = __instance.workingList; // Mark the colliders in the bars list dirty only if visible go.GetComponentsInChildren(false, colliders); int c = colliders.Count; for (int j = 0; j < c; j++) { colliders[j].MarkDirty(false); } } } } return(false); }
/// <summary> /// Applied before LateUpdatePos runs. /// </summary> internal static bool Prefix(bool visibleToZoom, NameDisplayScreen __instance) { var inst = CameraController.Instance; if (inst != null) { GridArea area = inst.VisibleArea.CurrentArea; var entries = __instance.entries; var followTarget = inst.followTarget; int n = entries.Count; Vector3 pos; for (int i = 0; i < n; i++) { var entry = entries[i]; var go = entry.world_go; var dg = entry.display_go; var animController = entry.world_go_anim_controller; if (go != null && dg != null) { // Merely fetching the position appears to take almost 1 us? var transform = go.transform; bool active = dg.activeSelf; if (visibleToZoom && area.Contains(pos = transform.position)) { // Visible if (followTarget == transform) { pos = inst.followTargetPos; } else if (animController != null) { pos = animController.GetWorldPivot(); } entry.display_go_rect.anchoredPosition = __instance. worldSpace ? pos : __instance.WorldToScreen(pos); if (!active) { dg.SetActive(true); } } else if (active) { // Invisible dg.SetActive(false); } } } } return(false); }
protected override void OnPrefabInit() { base.OnPrefabInit(); Instance = this; }
public static void DestroyInstance() { Instance = null; }