private static HUDIndicator InstantiateIndicator(ref HUDIndicator.Target target, HUDIndicator prefab, HUDIndicator.PlacementSpace space, Vector3 position, float rotation) { UIAnchor uIAnchor = target.anchor; Quaternion quaternion = Quaternion.AngleAxis(rotation, Vector3.back); switch (space) { case HUDIndicator.PlacementSpace.World: { Camera camera = HUDIndicator.Target.camera; Vector3?nullable = CameraFX.World2Screen(position); position = camera.ScreenToWorldPoint((!nullable.HasValue ? Vector3.zero : nullable.Value)); break; } case HUDIndicator.PlacementSpace.Screen: { position = HUDIndicator.Target.camera.ScreenToWorldPoint(position); break; } case HUDIndicator.PlacementSpace.Viewport: { position = HUDIndicator.Target.camera.ViewportToWorldPoint(position); break; } case HUDIndicator.PlacementSpace.Anchor: { position = uIAnchor.transform.TransformPoint(position); quaternion = uIAnchor.transform.rotation * quaternion; break; } } position.z = uIAnchor.transform.position.z; HUDIndicator hUDIndicator = (HUDIndicator)UnityEngine.Object.Instantiate(prefab, position, quaternion); hUDIndicator.transform.parent = uIAnchor.transform; hUDIndicator.transform.localScale = Vector3.one; hUDIndicator.anchor = target.anchor; return(hUDIndicator); }
static HUDIndicator() { HUDIndicator.worldToCameraLocalMatrix = Matrix4x4.identity; HUDIndicator.CenterFixed3000Tall = new HUDIndicator.Target("HUD_INDICATOR_CENTER_3000", 3000, UIAnchor.Side.Center); HUDIndicator.CenterAuto = new HUDIndicator.Target("HUD_INDICATOR_CENTER_AUTO", UIAnchor.Side.Center); }