public static FunctionUpdater CreateMouseDraggingAction(int mouseButton, Action <Vector3> onMouseDragging) { bool dragging = false; return(FunctionUpdater.Create(() => { if (Input.GetMouseButtonDown(mouseButton)) { dragging = true; } if (Input.GetMouseButtonUp(mouseButton)) { dragging = false; } if (dragging) { onMouseDragging(UtilsClass.GetMouseWorldPosition()); } return false; })); }
// Create a Text Popup in the World public static void CreateWorldTextPopup(Transform parent, string text, Vector3 localPosition, int fontSize, Color color, Vector3 finalPopupPosition, float popupTime) { TextMesh textMesh = CreateWorldText(parent, text, localPosition, fontSize, color, TextAnchor.LowerLeft, TextAlignment.Left, sortingOrderDefault); Transform transform = textMesh.transform; Vector3 moveAmount = (finalPopupPosition - localPosition) / popupTime; FunctionUpdater.Create(delegate() { transform.position += moveAmount * Time.deltaTime; popupTime -= Time.deltaTime; if (popupTime <= 0f) { UnityEngine.Object.Destroy(transform.gameObject); return(true); } else { return(false); } }, "WorldTextPopup"); }
private static void RemoveUpdater(FunctionUpdater funcUpdater) { InitIfNeeded(); updaterList.Remove(funcUpdater); }