public Vector2 GetLerpMessagePosition(InWorldLogPanel panel, float t) { Vector2 localPoint; Vector3 topOfActor = panel.actor.GetWorldRenderBoundsCenter() + Vector3.up * t * panel.actor.GetWorldRenderBoundsSize().y / 2f; Vector2 screenPoint = mainCamera.WorldToScreenPoint(topOfActor); RectTransformUtility.ScreenPointToLocalPointInRectangle(panel.rectTransform, screenPoint, null, out localPoint); return(localPoint); }
private void UpdatePanelPosition(InWorldLogPanel panel) { Vector2 localPoint; Vector3 topOfActor = panel.actor.GetWorldRenderBoundsCenter() + Vector3.up * panel.actor.GetWorldRenderBoundsSize().y / 2f; Vector2 screenPoint = mainCamera.WorldToScreenPoint(topOfActor); RectTransformUtility.ScreenPointToLocalPointInRectangle(canvasRect, screenPoint, null, out localPoint); // panel.SetPosition(localPoint); }
private InWorldLogPanel GetOrAddPanel(VoosActor actor) { if (!currentPanels.ContainsKey(actor)) { InWorldLogPanel newPanel = Instantiate(logPanelPrefab, canvasRect); newPanel.Setup(actor, this); currentPanels[actor] = newPanel; } return(currentPanels[actor]); }
// Update is called once per frame void Update() { if (!setupComplete) { return; } foreach (VoosActor actor in voosEngine.EnumerateActors()) { if (IsActorCenterOnScreen(actor)) { InWorldLogPanel panel = GetOrAddPanel(actor); UpdatePanelPosition(panel); } else { AttemptRemovePanel(actor); } } }